@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
@@ -1 +1 @@
1
- {"version":3,"file":"queryDataSource.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messages/queryDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;IAExC,0DAA0D;;IAE1D,kDAAkD;;IAElD,iEAAiE;;aAEhE,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,WAAW,CACjD,OAAO,4BAA4B,CACnC,CAAA"}
1
+ {"version":3,"file":"queryDataSource.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messages/queryDataSource.ts"],"names":[],"mappings":"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"}
@@ -1,5 +1,109 @@
1
1
  import * as v from "valibot";
2
2
  import { notionDataSourceIdSchema } from "../ids.js";
3
+ const emptyOperatorSchema = v.union([
4
+ v.object({ is_empty: v.literal(true) }),
5
+ v.object({ is_not_empty: v.literal(true) }),
6
+ ]);
7
+ const stringOrStringArraySchema = v.union([v.string(), v.array(v.string())]);
8
+ export const customBlockTextFilterOperatorSchema = v.union([
9
+ v.object({ equals: v.string() }),
10
+ v.object({ does_not_equal: v.string() }),
11
+ v.object({ contains: v.string() }),
12
+ v.object({ does_not_contain: v.string() }),
13
+ v.object({ starts_with: v.string() }),
14
+ v.object({ ends_with: v.string() }),
15
+ emptyOperatorSchema,
16
+ ]);
17
+ export const customBlockNumberFilterOperatorSchema = v.union([
18
+ v.object({ equals: v.number() }),
19
+ v.object({ does_not_equal: v.number() }),
20
+ v.object({ greater_than: v.number() }),
21
+ v.object({ less_than: v.number() }),
22
+ v.object({ greater_than_or_equal_to: v.number() }),
23
+ v.object({ less_than_or_equal_to: v.number() }),
24
+ emptyOperatorSchema,
25
+ ]);
26
+ export const customBlockCheckboxFilterOperatorSchema = v.union([
27
+ v.object({ equals: v.boolean() }),
28
+ v.object({ does_not_equal: v.boolean() }),
29
+ ]);
30
+ export const customBlockOptionFilterOperatorSchema = v.union([
31
+ v.object({ equals: stringOrStringArraySchema }),
32
+ v.object({ does_not_equal: stringOrStringArraySchema }),
33
+ emptyOperatorSchema,
34
+ ]);
35
+ export const customBlockContainsFilterOperatorSchema = v.union([
36
+ v.object({ contains: stringOrStringArraySchema }),
37
+ v.object({ contains_all: stringOrStringArraySchema }),
38
+ v.object({ does_not_contain: stringOrStringArraySchema }),
39
+ emptyOperatorSchema,
40
+ ]);
41
+ export const customBlockDateFilterOperatorSchema = v.union([
42
+ v.object({ equals: v.string() }),
43
+ v.object({ before: v.string() }),
44
+ v.object({ after: v.string() }),
45
+ v.object({ on_or_before: v.string() }),
46
+ v.object({ on_or_after: v.string() }),
47
+ emptyOperatorSchema,
48
+ ]);
49
+ export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
50
+ v.object({
51
+ propertyId: v.string(),
52
+ title: customBlockTextFilterOperatorSchema,
53
+ }),
54
+ v.object({
55
+ propertyId: v.string(),
56
+ rich_text: customBlockTextFilterOperatorSchema,
57
+ }),
58
+ v.object({
59
+ propertyId: v.string(),
60
+ url: customBlockTextFilterOperatorSchema,
61
+ }),
62
+ v.object({
63
+ propertyId: v.string(),
64
+ email: customBlockTextFilterOperatorSchema,
65
+ }),
66
+ v.object({
67
+ propertyId: v.string(),
68
+ phone_number: customBlockTextFilterOperatorSchema,
69
+ }),
70
+ v.object({
71
+ propertyId: v.string(),
72
+ number: customBlockNumberFilterOperatorSchema,
73
+ }),
74
+ v.object({
75
+ propertyId: v.string(),
76
+ checkbox: customBlockCheckboxFilterOperatorSchema,
77
+ }),
78
+ v.object({
79
+ propertyId: v.string(),
80
+ select: customBlockOptionFilterOperatorSchema,
81
+ }),
82
+ v.object({
83
+ propertyId: v.string(),
84
+ multi_select: customBlockContainsFilterOperatorSchema,
85
+ }),
86
+ v.object({
87
+ propertyId: v.string(),
88
+ status: customBlockOptionFilterOperatorSchema,
89
+ }),
90
+ v.object({
91
+ propertyId: v.string(),
92
+ date: customBlockDateFilterOperatorSchema,
93
+ }),
94
+ ]);
95
+ export const resolvedCustomBlockDataSourceFilterSchema = v.union([
96
+ resolvedCustomBlockDataSourcePropertyFilterSchema,
97
+ v.object({
98
+ and: v.array(resolvedCustomBlockDataSourcePropertyFilterSchema),
99
+ }),
100
+ ]);
101
+ /** Maximum number of sort properties accepted in one data source query. */
102
+ export const CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS = 10;
103
+ export const resolvedCustomBlockDataSourceSortSchema = v.object({
104
+ propertyId: v.string(),
105
+ direction: v.picklist(["ascending", "descending"]),
106
+ });
3
107
  /**
4
108
  * Message sent by the sandbox to ask the host for the current rows in a resolved
5
109
  * Notion data source.
@@ -12,4 +116,8 @@ export const queryDataSourceMessageSchema = v.object({
12
116
  dataSourceId: notionDataSourceIdSchema,
13
117
  /** The number of items to return in each subscription update. */
14
118
  limit: v.number(),
119
+ /** A sandbox-resolved property filter. */
120
+ filter: v.optional(resolvedCustomBlockDataSourceFilterSchema),
121
+ /** Sandbox-resolved property sorts, in priority order. */
122
+ sorts: v.optional(v.array(resolvedCustomBlockDataSourceSortSchema)),
15
123
  });
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
2
  import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
3
  export declare const customBlockQueryDataSourceErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "unknown_data_source_key" | "unmapped_data_source">;
4
+ export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source">;
5
5
  export type CustomBlockQueryDataSourceErrorInfo = CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>;
6
6
  export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
7
7
  readonly code: v.StringSchema<undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"queryDataSourceResult.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messages/queryDataSourceResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAI9E,eAAO,MAAM,yCAAyC,2BAAa,CAAA;AAEnE,MAAM,MAAM,mCAAmC,GAAG,oBAAoB,CACnE,0BAA0B,GAC1B,yBAAyB,GACzB,sBAAsB,CACxB,CAAA;AAED,MAAM,MAAM,mCAAmC,GAC9C,oBAAoB,CAAC,mCAAmC,CAAC,CAAA;AAE1D,eAAO,MAAM,yCAAyC;;;;aAIpD,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAc7C,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CACvD,OAAO,kCAAkC,CACzC,CAAA"}
1
+ {"version":3,"file":"queryDataSourceResult.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messages/queryDataSourceResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAI9E,eAAO,MAAM,yCAAyC,2BAAa,CAAA;AAEnE,MAAM,MAAM,mCAAmC,GAAG,oBAAoB,CACnE,0BAA0B,GAC1B,2BAA2B,GAC3B,kCAAkC,GAClC,gCAAgC,GAChC,yBAAyB,GACzB,sBAAsB,CACxB,CAAA;AAED,MAAM,MAAM,mCAAmC,GAC9C,oBAAoB,CAAC,mCAAmC,CAAC,CAAA;AAE1D,eAAO,MAAM,yCAAyC;;;;aAIpD,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAc7C,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CACvD,OAAO,kCAAkC,CACzC,CAAA"}
@@ -58,6 +58,359 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
58
58
  readonly subscriptionId: v.StringSchema<undefined>;
59
59
  readonly dataSourceId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
60
60
  readonly limit: v.NumberSchema<undefined>;
61
+ readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
62
+ readonly propertyId: v.StringSchema<undefined>;
63
+ readonly title: v.UnionSchema<[v.ObjectSchema<{
64
+ readonly equals: v.StringSchema<undefined>;
65
+ }, undefined>, v.ObjectSchema<{
66
+ readonly does_not_equal: v.StringSchema<undefined>;
67
+ }, undefined>, v.ObjectSchema<{
68
+ readonly contains: v.StringSchema<undefined>;
69
+ }, undefined>, v.ObjectSchema<{
70
+ readonly does_not_contain: v.StringSchema<undefined>;
71
+ }, undefined>, v.ObjectSchema<{
72
+ readonly starts_with: v.StringSchema<undefined>;
73
+ }, undefined>, v.ObjectSchema<{
74
+ readonly ends_with: v.StringSchema<undefined>;
75
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
76
+ readonly is_empty: v.LiteralSchema<true, undefined>;
77
+ }, undefined>, v.ObjectSchema<{
78
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
79
+ }, undefined>], undefined>], undefined>;
80
+ }, undefined>, v.ObjectSchema<{
81
+ readonly propertyId: v.StringSchema<undefined>;
82
+ readonly rich_text: v.UnionSchema<[v.ObjectSchema<{
83
+ readonly equals: v.StringSchema<undefined>;
84
+ }, undefined>, v.ObjectSchema<{
85
+ readonly does_not_equal: v.StringSchema<undefined>;
86
+ }, undefined>, v.ObjectSchema<{
87
+ readonly contains: v.StringSchema<undefined>;
88
+ }, undefined>, v.ObjectSchema<{
89
+ readonly does_not_contain: v.StringSchema<undefined>;
90
+ }, undefined>, v.ObjectSchema<{
91
+ readonly starts_with: v.StringSchema<undefined>;
92
+ }, undefined>, v.ObjectSchema<{
93
+ readonly ends_with: v.StringSchema<undefined>;
94
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
95
+ readonly is_empty: v.LiteralSchema<true, undefined>;
96
+ }, undefined>, v.ObjectSchema<{
97
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
98
+ }, undefined>], undefined>], undefined>;
99
+ }, undefined>, v.ObjectSchema<{
100
+ readonly propertyId: v.StringSchema<undefined>;
101
+ readonly url: v.UnionSchema<[v.ObjectSchema<{
102
+ readonly equals: v.StringSchema<undefined>;
103
+ }, undefined>, v.ObjectSchema<{
104
+ readonly does_not_equal: v.StringSchema<undefined>;
105
+ }, undefined>, v.ObjectSchema<{
106
+ readonly contains: v.StringSchema<undefined>;
107
+ }, undefined>, v.ObjectSchema<{
108
+ readonly does_not_contain: v.StringSchema<undefined>;
109
+ }, undefined>, v.ObjectSchema<{
110
+ readonly starts_with: v.StringSchema<undefined>;
111
+ }, undefined>, v.ObjectSchema<{
112
+ readonly ends_with: v.StringSchema<undefined>;
113
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
114
+ readonly is_empty: v.LiteralSchema<true, undefined>;
115
+ }, undefined>, v.ObjectSchema<{
116
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
117
+ }, undefined>], undefined>], undefined>;
118
+ }, undefined>, v.ObjectSchema<{
119
+ readonly propertyId: v.StringSchema<undefined>;
120
+ readonly email: v.UnionSchema<[v.ObjectSchema<{
121
+ readonly equals: v.StringSchema<undefined>;
122
+ }, undefined>, v.ObjectSchema<{
123
+ readonly does_not_equal: v.StringSchema<undefined>;
124
+ }, undefined>, v.ObjectSchema<{
125
+ readonly contains: v.StringSchema<undefined>;
126
+ }, undefined>, v.ObjectSchema<{
127
+ readonly does_not_contain: v.StringSchema<undefined>;
128
+ }, undefined>, v.ObjectSchema<{
129
+ readonly starts_with: v.StringSchema<undefined>;
130
+ }, undefined>, v.ObjectSchema<{
131
+ readonly ends_with: v.StringSchema<undefined>;
132
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
133
+ readonly is_empty: v.LiteralSchema<true, undefined>;
134
+ }, undefined>, v.ObjectSchema<{
135
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
136
+ }, undefined>], undefined>], undefined>;
137
+ }, undefined>, v.ObjectSchema<{
138
+ readonly propertyId: v.StringSchema<undefined>;
139
+ readonly phone_number: v.UnionSchema<[v.ObjectSchema<{
140
+ readonly equals: v.StringSchema<undefined>;
141
+ }, undefined>, v.ObjectSchema<{
142
+ readonly does_not_equal: v.StringSchema<undefined>;
143
+ }, undefined>, v.ObjectSchema<{
144
+ readonly contains: v.StringSchema<undefined>;
145
+ }, undefined>, v.ObjectSchema<{
146
+ readonly does_not_contain: v.StringSchema<undefined>;
147
+ }, undefined>, v.ObjectSchema<{
148
+ readonly starts_with: v.StringSchema<undefined>;
149
+ }, undefined>, v.ObjectSchema<{
150
+ readonly ends_with: v.StringSchema<undefined>;
151
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
152
+ readonly is_empty: v.LiteralSchema<true, undefined>;
153
+ }, undefined>, v.ObjectSchema<{
154
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
155
+ }, undefined>], undefined>], undefined>;
156
+ }, undefined>, v.ObjectSchema<{
157
+ readonly propertyId: v.StringSchema<undefined>;
158
+ readonly number: v.UnionSchema<[v.ObjectSchema<{
159
+ readonly equals: v.NumberSchema<undefined>;
160
+ }, undefined>, v.ObjectSchema<{
161
+ readonly does_not_equal: v.NumberSchema<undefined>;
162
+ }, undefined>, v.ObjectSchema<{
163
+ readonly greater_than: v.NumberSchema<undefined>;
164
+ }, undefined>, v.ObjectSchema<{
165
+ readonly less_than: v.NumberSchema<undefined>;
166
+ }, undefined>, v.ObjectSchema<{
167
+ readonly greater_than_or_equal_to: v.NumberSchema<undefined>;
168
+ }, undefined>, v.ObjectSchema<{
169
+ readonly less_than_or_equal_to: v.NumberSchema<undefined>;
170
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
171
+ readonly is_empty: v.LiteralSchema<true, undefined>;
172
+ }, undefined>, v.ObjectSchema<{
173
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
174
+ }, undefined>], undefined>], undefined>;
175
+ }, undefined>, v.ObjectSchema<{
176
+ readonly propertyId: v.StringSchema<undefined>;
177
+ readonly checkbox: v.UnionSchema<[v.ObjectSchema<{
178
+ readonly equals: v.BooleanSchema<undefined>;
179
+ }, undefined>, v.ObjectSchema<{
180
+ readonly does_not_equal: v.BooleanSchema<undefined>;
181
+ }, undefined>], undefined>;
182
+ }, undefined>, v.ObjectSchema<{
183
+ readonly propertyId: v.StringSchema<undefined>;
184
+ readonly select: v.UnionSchema<[v.ObjectSchema<{
185
+ readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
186
+ }, undefined>, v.ObjectSchema<{
187
+ readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
188
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
189
+ readonly is_empty: v.LiteralSchema<true, undefined>;
190
+ }, undefined>, v.ObjectSchema<{
191
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
192
+ }, undefined>], undefined>], undefined>;
193
+ }, undefined>, v.ObjectSchema<{
194
+ readonly propertyId: v.StringSchema<undefined>;
195
+ readonly multi_select: v.UnionSchema<[v.ObjectSchema<{
196
+ readonly contains: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
197
+ }, undefined>, v.ObjectSchema<{
198
+ readonly contains_all: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
199
+ }, undefined>, v.ObjectSchema<{
200
+ readonly does_not_contain: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
201
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
202
+ readonly is_empty: v.LiteralSchema<true, undefined>;
203
+ }, undefined>, v.ObjectSchema<{
204
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
205
+ }, undefined>], undefined>], undefined>;
206
+ }, undefined>, v.ObjectSchema<{
207
+ readonly propertyId: v.StringSchema<undefined>;
208
+ readonly status: v.UnionSchema<[v.ObjectSchema<{
209
+ readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
210
+ }, undefined>, v.ObjectSchema<{
211
+ readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
212
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
213
+ readonly is_empty: v.LiteralSchema<true, undefined>;
214
+ }, undefined>, v.ObjectSchema<{
215
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
216
+ }, undefined>], undefined>], undefined>;
217
+ }, undefined>, v.ObjectSchema<{
218
+ readonly propertyId: v.StringSchema<undefined>;
219
+ readonly date: v.UnionSchema<[v.ObjectSchema<{
220
+ readonly equals: v.StringSchema<undefined>;
221
+ }, undefined>, v.ObjectSchema<{
222
+ readonly before: v.StringSchema<undefined>;
223
+ }, undefined>, v.ObjectSchema<{
224
+ readonly after: v.StringSchema<undefined>;
225
+ }, undefined>, v.ObjectSchema<{
226
+ readonly on_or_before: v.StringSchema<undefined>;
227
+ }, undefined>, v.ObjectSchema<{
228
+ readonly on_or_after: v.StringSchema<undefined>;
229
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
230
+ readonly is_empty: v.LiteralSchema<true, undefined>;
231
+ }, undefined>, v.ObjectSchema<{
232
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
233
+ }, undefined>], undefined>], undefined>;
234
+ }, undefined>], undefined>, v.ObjectSchema<{
235
+ readonly and: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
236
+ readonly propertyId: v.StringSchema<undefined>;
237
+ readonly title: v.UnionSchema<[v.ObjectSchema<{
238
+ readonly equals: v.StringSchema<undefined>;
239
+ }, undefined>, v.ObjectSchema<{
240
+ readonly does_not_equal: v.StringSchema<undefined>;
241
+ }, undefined>, v.ObjectSchema<{
242
+ readonly contains: v.StringSchema<undefined>;
243
+ }, undefined>, v.ObjectSchema<{
244
+ readonly does_not_contain: v.StringSchema<undefined>;
245
+ }, undefined>, v.ObjectSchema<{
246
+ readonly starts_with: v.StringSchema<undefined>;
247
+ }, undefined>, v.ObjectSchema<{
248
+ readonly ends_with: v.StringSchema<undefined>;
249
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
250
+ readonly is_empty: v.LiteralSchema<true, undefined>;
251
+ }, undefined>, v.ObjectSchema<{
252
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
253
+ }, undefined>], undefined>], undefined>;
254
+ }, undefined>, v.ObjectSchema<{
255
+ readonly propertyId: v.StringSchema<undefined>;
256
+ readonly rich_text: v.UnionSchema<[v.ObjectSchema<{
257
+ readonly equals: v.StringSchema<undefined>;
258
+ }, undefined>, v.ObjectSchema<{
259
+ readonly does_not_equal: v.StringSchema<undefined>;
260
+ }, undefined>, v.ObjectSchema<{
261
+ readonly contains: v.StringSchema<undefined>;
262
+ }, undefined>, v.ObjectSchema<{
263
+ readonly does_not_contain: v.StringSchema<undefined>;
264
+ }, undefined>, v.ObjectSchema<{
265
+ readonly starts_with: v.StringSchema<undefined>;
266
+ }, undefined>, v.ObjectSchema<{
267
+ readonly ends_with: v.StringSchema<undefined>;
268
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
269
+ readonly is_empty: v.LiteralSchema<true, undefined>;
270
+ }, undefined>, v.ObjectSchema<{
271
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
272
+ }, undefined>], undefined>], undefined>;
273
+ }, undefined>, v.ObjectSchema<{
274
+ readonly propertyId: v.StringSchema<undefined>;
275
+ readonly url: v.UnionSchema<[v.ObjectSchema<{
276
+ readonly equals: v.StringSchema<undefined>;
277
+ }, undefined>, v.ObjectSchema<{
278
+ readonly does_not_equal: v.StringSchema<undefined>;
279
+ }, undefined>, v.ObjectSchema<{
280
+ readonly contains: v.StringSchema<undefined>;
281
+ }, undefined>, v.ObjectSchema<{
282
+ readonly does_not_contain: v.StringSchema<undefined>;
283
+ }, undefined>, v.ObjectSchema<{
284
+ readonly starts_with: v.StringSchema<undefined>;
285
+ }, undefined>, v.ObjectSchema<{
286
+ readonly ends_with: v.StringSchema<undefined>;
287
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
288
+ readonly is_empty: v.LiteralSchema<true, undefined>;
289
+ }, undefined>, v.ObjectSchema<{
290
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
291
+ }, undefined>], undefined>], undefined>;
292
+ }, undefined>, v.ObjectSchema<{
293
+ readonly propertyId: v.StringSchema<undefined>;
294
+ readonly email: v.UnionSchema<[v.ObjectSchema<{
295
+ readonly equals: v.StringSchema<undefined>;
296
+ }, undefined>, v.ObjectSchema<{
297
+ readonly does_not_equal: v.StringSchema<undefined>;
298
+ }, undefined>, v.ObjectSchema<{
299
+ readonly contains: v.StringSchema<undefined>;
300
+ }, undefined>, v.ObjectSchema<{
301
+ readonly does_not_contain: v.StringSchema<undefined>;
302
+ }, undefined>, v.ObjectSchema<{
303
+ readonly starts_with: v.StringSchema<undefined>;
304
+ }, undefined>, v.ObjectSchema<{
305
+ readonly ends_with: v.StringSchema<undefined>;
306
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
307
+ readonly is_empty: v.LiteralSchema<true, undefined>;
308
+ }, undefined>, v.ObjectSchema<{
309
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
310
+ }, undefined>], undefined>], undefined>;
311
+ }, undefined>, v.ObjectSchema<{
312
+ readonly propertyId: v.StringSchema<undefined>;
313
+ readonly phone_number: v.UnionSchema<[v.ObjectSchema<{
314
+ readonly equals: v.StringSchema<undefined>;
315
+ }, undefined>, v.ObjectSchema<{
316
+ readonly does_not_equal: v.StringSchema<undefined>;
317
+ }, undefined>, v.ObjectSchema<{
318
+ readonly contains: v.StringSchema<undefined>;
319
+ }, undefined>, v.ObjectSchema<{
320
+ readonly does_not_contain: v.StringSchema<undefined>;
321
+ }, undefined>, v.ObjectSchema<{
322
+ readonly starts_with: v.StringSchema<undefined>;
323
+ }, undefined>, v.ObjectSchema<{
324
+ readonly ends_with: v.StringSchema<undefined>;
325
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
326
+ readonly is_empty: v.LiteralSchema<true, undefined>;
327
+ }, undefined>, v.ObjectSchema<{
328
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
329
+ }, undefined>], undefined>], undefined>;
330
+ }, undefined>, v.ObjectSchema<{
331
+ readonly propertyId: v.StringSchema<undefined>;
332
+ readonly number: v.UnionSchema<[v.ObjectSchema<{
333
+ readonly equals: v.NumberSchema<undefined>;
334
+ }, undefined>, v.ObjectSchema<{
335
+ readonly does_not_equal: v.NumberSchema<undefined>;
336
+ }, undefined>, v.ObjectSchema<{
337
+ readonly greater_than: v.NumberSchema<undefined>;
338
+ }, undefined>, v.ObjectSchema<{
339
+ readonly less_than: v.NumberSchema<undefined>;
340
+ }, undefined>, v.ObjectSchema<{
341
+ readonly greater_than_or_equal_to: v.NumberSchema<undefined>;
342
+ }, undefined>, v.ObjectSchema<{
343
+ readonly less_than_or_equal_to: v.NumberSchema<undefined>;
344
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
345
+ readonly is_empty: v.LiteralSchema<true, undefined>;
346
+ }, undefined>, v.ObjectSchema<{
347
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
348
+ }, undefined>], undefined>], undefined>;
349
+ }, undefined>, v.ObjectSchema<{
350
+ readonly propertyId: v.StringSchema<undefined>;
351
+ readonly checkbox: v.UnionSchema<[v.ObjectSchema<{
352
+ readonly equals: v.BooleanSchema<undefined>;
353
+ }, undefined>, v.ObjectSchema<{
354
+ readonly does_not_equal: v.BooleanSchema<undefined>;
355
+ }, undefined>], undefined>;
356
+ }, undefined>, v.ObjectSchema<{
357
+ readonly propertyId: v.StringSchema<undefined>;
358
+ readonly select: v.UnionSchema<[v.ObjectSchema<{
359
+ readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
360
+ }, undefined>, v.ObjectSchema<{
361
+ readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
362
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
363
+ readonly is_empty: v.LiteralSchema<true, undefined>;
364
+ }, undefined>, v.ObjectSchema<{
365
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
366
+ }, undefined>], undefined>], undefined>;
367
+ }, undefined>, v.ObjectSchema<{
368
+ readonly propertyId: v.StringSchema<undefined>;
369
+ readonly multi_select: v.UnionSchema<[v.ObjectSchema<{
370
+ readonly contains: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
371
+ }, undefined>, v.ObjectSchema<{
372
+ readonly contains_all: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
373
+ }, undefined>, v.ObjectSchema<{
374
+ readonly does_not_contain: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
375
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
376
+ readonly is_empty: v.LiteralSchema<true, undefined>;
377
+ }, undefined>, v.ObjectSchema<{
378
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
379
+ }, undefined>], undefined>], undefined>;
380
+ }, undefined>, v.ObjectSchema<{
381
+ readonly propertyId: v.StringSchema<undefined>;
382
+ readonly status: v.UnionSchema<[v.ObjectSchema<{
383
+ readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
384
+ }, undefined>, v.ObjectSchema<{
385
+ readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
386
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
387
+ readonly is_empty: v.LiteralSchema<true, undefined>;
388
+ }, undefined>, v.ObjectSchema<{
389
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
390
+ }, undefined>], undefined>], undefined>;
391
+ }, undefined>, v.ObjectSchema<{
392
+ readonly propertyId: v.StringSchema<undefined>;
393
+ readonly date: v.UnionSchema<[v.ObjectSchema<{
394
+ readonly equals: v.StringSchema<undefined>;
395
+ }, undefined>, v.ObjectSchema<{
396
+ readonly before: v.StringSchema<undefined>;
397
+ }, undefined>, v.ObjectSchema<{
398
+ readonly after: v.StringSchema<undefined>;
399
+ }, undefined>, v.ObjectSchema<{
400
+ readonly on_or_before: v.StringSchema<undefined>;
401
+ }, undefined>, v.ObjectSchema<{
402
+ readonly on_or_after: v.StringSchema<undefined>;
403
+ }, undefined>, v.UnionSchema<[v.ObjectSchema<{
404
+ readonly is_empty: v.LiteralSchema<true, undefined>;
405
+ }, undefined>, v.ObjectSchema<{
406
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
407
+ }, undefined>], undefined>], undefined>;
408
+ }, undefined>], undefined>, undefined>;
409
+ }, undefined>], undefined>, undefined>;
410
+ readonly sorts: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
411
+ readonly propertyId: v.StringSchema<undefined>;
412
+ readonly direction: v.PicklistSchema<["ascending", "descending"], undefined>;
413
+ }, undefined>, undefined>, undefined>;
61
414
  }, undefined>, v.ObjectSchema<{
62
415
  readonly type: v.LiteralSchema<"createPage", undefined>;
63
416
  readonly requestId: v.StringSchema<undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAY5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAWrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
1
+ {"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAY5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAWrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
@@ -4,7 +4,7 @@ import type { UseDataSourceOptions, UseDataSourceResult } from "../types.js";
4
4
  *
5
5
  * @param key - The semantic data source key the block is wired to (e.g. `"people"`).
6
6
  * @param options - Optional live snapshot options. `limit` defaults to 20 and
7
- * is capped at 999.
7
+ * is capped at 999. `sorts` are applied in array order.
8
8
  *
9
9
  * @example
10
10
  * const { items, isLoading, hasMore, error } = useDataSource("default", { limit: 25 })
@@ -1 +1 @@
1
- {"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/react/useDataSource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAG5E;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,oBAAoB,GAC5B,mBAAmB,CA6BrB"}
1
+ {"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/react/useDataSource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAG5E;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,oBAAoB,GAC5B,mBAAmB,CAuCrB"}
@@ -1,4 +1,5 @@
1
- import { useEffect } from "react";
1
+ import { useEffect, useState } from "react";
2
+ import { getDataSourceQueryOptionsIdentity } from "../bridge/dataSources/query.js";
2
3
  import { customBlockDataSources } from "../bridge/sandboxClient.js";
3
4
  import { useCustomBlockHost } from "./useHostState.js";
4
5
  /**
@@ -6,14 +7,15 @@ import { useCustomBlockHost } from "./useHostState.js";
6
7
  *
7
8
  * @param key - The semantic data source key the block is wired to (e.g. `"people"`).
8
9
  * @param options - Optional live snapshot options. `limit` defaults to 20 and
9
- * is capped at 999.
10
+ * is capped at 999. `sorts` are applied in array order.
10
11
  *
11
12
  * @example
12
13
  * const { items, isLoading, hasMore, error } = useDataSource("default", { limit: 25 })
13
14
  */
14
15
  export function useDataSource(key, options) {
15
16
  const host = useCustomBlockHost();
16
- const limit = options?.limit;
17
+ const [subscriptionId] = useState(() => customBlockDataSources.createSubscriptionId());
18
+ const optionsIdentity = getDataSourceQueryOptionsIdentity(options);
17
19
  const matchingDataSource = host.status === "initialized"
18
20
  ? host.dataSources.find(dataSource => dataSource.key === key)
19
21
  : undefined;
@@ -22,9 +24,12 @@ export function useDataSource(key, options) {
22
24
  if (!isInitialized) {
23
25
  return;
24
26
  }
25
- customBlockDataSources.query(key, { limit });
26
- }, [matchingDataSource, isInitialized, key, limit]);
27
- const view = customBlockDataSources.getView(host, key);
27
+ customBlockDataSources.query(subscriptionId, key, options);
28
+ }, [matchingDataSource, isInitialized, key, optionsIdentity, subscriptionId]);
29
+ useEffect(() => () => {
30
+ customBlockDataSources.release(subscriptionId);
31
+ }, [subscriptionId]);
32
+ const view = customBlockDataSources.getView(host, key, subscriptionId);
28
33
  return {
29
34
  items: view.items,
30
35
  collectionSchema: view.collectionSchema,
package/dist/types.d.ts CHANGED
@@ -8,6 +8,7 @@ import type { CreatePageResultMessage, CustomBlockCreatePageErrorInfo } from "./
8
8
  import type { CustomBlockGetPageErrorInfo, GetPageResultMessage } from "./protocol/messages/getPage.js";
9
9
  import type { CustomBlockGetUserErrorInfo, GetUserResultMessage } from "./protocol/messages/getUser.js";
10
10
  import type { CustomBlockListUsersErrorInfo, ListUsersMessage, ListUsersResultMessage } from "./protocol/messages/listUsers.js";
11
+ import type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockTextFilterOperator } from "./protocol/messages/queryDataSource.js";
11
12
  import type { CustomBlockQueryDataSourceErrorInfo } from "./protocol/messages/queryDataSourceResult.js";
12
13
  import type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
13
14
  import type { CustomBlockUpdatePageErrorInfo, UpdatePageResultMessage } from "./protocol/messages/updatePageResult.js";
@@ -74,6 +75,48 @@ export type NotionDataSourcePageUpdateInput = NotionDataSourcePageUpdateArgs;
74
75
  * TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
75
76
  */
76
77
  export type NotionDataSourcePageUpdateResult = UpdatePageResult;
78
+ export type NotionDataSourceTextFilterOperator = CustomBlockTextFilterOperator;
79
+ export type NotionDataSourceNumberFilterOperator = CustomBlockNumberFilterOperator;
80
+ export type NotionDataSourceCheckboxFilterOperator = CustomBlockCheckboxFilterOperator;
81
+ export type NotionDataSourceOptionFilterOperator = CustomBlockOptionFilterOperator;
82
+ export type NotionDataSourceContainsFilterOperator = CustomBlockContainsFilterOperator;
83
+ export type NotionDataSourceDateFilterOperator = CustomBlockDateFilterOperator;
84
+ export type NotionDataSourcePropertyAddress = {
85
+ key: string;
86
+ propertyId?: never;
87
+ } | {
88
+ propertyId: string;
89
+ key?: never;
90
+ };
91
+ export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress & ({
92
+ title: NotionDataSourceTextFilterOperator;
93
+ } | {
94
+ rich_text: NotionDataSourceTextFilterOperator;
95
+ } | {
96
+ url: NotionDataSourceTextFilterOperator;
97
+ } | {
98
+ email: NotionDataSourceTextFilterOperator;
99
+ } | {
100
+ phone_number: NotionDataSourceTextFilterOperator;
101
+ } | {
102
+ number: NotionDataSourceNumberFilterOperator;
103
+ } | {
104
+ checkbox: NotionDataSourceCheckboxFilterOperator;
105
+ } | {
106
+ select: NotionDataSourceOptionFilterOperator;
107
+ } | {
108
+ multi_select: NotionDataSourceContainsFilterOperator;
109
+ } | {
110
+ status: NotionDataSourceOptionFilterOperator;
111
+ } | {
112
+ date: NotionDataSourceDateFilterOperator;
113
+ });
114
+ export type NotionDataSourceSort = NotionDataSourcePropertyAddress & {
115
+ direction: "ascending" | "descending";
116
+ };
117
+ export type NotionDataSourceFilter = NotionDataSourcePropertyFilter | {
118
+ and: NotionDataSourcePropertyFilter[];
119
+ };
77
120
  /**
78
121
  * Return shape of `useDataSource`.
79
122
  *
@@ -120,6 +163,15 @@ export type UseDataSourceOptions = {
120
163
  * Maximum number of rows to request from the host. Defaults to 20.
121
164
  */
122
165
  limit?: number;
166
+ /**
167
+ * Optional property filter. The SDK resolves semantic property keys before
168
+ * it sends the query to the host.
169
+ */
170
+ filter?: NotionDataSourceFilter;
171
+ /**
172
+ * Optional property sorts. The host applies them in array order.
173
+ */
174
+ sorts?: NotionDataSourceSort[];
123
175
  };
124
176
  /**
125
177
  * Parent reference accepted by `sdk.pages.create`. Mirrors Notion's public `POST /v1/pages`