@notionhq/custom-blocks 0.0.75 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOST.md +9 -5
- package/dist/bridge/SandboxBridge.d.ts +0 -1
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +15 -34
- package/dist/bridge/hostState.d.ts +1 -2
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/messages/hostToSandbox.d.ts +3 -79
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
- package/dist/bridge/messages/hostToSandbox.js +2 -3
- package/dist/bridge/messages/queryDataSource.d.ts +3 -7
- package/dist/bridge/messages/queryDataSource.d.ts.map +1 -1
- package/dist/bridge/messages/queryDataSource.js +3 -7
- package/dist/bridge/messages/queryDataSourceResult.d.ts +4 -240
- package/dist/bridge/messages/queryDataSourceResult.d.ts.map +1 -1
- package/dist/bridge/messages/queryDataSourceResult.js +4 -22
- package/dist/bridge/messages/sandboxToHost.d.ts +1 -2
- package/dist/bridge/messages/sandboxToHost.d.ts.map +1 -1
- package/dist/host/createCustomBlockHost.d.ts.map +1 -1
- package/dist/host/createCustomBlockHost.js +25 -20
- package/dist/host/queries/querySubscriptions.d.ts +10 -10
- package/dist/host/queries/querySubscriptions.d.ts.map +1 -1
- package/dist/host/queries/querySubscriptions.js +35 -19
- package/dist/host/queries/types.d.ts +5 -4
- package/dist/host/queries/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +15 -35
- package/src/bridge/hostState.ts +1 -2
- package/src/bridge/messages/hostToSandbox.ts +2 -6
- package/src/bridge/messages/queryDataSource.ts +3 -7
- package/src/bridge/messages/queryDataSourceResult.ts +4 -24
- package/src/host/createCustomBlockHost.ts +27 -22
- package/src/host/queries/querySubscriptions.ts +58 -39
- package/src/host/queries/types.ts +10 -11
|
@@ -9,87 +9,11 @@ export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
|
|
|
9
9
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
10
10
|
}, undefined>;
|
|
11
11
|
/**
|
|
12
|
-
* Message sent by the host to
|
|
12
|
+
* Message sent by the host to update a `queryDataSource` subscription.
|
|
13
13
|
*/
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
15
15
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
16
|
-
readonly
|
|
17
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
18
|
-
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
19
|
-
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
20
|
-
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
21
|
-
readonly type: v.LiteralSchema<"date", undefined>;
|
|
22
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
23
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
24
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
25
|
-
readonly value: v.NumberSchema<undefined>;
|
|
26
|
-
readonly time: v.StringSchema<undefined>;
|
|
27
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
28
|
-
}, undefined>, v.ObjectSchema<{
|
|
29
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
30
|
-
}, undefined>], undefined>, undefined>;
|
|
31
|
-
}, undefined>, v.ObjectSchema<{
|
|
32
|
-
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
33
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
34
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
35
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
36
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
37
|
-
readonly value: v.NumberSchema<undefined>;
|
|
38
|
-
readonly time: v.StringSchema<undefined>;
|
|
39
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
40
|
-
}, undefined>, v.ObjectSchema<{
|
|
41
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
42
|
-
}, undefined>], undefined>, undefined>;
|
|
43
|
-
}, undefined>, v.ObjectSchema<{
|
|
44
|
-
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
45
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
46
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
47
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
48
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
49
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
50
|
-
readonly value: v.NumberSchema<undefined>;
|
|
51
|
-
readonly time: v.StringSchema<undefined>;
|
|
52
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
53
|
-
}, undefined>, v.ObjectSchema<{
|
|
54
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
55
|
-
readonly value: v.NumberSchema<undefined>;
|
|
56
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
57
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
58
|
-
}, undefined>], undefined>, undefined>;
|
|
59
|
-
}, undefined>, v.ObjectSchema<{
|
|
60
|
-
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
61
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
62
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
63
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
64
|
-
readonly end_time: v.StringSchema<undefined>;
|
|
65
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
67
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
68
|
-
readonly value: v.NumberSchema<undefined>;
|
|
69
|
-
readonly time: v.StringSchema<undefined>;
|
|
70
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
-
}, undefined>, v.ObjectSchema<{
|
|
72
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
73
|
-
readonly value: v.NumberSchema<undefined>;
|
|
74
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
75
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
76
|
-
}, undefined>], undefined>, undefined>;
|
|
77
|
-
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
78
|
-
readonly id: v.StringSchema<undefined>;
|
|
79
|
-
readonly table: v.StringSchema<undefined>;
|
|
80
|
-
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
81
|
-
}, undefined>, undefined>;
|
|
82
|
-
readonly hasMore: v.BooleanSchema<undefined>;
|
|
83
|
-
readonly error: v.OptionalSchema<v.ObjectSchema<{
|
|
84
|
-
readonly code: v.StringSchema<undefined>;
|
|
85
|
-
readonly message: v.StringSchema<undefined>;
|
|
86
|
-
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
87
|
-
}, undefined>, undefined>;
|
|
88
|
-
}, undefined>;
|
|
89
|
-
export declare const statusQueryDataSourceResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
90
|
-
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
91
|
-
readonly requestId: v.StringSchema<undefined>;
|
|
92
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
16
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
93
17
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
94
18
|
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
95
19
|
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
@@ -158,8 +82,7 @@ export declare const statusQueryDataSourceResultMessageSchema: v.VariantSchema<"
|
|
|
158
82
|
readonly hasMore: v.BooleanSchema<undefined>;
|
|
159
83
|
}, undefined>, v.ObjectSchema<{
|
|
160
84
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
161
|
-
readonly
|
|
162
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
85
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
163
86
|
readonly status: v.LiteralSchema<"error", undefined>;
|
|
164
87
|
readonly error: v.ObjectSchema<{
|
|
165
88
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -167,164 +90,5 @@ export declare const statusQueryDataSourceResultMessageSchema: v.VariantSchema<"
|
|
|
167
90
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
168
91
|
}, undefined>;
|
|
169
92
|
}, undefined>], undefined>;
|
|
170
|
-
/**
|
|
171
|
-
* TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
172
|
-
* Protocol version 2 hosts and sandboxes use the legacy optional-error shape.
|
|
173
|
-
*/
|
|
174
|
-
export declare const queryDataSourceResultMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
175
|
-
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
176
|
-
readonly requestId: v.StringSchema<undefined>;
|
|
177
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
178
|
-
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
179
|
-
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
180
|
-
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
181
|
-
readonly type: v.LiteralSchema<"date", undefined>;
|
|
182
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
183
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
184
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
185
|
-
readonly value: v.NumberSchema<undefined>;
|
|
186
|
-
readonly time: v.StringSchema<undefined>;
|
|
187
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
188
|
-
}, undefined>, v.ObjectSchema<{
|
|
189
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
190
|
-
}, undefined>], undefined>, undefined>;
|
|
191
|
-
}, undefined>, v.ObjectSchema<{
|
|
192
|
-
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
193
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
194
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
195
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
196
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
197
|
-
readonly value: v.NumberSchema<undefined>;
|
|
198
|
-
readonly time: v.StringSchema<undefined>;
|
|
199
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
200
|
-
}, undefined>, v.ObjectSchema<{
|
|
201
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
202
|
-
}, undefined>], undefined>, undefined>;
|
|
203
|
-
}, undefined>, v.ObjectSchema<{
|
|
204
|
-
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
205
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
206
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
207
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
208
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
209
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
210
|
-
readonly value: v.NumberSchema<undefined>;
|
|
211
|
-
readonly time: v.StringSchema<undefined>;
|
|
212
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
213
|
-
}, undefined>, v.ObjectSchema<{
|
|
214
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
215
|
-
readonly value: v.NumberSchema<undefined>;
|
|
216
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
217
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
218
|
-
}, undefined>], undefined>, undefined>;
|
|
219
|
-
}, undefined>, v.ObjectSchema<{
|
|
220
|
-
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
221
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
222
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
223
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
224
|
-
readonly end_time: v.StringSchema<undefined>;
|
|
225
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
226
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
227
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
228
|
-
readonly value: v.NumberSchema<undefined>;
|
|
229
|
-
readonly time: v.StringSchema<undefined>;
|
|
230
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
231
|
-
}, undefined>, v.ObjectSchema<{
|
|
232
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
233
|
-
readonly value: v.NumberSchema<undefined>;
|
|
234
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
235
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
236
|
-
}, undefined>], undefined>, undefined>;
|
|
237
|
-
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
238
|
-
readonly id: v.StringSchema<undefined>;
|
|
239
|
-
readonly table: v.StringSchema<undefined>;
|
|
240
|
-
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
241
|
-
}, undefined>, undefined>;
|
|
242
|
-
readonly hasMore: v.BooleanSchema<undefined>;
|
|
243
|
-
readonly error: v.OptionalSchema<v.ObjectSchema<{
|
|
244
|
-
readonly code: v.StringSchema<undefined>;
|
|
245
|
-
readonly message: v.StringSchema<undefined>;
|
|
246
|
-
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
247
|
-
}, undefined>, undefined>;
|
|
248
|
-
}, undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
249
|
-
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
250
|
-
readonly requestId: v.StringSchema<undefined>;
|
|
251
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
252
|
-
readonly status: v.LiteralSchema<"success", undefined>;
|
|
253
|
-
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
254
|
-
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
255
|
-
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
256
|
-
readonly type: v.LiteralSchema<"date", undefined>;
|
|
257
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
258
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
259
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
260
|
-
readonly value: v.NumberSchema<undefined>;
|
|
261
|
-
readonly time: v.StringSchema<undefined>;
|
|
262
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
263
|
-
}, undefined>, v.ObjectSchema<{
|
|
264
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
265
|
-
}, undefined>], undefined>, undefined>;
|
|
266
|
-
}, undefined>, v.ObjectSchema<{
|
|
267
|
-
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
268
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
269
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
270
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
271
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
272
|
-
readonly value: v.NumberSchema<undefined>;
|
|
273
|
-
readonly time: v.StringSchema<undefined>;
|
|
274
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
275
|
-
}, undefined>, v.ObjectSchema<{
|
|
276
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
277
|
-
}, undefined>], undefined>, undefined>;
|
|
278
|
-
}, undefined>, v.ObjectSchema<{
|
|
279
|
-
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
280
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
281
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
282
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
283
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
284
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
285
|
-
readonly value: v.NumberSchema<undefined>;
|
|
286
|
-
readonly time: v.StringSchema<undefined>;
|
|
287
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
288
|
-
}, undefined>, v.ObjectSchema<{
|
|
289
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
290
|
-
readonly value: v.NumberSchema<undefined>;
|
|
291
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
292
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
293
|
-
}, undefined>], undefined>, undefined>;
|
|
294
|
-
}, undefined>, v.ObjectSchema<{
|
|
295
|
-
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
296
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
297
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
298
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
299
|
-
readonly end_time: v.StringSchema<undefined>;
|
|
300
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
301
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
302
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
303
|
-
readonly value: v.NumberSchema<undefined>;
|
|
304
|
-
readonly time: v.StringSchema<undefined>;
|
|
305
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
306
|
-
}, undefined>, v.ObjectSchema<{
|
|
307
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
308
|
-
readonly value: v.NumberSchema<undefined>;
|
|
309
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
310
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
311
|
-
}, undefined>], undefined>, undefined>;
|
|
312
|
-
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
313
|
-
readonly id: v.StringSchema<undefined>;
|
|
314
|
-
readonly table: v.StringSchema<undefined>;
|
|
315
|
-
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
316
|
-
}, undefined>, undefined>;
|
|
317
|
-
readonly hasMore: v.BooleanSchema<undefined>;
|
|
318
|
-
}, undefined>, v.ObjectSchema<{
|
|
319
|
-
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
320
|
-
readonly requestId: v.StringSchema<undefined>;
|
|
321
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
322
|
-
readonly status: v.LiteralSchema<"error", undefined>;
|
|
323
|
-
readonly error: v.ObjectSchema<{
|
|
324
|
-
readonly code: v.StringSchema<undefined>;
|
|
325
|
-
readonly message: v.StringSchema<undefined>;
|
|
326
|
-
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
327
|
-
}, undefined>;
|
|
328
|
-
}, undefined>], undefined>], undefined>;
|
|
329
93
|
export type QueryDataSourceResultMessage = v.InferOutput<typeof queryDataSourceResultMessageSchema>;
|
|
330
94
|
//# sourceMappingURL=queryDataSourceResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryDataSourceResult.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/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,
|
|
1
|
+
{"version":3,"file":"queryDataSourceResult.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/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"}
|
|
@@ -9,38 +9,20 @@ export const customBlockQueryDataSourceErrorInfoSchema = v.object({
|
|
|
9
9
|
isRetryable: v.boolean(),
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
|
-
* Message sent by the host to
|
|
12
|
+
* Message sent by the host to update a `queryDataSource` subscription.
|
|
13
13
|
*/
|
|
14
|
-
export const
|
|
15
|
-
type: v.literal("queryDataSourceResult"),
|
|
16
|
-
requestId: v.string(),
|
|
17
|
-
snapshotId: v.string(),
|
|
18
|
-
items: v.array(notionDataSourcePageBridgeSchema),
|
|
19
|
-
hasMore: v.boolean(),
|
|
20
|
-
error: v.optional(customBlockQueryDataSourceErrorInfoSchema),
|
|
21
|
-
});
|
|
22
|
-
export const statusQueryDataSourceResultMessageSchema = v.variant("status", [
|
|
14
|
+
export const queryDataSourceResultMessageSchema = v.variant("status", [
|
|
23
15
|
v.object({
|
|
24
16
|
type: v.literal("queryDataSourceResult"),
|
|
25
|
-
|
|
26
|
-
snapshotId: v.string(),
|
|
17
|
+
subscriptionId: v.string(),
|
|
27
18
|
status: v.literal("success"),
|
|
28
19
|
items: v.array(notionDataSourcePageBridgeSchema),
|
|
29
20
|
hasMore: v.boolean(),
|
|
30
21
|
}),
|
|
31
22
|
v.object({
|
|
32
23
|
type: v.literal("queryDataSourceResult"),
|
|
33
|
-
|
|
34
|
-
snapshotId: v.string(),
|
|
24
|
+
subscriptionId: v.string(),
|
|
35
25
|
status: v.literal("error"),
|
|
36
26
|
error: customBlockQueryDataSourceErrorInfoSchema,
|
|
37
27
|
}),
|
|
38
28
|
]);
|
|
39
|
-
/**
|
|
40
|
-
* TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
41
|
-
* Protocol version 2 hosts and sandboxes use the legacy optional-error shape.
|
|
42
|
-
*/
|
|
43
|
-
export const queryDataSourceResultMessageSchema = v.union([
|
|
44
|
-
legacyQueryDataSourceResultMessageSchema,
|
|
45
|
-
statusQueryDataSourceResultMessageSchema,
|
|
46
|
-
]);
|
|
@@ -39,8 +39,7 @@ export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.UnionSchema<[v
|
|
|
39
39
|
}, undefined>;
|
|
40
40
|
}, undefined>], undefined>, v.ObjectSchema<{
|
|
41
41
|
readonly type: v.LiteralSchema<"queryDataSource", undefined>;
|
|
42
|
-
readonly
|
|
43
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
42
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
44
43
|
readonly dataSourceId: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
45
44
|
readonly limit: v.NumberSchema<undefined>;
|
|
46
45
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAW5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAW5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAUrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/createCustomBlockHost.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAY1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAkB/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIzD,OAAO,KAAK,EACX,iCAAiC,EACjC,2BAA2B,EAE3B,mBAAmB,EACnB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA;AAE9E,MAAM,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,iBAAiB,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,EAAE,2BAA2B,CAAA;IACzC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAChD,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAC1E,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACtC,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;IACzC,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA;IACxC,cAAc,EAAE,CAAC,WAAW,EAAE,iCAAiC,KAAK,IAAI,CAAA;IACxE,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,KAAK,IAAI,CAAA;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,YAAY,EAAE,kBAAkB,CAAA;QAChC,QAAQ,EAAE,oCAAoC,CAAA;KAC9C,KAAK,IAAI,CAAA;CACV,CAAA;AAKD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/createCustomBlockHost.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAY1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAkB/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIzD,OAAO,KAAK,EACX,iCAAiC,EACjC,2BAA2B,EAE3B,mBAAmB,EACnB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA;AAE9E,MAAM,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,iBAAiB,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,EAAE,2BAA2B,CAAA;IACzC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAChD,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAC1E,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACtC,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;IACzC,OAAO,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA;IACxC,cAAc,EAAE,CAAC,WAAW,EAAE,iCAAiC,KAAK,IAAI,CAAA;IACxE,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,KAAK,IAAI,CAAA;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,YAAY,EAAE,kBAAkB,CAAA;QAChC,QAAQ,EAAE,oCAAoC,CAAA;KAC9C,KAAK,IAAI,CAAA;CACV,CAAA;AAKD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CA4UvB"}
|
|
@@ -25,16 +25,20 @@ export function createCustomBlockHost(options) {
|
|
|
25
25
|
iframe.contentWindow?.postMessage(message, targetOrigin);
|
|
26
26
|
}
|
|
27
27
|
function postQueryDataSourceResult(args) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
const message = args.response.status === "error"
|
|
29
|
+
? {
|
|
30
|
+
type: "queryDataSourceResult",
|
|
31
|
+
subscriptionId: args.subscriptionId,
|
|
32
|
+
status: "error",
|
|
33
|
+
error: args.response.error,
|
|
34
|
+
}
|
|
35
|
+
: {
|
|
36
|
+
type: "queryDataSourceResult",
|
|
37
|
+
subscriptionId: args.subscriptionId,
|
|
38
|
+
status: "success",
|
|
39
|
+
items: args.response.items,
|
|
40
|
+
hasMore: args.response.hasMore,
|
|
41
|
+
};
|
|
38
42
|
post(message);
|
|
39
43
|
}
|
|
40
44
|
function clearNoReadyTimeout() {
|
|
@@ -85,11 +89,13 @@ export function createCustomBlockHost(options) {
|
|
|
85
89
|
}, noReadyTimeoutMs);
|
|
86
90
|
}
|
|
87
91
|
async function handleQuery(message) {
|
|
88
|
-
querySubscriptions.track(message);
|
|
92
|
+
const token = querySubscriptions.track(message);
|
|
89
93
|
const response = await handlers.queryDataSource(message);
|
|
94
|
+
if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
90
97
|
postQueryDataSourceResult({
|
|
91
|
-
|
|
92
|
-
snapshotId: message.snapshotId,
|
|
98
|
+
subscriptionId: message.subscriptionId,
|
|
93
99
|
response,
|
|
94
100
|
});
|
|
95
101
|
}
|
|
@@ -243,6 +249,7 @@ export function createCustomBlockHost(options) {
|
|
|
243
249
|
window.removeEventListener("message", onMessage);
|
|
244
250
|
iframe.removeEventListener("load", onIframeLoad);
|
|
245
251
|
clearNoReadyTimeout();
|
|
252
|
+
querySubscriptions.clear();
|
|
246
253
|
},
|
|
247
254
|
post,
|
|
248
255
|
setTheme(nextTheme) {
|
|
@@ -273,19 +280,17 @@ export function createCustomBlockHost(options) {
|
|
|
273
280
|
post({ type: "currentUserChanged", currentUser });
|
|
274
281
|
},
|
|
275
282
|
refreshQuery({ dataSourceId, response }) {
|
|
276
|
-
const
|
|
283
|
+
const refreshes = querySubscriptions.resolveRefreshes({
|
|
277
284
|
dataSourceId,
|
|
278
285
|
response,
|
|
279
286
|
});
|
|
280
|
-
if (
|
|
287
|
+
if (refreshes.length === 0) {
|
|
281
288
|
emit("warn", `No active query exists for data source "${dataSourceId}"`);
|
|
282
289
|
return;
|
|
283
290
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
response: refresh.response,
|
|
288
|
-
});
|
|
291
|
+
for (const refresh of refreshes) {
|
|
292
|
+
postQueryDataSourceResult(refresh);
|
|
293
|
+
}
|
|
289
294
|
},
|
|
290
295
|
};
|
|
291
296
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { NotionDataSourceId } from "../../bridge/ids.js";
|
|
2
2
|
import type { QueryDataSourceMessage } from "../../bridge/messages/queryDataSource.js";
|
|
3
3
|
import type { CustomBlockHostQueryDataSourceResult } from "./types.js";
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
requestId: string;
|
|
7
|
-
snapshotId: string;
|
|
4
|
+
export type QueryRefresh = {
|
|
5
|
+
subscriptionId: string;
|
|
8
6
|
response: CustomBlockHostQueryDataSourceResult;
|
|
9
|
-
} | {
|
|
10
|
-
status: "missing";
|
|
11
7
|
};
|
|
8
|
+
type QuerySubscriptionToken = object;
|
|
12
9
|
export declare class QuerySubscriptions {
|
|
13
|
-
private readonly
|
|
14
|
-
track(message: QueryDataSourceMessage):
|
|
15
|
-
|
|
10
|
+
private readonly bySubscriptionId;
|
|
11
|
+
track(message: QueryDataSourceMessage): QuerySubscriptionToken;
|
|
12
|
+
isCurrent(subscriptionId: string, token: QuerySubscriptionToken): boolean;
|
|
13
|
+
resolveRefreshes(args: {
|
|
16
14
|
dataSourceId: NotionDataSourceId;
|
|
17
15
|
response: CustomBlockHostQueryDataSourceResult;
|
|
18
|
-
}):
|
|
16
|
+
}): QueryRefresh[];
|
|
17
|
+
clear(): void;
|
|
19
18
|
}
|
|
19
|
+
export {};
|
|
20
20
|
//# sourceMappingURL=querySubscriptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"querySubscriptions.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/queries/querySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AACtF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"querySubscriptions.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/queries/querySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AACtF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAA;AAEtE,MAAM,MAAM,YAAY,GAAG;IAC1B,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,oCAAoC,CAAA;CAC9C,CAAA;AAED,KAAK,sBAAsB,GAAG,MAAM,CAAA;AAQpC,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4C;IAE7E,KAAK,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB;IAU9D,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO;IAIzE,gBAAgB,CAAC,IAAI,EAAE;QACtB,YAAY,EAAE,kBAAkB,CAAA;QAChC,QAAQ,EAAE,oCAAoC,CAAA;KAC9C,GAAG,YAAY,EAAE;IAelB,KAAK;CAGL"}
|
|
@@ -1,29 +1,45 @@
|
|
|
1
1
|
export class QuerySubscriptions {
|
|
2
2
|
constructor() {
|
|
3
|
-
this.
|
|
3
|
+
this.bySubscriptionId = new Map();
|
|
4
4
|
}
|
|
5
5
|
track(message) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const token = {};
|
|
7
|
+
this.bySubscriptionId.set(message.subscriptionId, {
|
|
8
|
+
dataSourceId: message.dataSourceId,
|
|
9
9
|
limit: message.limit,
|
|
10
|
+
token,
|
|
10
11
|
});
|
|
12
|
+
return token;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
isCurrent(subscriptionId, token) {
|
|
15
|
+
return this.bySubscriptionId.get(subscriptionId)?.token === token;
|
|
16
|
+
}
|
|
17
|
+
resolveRefreshes(args) {
|
|
18
|
+
const refreshes = [];
|
|
19
|
+
for (const [subscriptionId, queryState] of this.bySubscriptionId) {
|
|
20
|
+
if (queryState.dataSourceId !== args.dataSourceId) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
queryState.token = {};
|
|
24
|
+
refreshes.push({
|
|
25
|
+
subscriptionId,
|
|
26
|
+
response: limitResponse(args.response, queryState.limit),
|
|
27
|
+
});
|
|
16
28
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
};
|
|
29
|
+
return refreshes;
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
this.bySubscriptionId.clear();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function limitResponse(response, limit) {
|
|
36
|
+
if (response.status === "error") {
|
|
37
|
+
return response;
|
|
28
38
|
}
|
|
39
|
+
const items = response.items.slice(0, limit);
|
|
40
|
+
return {
|
|
41
|
+
status: "success",
|
|
42
|
+
items,
|
|
43
|
+
hasMore: response.hasMore || response.items.length > items.length,
|
|
44
|
+
};
|
|
29
45
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { NotionDataSourcePageBridge } from "../../bridge/dataSources/dataSourcePage.js";
|
|
2
|
-
import type { QueryDataSourceMessage } from "../../bridge/messages/queryDataSource.js";
|
|
3
2
|
import type { CustomBlockQueryDataSourceErrorInfo } from "../../bridge/messages/queryDataSourceResult.js";
|
|
4
3
|
export type CustomBlockHostQueryDataSourceResult = {
|
|
4
|
+
status: "success";
|
|
5
5
|
items: NotionDataSourcePageBridge[];
|
|
6
|
-
hasMore
|
|
7
|
-
|
|
6
|
+
hasMore: boolean;
|
|
7
|
+
} | {
|
|
8
|
+
status: "error";
|
|
9
|
+
error: CustomBlockQueryDataSourceErrorInfo;
|
|
8
10
|
};
|
|
9
|
-
export type QuerySubscriptionState = Pick<QueryDataSourceMessage, "requestId" | "snapshotId" | "limit">;
|
|
10
11
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/queries/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA;AAC5F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/queries/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA;AAC5F,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAA;AAEzG,MAAM,MAAM,oCAAoC,GAC7C;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,KAAK,EAAE,0BAA0B,EAAE,CAAA;IACnC,OAAO,EAAE,OAAO,CAAA;CACf,GACD;IACA,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,mCAAmC,CAAA;CACzC,CAAA"}
|
package/dist/version.js
CHANGED