@notionhq/custom-blocks 0.0.60 → 0.0.61
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 +1 -1
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +21 -3
- package/dist/bridge/messages/hostToSandbox.d.ts +80 -0
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
- package/dist/bridge/messages/hostToSandbox.js +3 -2
- package/dist/bridge/messages/queryDataSourceResult.d.ts +241 -1
- package/dist/bridge/messages/queryDataSourceResult.d.ts.map +1 -1
- package/dist/bridge/messages/queryDataSourceResult.js +26 -1
- package/dist/host/createCustomBlockHost.d.ts.map +1 -1
- package/dist/host/createCustomBlockHost.js +2 -0
- package/dist/host/queries/types.d.ts +3 -2
- 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 +22 -3
- package/src/bridge/messages/hostToSandbox.ts +6 -2
- package/src/bridge/messages/queryDataSourceResult.ts +28 -1
- package/src/host/createCustomBlockHost.ts +2 -0
- package/src/host/queries/types.ts +3 -5
package/HOST.md
CHANGED
|
@@ -158,7 +158,7 @@ Messages sent from the host to the sandbox. Same `{ wire type, type / schema, be
|
|
|
158
158
|
| `pageChanged` | `PageChangedMessage` / `pageChangedMessageSchema` | Replaces the nearest page ancestor without disturbing theme, block ID, parent, user, or query state. |
|
|
159
159
|
| `currentUserChanged` | `CurrentUserChangedMessage` / `currentUserChangedMessageSchema` | Replaces the current viewer record. Send when any viewer field changes (name, avatar, email). |
|
|
160
160
|
| `dataSourcesChanged` | `DataSourcesChangedMessage` / `dataSourcesChangedMessageSchema` | Replaces data-source bindings; the sandbox preserves cached query state for keys that still exist and drops removed keys. |
|
|
161
|
-
| `queryDataSourceResult` | `QueryDataSourceResultMessage` / `queryDataSourceResultMessageSchema` | `requestId` / `snapshotId`-keyed response with `items`, `hasMore`,
|
|
161
|
+
| `queryDataSourceResult` | `QueryDataSourceResultMessage` / `queryDataSourceResultMessageSchema` | `requestId` / `snapshotId`-keyed response with `status: "success"`, `items`, and `hasMore`, or `status: "error"` and `error`. |
|
|
162
162
|
| `createPageResult` | `CreatePageResultMessage` / `createPageResultMessageSchema` | `requestId`-keyed page response with `status: "success"` or `status: "error"`. |
|
|
163
163
|
| `getPageResult` | `GetPageResultMessage` / `getPageResultMessageSchema` | Same success/error shape as `createPageResult`. |
|
|
164
164
|
| `updatePageResult` | `UpdatePageResultMessage` / `updatePageResultMessageSchema` | Same success/error shape as `createPageResult`. |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxBridge.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/SandboxBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EACX,gBAAgB,EAEhB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EACX,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,iCAAiC,CAAA;AAGxC,OAAO,EACN,KAAK,oBAAoB,EAGzB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAQxD,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAW3E;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"SandboxBridge.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/SandboxBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK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QAC5B,MAAM,EAAE,YAAY,CAAA;QACpB,KAAK,EAAE,+BAA+B,CAAA;KACtC,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAuB7C;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;CAkE/B"}
|
|
@@ -13,6 +13,7 @@ import { PendingRequests } from "./pendingRequests.js";
|
|
|
13
13
|
* single host needs to support multiple custom blocks built with different versions of the bridge
|
|
14
14
|
* protocol. Increment this number any time a breaking change is made to the bridge protocol.
|
|
15
15
|
*/
|
|
16
|
+
// TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
16
17
|
export const CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION = 2;
|
|
17
18
|
export class SandboxBridge {
|
|
18
19
|
constructor() {
|
|
@@ -205,15 +206,32 @@ export class SandboxBridge {
|
|
|
205
206
|
if (currentState.latestRequestId !== message.requestId) {
|
|
206
207
|
return;
|
|
207
208
|
}
|
|
209
|
+
const queryResult = "status" in message
|
|
210
|
+
? message.status === "error"
|
|
211
|
+
? {
|
|
212
|
+
items: [],
|
|
213
|
+
hasMore: false,
|
|
214
|
+
error: message.error,
|
|
215
|
+
}
|
|
216
|
+
: {
|
|
217
|
+
items: message.items,
|
|
218
|
+
hasMore: message.hasMore,
|
|
219
|
+
error: undefined,
|
|
220
|
+
}
|
|
221
|
+
: {
|
|
222
|
+
items: message.items,
|
|
223
|
+
hasMore: message.hasMore,
|
|
224
|
+
error: message.error,
|
|
225
|
+
};
|
|
208
226
|
this.hostState = {
|
|
209
227
|
...hostState,
|
|
210
228
|
dataSourceState: {
|
|
211
229
|
...hostState.dataSourceState,
|
|
212
230
|
[key]: {
|
|
213
|
-
items:
|
|
231
|
+
items: queryResult.items,
|
|
214
232
|
isLoading: false,
|
|
215
|
-
hasMore:
|
|
216
|
-
error:
|
|
233
|
+
hasMore: queryResult.hasMore,
|
|
234
|
+
error: queryResult.error,
|
|
217
235
|
// Keep the request ID so later host-pushed refreshes for the
|
|
218
236
|
// same subscription still match.
|
|
219
237
|
latestRequestId: message.requestId,
|
|
@@ -378,7 +378,87 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
378
378
|
readonly propertyIdsByKey: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
|
|
379
379
|
}, undefined>, undefined>;
|
|
380
380
|
}, undefined>;
|
|
381
|
+
}, undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
382
|
+
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
383
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
384
|
+
readonly snapshotId: v.StringSchema<undefined>;
|
|
385
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
386
|
+
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
387
|
+
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
388
|
+
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<{
|
|
389
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
390
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
391
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
392
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
393
|
+
readonly value: v.NumberSchema<undefined>;
|
|
394
|
+
readonly time: v.StringSchema<undefined>;
|
|
395
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
396
|
+
}, undefined>, v.ObjectSchema<{
|
|
397
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
398
|
+
}, undefined>], undefined>, undefined>;
|
|
399
|
+
}, undefined>, v.ObjectSchema<{
|
|
400
|
+
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
401
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
402
|
+
readonly end_date: v.StringSchema<undefined>;
|
|
403
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
404
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
405
|
+
readonly value: v.NumberSchema<undefined>;
|
|
406
|
+
readonly time: v.StringSchema<undefined>;
|
|
407
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
408
|
+
}, undefined>, v.ObjectSchema<{
|
|
409
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
410
|
+
}, undefined>], undefined>, undefined>;
|
|
411
|
+
}, undefined>, v.ObjectSchema<{
|
|
412
|
+
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
413
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
414
|
+
readonly start_time: v.StringSchema<undefined>;
|
|
415
|
+
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
416
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
417
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
418
|
+
readonly value: v.NumberSchema<undefined>;
|
|
419
|
+
readonly time: v.StringSchema<undefined>;
|
|
420
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
421
|
+
}, undefined>, v.ObjectSchema<{
|
|
422
|
+
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
423
|
+
readonly value: v.NumberSchema<undefined>;
|
|
424
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
425
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
426
|
+
}, undefined>], undefined>, undefined>;
|
|
427
|
+
}, undefined>, v.ObjectSchema<{
|
|
428
|
+
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
429
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
430
|
+
readonly start_time: v.StringSchema<undefined>;
|
|
431
|
+
readonly end_date: v.StringSchema<undefined>;
|
|
432
|
+
readonly end_time: v.StringSchema<undefined>;
|
|
433
|
+
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
434
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
435
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
436
|
+
readonly value: v.NumberSchema<undefined>;
|
|
437
|
+
readonly time: v.StringSchema<undefined>;
|
|
438
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
439
|
+
}, undefined>, v.ObjectSchema<{
|
|
440
|
+
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
441
|
+
readonly value: v.NumberSchema<undefined>;
|
|
442
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
443
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
444
|
+
}, undefined>], undefined>, undefined>;
|
|
445
|
+
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
446
|
+
readonly id: v.StringSchema<undefined>;
|
|
447
|
+
readonly table: v.StringSchema<undefined>;
|
|
448
|
+
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
449
|
+
}, undefined>, undefined>;
|
|
450
|
+
readonly hasMore: v.BooleanSchema<undefined>;
|
|
381
451
|
}, undefined>, v.ObjectSchema<{
|
|
452
|
+
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
453
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
454
|
+
readonly snapshotId: v.StringSchema<undefined>;
|
|
455
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
456
|
+
readonly error: v.ObjectSchema<{
|
|
457
|
+
readonly code: v.StringSchema<undefined>;
|
|
458
|
+
readonly message: v.StringSchema<undefined>;
|
|
459
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
460
|
+
}, undefined>;
|
|
461
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
382
462
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
383
463
|
readonly requestId: v.StringSchema<undefined>;
|
|
384
464
|
readonly snapshotId: v.StringSchema<undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostToSandbox.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/hostToSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"hostToSandbox.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/hostToSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAkB5B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAerC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
|
|
@@ -9,7 +9,7 @@ import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js";
|
|
|
9
9
|
import { listUsersResultMessageSchema } from "./listUsers.js";
|
|
10
10
|
import { pageChangedMessageSchema } from "./pageChanged.js";
|
|
11
11
|
import { parentChangedMessageSchema } from "./parentChanged.js";
|
|
12
|
-
import {
|
|
12
|
+
import { legacyQueryDataSourceResultMessageSchema, statusQueryDataSourceResultMessageSchema, } from "./queryDataSourceResult.js";
|
|
13
13
|
import { themeChangedMessageSchema } from "./themeChanged.js";
|
|
14
14
|
import { updatePageResultMessageSchema } from "./updatePageResult.js";
|
|
15
15
|
/**
|
|
@@ -22,7 +22,8 @@ export const hostToSandboxMessageSchema = v.variant("type", [
|
|
|
22
22
|
pageChangedMessageSchema,
|
|
23
23
|
currentUserChangedMessageSchema,
|
|
24
24
|
dataSourcesChangedMessageSchema,
|
|
25
|
-
|
|
25
|
+
statusQueryDataSourceResultMessageSchema,
|
|
26
|
+
legacyQueryDataSourceResultMessageSchema,
|
|
26
27
|
createPageResultMessageSchema,
|
|
27
28
|
getPageResultMessageSchema,
|
|
28
29
|
getUserResultMessageSchema,
|
|
@@ -11,7 +11,7 @@ export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
|
|
|
11
11
|
/**
|
|
12
12
|
* Message sent by the host to the sandbox in response to a `queryDataSource` request.
|
|
13
13
|
*/
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const legacyQueryDataSourceResultMessageSchema: v.ObjectSchema<{
|
|
15
15
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
16
16
|
readonly requestId: v.StringSchema<undefined>;
|
|
17
17
|
readonly snapshotId: v.StringSchema<undefined>;
|
|
@@ -86,5 +86,245 @@ export declare const queryDataSourceResultMessageSchema: v.ObjectSchema<{
|
|
|
86
86
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
87
87
|
}, undefined>, undefined>;
|
|
88
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>;
|
|
93
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
94
|
+
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
95
|
+
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
96
|
+
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<{
|
|
97
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
98
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
99
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
100
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
101
|
+
readonly value: v.NumberSchema<undefined>;
|
|
102
|
+
readonly time: v.StringSchema<undefined>;
|
|
103
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
104
|
+
}, undefined>, v.ObjectSchema<{
|
|
105
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
106
|
+
}, undefined>], undefined>, undefined>;
|
|
107
|
+
}, undefined>, v.ObjectSchema<{
|
|
108
|
+
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
109
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
110
|
+
readonly end_date: v.StringSchema<undefined>;
|
|
111
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
112
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
113
|
+
readonly value: v.NumberSchema<undefined>;
|
|
114
|
+
readonly time: v.StringSchema<undefined>;
|
|
115
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
116
|
+
}, undefined>, v.ObjectSchema<{
|
|
117
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
118
|
+
}, undefined>], undefined>, undefined>;
|
|
119
|
+
}, undefined>, v.ObjectSchema<{
|
|
120
|
+
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
121
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
122
|
+
readonly start_time: v.StringSchema<undefined>;
|
|
123
|
+
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
124
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
125
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
126
|
+
readonly value: v.NumberSchema<undefined>;
|
|
127
|
+
readonly time: v.StringSchema<undefined>;
|
|
128
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
129
|
+
}, undefined>, v.ObjectSchema<{
|
|
130
|
+
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
131
|
+
readonly value: v.NumberSchema<undefined>;
|
|
132
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
133
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
134
|
+
}, undefined>], undefined>, undefined>;
|
|
135
|
+
}, undefined>, v.ObjectSchema<{
|
|
136
|
+
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
137
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
138
|
+
readonly start_time: v.StringSchema<undefined>;
|
|
139
|
+
readonly end_date: v.StringSchema<undefined>;
|
|
140
|
+
readonly end_time: v.StringSchema<undefined>;
|
|
141
|
+
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
142
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
143
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
144
|
+
readonly value: v.NumberSchema<undefined>;
|
|
145
|
+
readonly time: v.StringSchema<undefined>;
|
|
146
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
147
|
+
}, undefined>, v.ObjectSchema<{
|
|
148
|
+
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
149
|
+
readonly value: v.NumberSchema<undefined>;
|
|
150
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
151
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
152
|
+
}, undefined>], undefined>, undefined>;
|
|
153
|
+
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
154
|
+
readonly id: v.StringSchema<undefined>;
|
|
155
|
+
readonly table: v.StringSchema<undefined>;
|
|
156
|
+
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
157
|
+
}, undefined>, undefined>;
|
|
158
|
+
readonly hasMore: v.BooleanSchema<undefined>;
|
|
159
|
+
}, undefined>, v.ObjectSchema<{
|
|
160
|
+
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
161
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
162
|
+
readonly snapshotId: v.StringSchema<undefined>;
|
|
163
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
164
|
+
readonly error: v.ObjectSchema<{
|
|
165
|
+
readonly code: v.StringSchema<undefined>;
|
|
166
|
+
readonly message: v.StringSchema<undefined>;
|
|
167
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
168
|
+
}, undefined>;
|
|
169
|
+
}, 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>;
|
|
89
329
|
export type QueryDataSourceResultMessage = v.InferOutput<typeof queryDataSourceResultMessageSchema>;
|
|
90
330
|
//# 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,MAAM,cAAc,CAAA;AAIxD,eAAO,MAAM,yCAAyC,2BAAa,CAAA;AAEnE,MAAM,MAAM,mCAAmC,GAC5C,0BAA0B,GAC1B,yBAAyB,GACzB,sBAAsB,GACtB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,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,MAAM,cAAc,CAAA;AAIxD,eAAO,MAAM,yCAAyC,2BAAa,CAAA;AAEnE,MAAM,MAAM,mCAAmC,GAC5C,0BAA0B,GAC1B,yBAAyB,GACzB,sBAAsB,GACtB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,mCAAmC,GAC9C,oBAAoB,CAAC,mCAAmC,CAAC,CAAA;AAE1D,eAAO,MAAM,yCAAyC;;;;aAIpD,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAOnD,CAAA;AAEF,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAgBnD,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAG7C,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CACvD,OAAO,kCAAkC,CACzC,CAAA"}
|
|
@@ -11,7 +11,7 @@ export const customBlockQueryDataSourceErrorInfoSchema = v.object({
|
|
|
11
11
|
/**
|
|
12
12
|
* Message sent by the host to the sandbox in response to a `queryDataSource` request.
|
|
13
13
|
*/
|
|
14
|
-
export const
|
|
14
|
+
export const legacyQueryDataSourceResultMessageSchema = v.object({
|
|
15
15
|
type: v.literal("queryDataSourceResult"),
|
|
16
16
|
requestId: v.string(),
|
|
17
17
|
snapshotId: v.string(),
|
|
@@ -19,3 +19,28 @@ export const queryDataSourceResultMessageSchema = v.object({
|
|
|
19
19
|
hasMore: v.boolean(),
|
|
20
20
|
error: v.optional(customBlockQueryDataSourceErrorInfoSchema),
|
|
21
21
|
});
|
|
22
|
+
export const statusQueryDataSourceResultMessageSchema = v.variant("status", [
|
|
23
|
+
v.object({
|
|
24
|
+
type: v.literal("queryDataSourceResult"),
|
|
25
|
+
requestId: v.string(),
|
|
26
|
+
snapshotId: v.string(),
|
|
27
|
+
status: v.literal("success"),
|
|
28
|
+
items: v.array(notionDataSourcePageBridgeSchema),
|
|
29
|
+
hasMore: v.boolean(),
|
|
30
|
+
}),
|
|
31
|
+
v.object({
|
|
32
|
+
type: v.literal("queryDataSourceResult"),
|
|
33
|
+
requestId: v.string(),
|
|
34
|
+
snapshotId: v.string(),
|
|
35
|
+
status: v.literal("error"),
|
|
36
|
+
error: customBlockQueryDataSourceErrorInfoSchema,
|
|
37
|
+
}),
|
|
38
|
+
]);
|
|
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
|
+
]);
|
|
@@ -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,CAA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AAK,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,CAuTvB"}
|
|
@@ -25,6 +25,8 @@ export function createCustomBlockHost(options) {
|
|
|
25
25
|
iframe.contentWindow?.postMessage(message, targetOrigin);
|
|
26
26
|
}
|
|
27
27
|
function postQueryDataSourceResult(args) {
|
|
28
|
+
// TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
29
|
+
// Protocol v2 sandboxes require the legacy optional-error result shape.
|
|
28
30
|
const message = {
|
|
29
31
|
type: "queryDataSourceResult",
|
|
30
32
|
requestId: args.requestId,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { NotionDataSourcePageBridge } from "../../bridge/dataSources/dataSourcePage.js";
|
|
1
2
|
import type { QueryDataSourceMessage } from "../../bridge/messages/queryDataSource.js";
|
|
2
|
-
import type { CustomBlockQueryDataSourceErrorInfo
|
|
3
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "../../bridge/messages/queryDataSourceResult.js";
|
|
3
4
|
export type CustomBlockHostQueryDataSourceResult = {
|
|
4
|
-
items:
|
|
5
|
+
items: NotionDataSourcePageBridge[];
|
|
5
6
|
hasMore?: boolean;
|
|
6
7
|
error?: CustomBlockQueryDataSourceErrorInfo;
|
|
7
8
|
};
|
|
@@ -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,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AACtF,OAAO,KAAK,
|
|
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,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AACtF,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAA;AAEzG,MAAM,MAAM,oCAAoC,GAAG;IAClD,KAAK,EAAE,0BAA0B,EAAE,CAAA;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,mCAAmC,CAAA;CAC3C,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,sBAAsB,EACtB,WAAW,GAAG,YAAY,GAAG,OAAO,CACpC,CAAA"}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -55,6 +55,7 @@ import type { NotionUser } from "./users/user.js"
|
|
|
55
55
|
* single host needs to support multiple custom blocks built with different versions of the bridge
|
|
56
56
|
* protocol. Increment this number any time a breaking change is made to the bridge protocol.
|
|
57
57
|
*/
|
|
58
|
+
// TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
58
59
|
export const CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION = 2
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -408,15 +409,33 @@ export class SandboxBridge {
|
|
|
408
409
|
if (currentState.latestRequestId !== message.requestId) {
|
|
409
410
|
return
|
|
410
411
|
}
|
|
412
|
+
const queryResult =
|
|
413
|
+
"status" in message
|
|
414
|
+
? message.status === "error"
|
|
415
|
+
? {
|
|
416
|
+
items: [],
|
|
417
|
+
hasMore: false,
|
|
418
|
+
error: message.error,
|
|
419
|
+
}
|
|
420
|
+
: {
|
|
421
|
+
items: message.items,
|
|
422
|
+
hasMore: message.hasMore,
|
|
423
|
+
error: undefined,
|
|
424
|
+
}
|
|
425
|
+
: {
|
|
426
|
+
items: message.items,
|
|
427
|
+
hasMore: message.hasMore,
|
|
428
|
+
error: message.error,
|
|
429
|
+
}
|
|
411
430
|
this.hostState = {
|
|
412
431
|
...hostState,
|
|
413
432
|
dataSourceState: {
|
|
414
433
|
...hostState.dataSourceState,
|
|
415
434
|
[key]: {
|
|
416
|
-
items:
|
|
435
|
+
items: queryResult.items,
|
|
417
436
|
isLoading: false,
|
|
418
|
-
hasMore:
|
|
419
|
-
error:
|
|
437
|
+
hasMore: queryResult.hasMore,
|
|
438
|
+
error: queryResult.error,
|
|
420
439
|
// Keep the request ID so later host-pushed refreshes for the
|
|
421
440
|
// same subscription still match.
|
|
422
441
|
latestRequestId: message.requestId,
|
|
@@ -9,7 +9,10 @@ import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js"
|
|
|
9
9
|
import { listUsersResultMessageSchema } from "./listUsers.js"
|
|
10
10
|
import { pageChangedMessageSchema } from "./pageChanged.js"
|
|
11
11
|
import { parentChangedMessageSchema } from "./parentChanged.js"
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
legacyQueryDataSourceResultMessageSchema,
|
|
14
|
+
statusQueryDataSourceResultMessageSchema,
|
|
15
|
+
} from "./queryDataSourceResult.js"
|
|
13
16
|
import { themeChangedMessageSchema } from "./themeChanged.js"
|
|
14
17
|
import { updatePageResultMessageSchema } from "./updatePageResult.js"
|
|
15
18
|
|
|
@@ -23,7 +26,8 @@ export const hostToSandboxMessageSchema = v.variant("type", [
|
|
|
23
26
|
pageChangedMessageSchema,
|
|
24
27
|
currentUserChangedMessageSchema,
|
|
25
28
|
dataSourcesChangedMessageSchema,
|
|
26
|
-
|
|
29
|
+
statusQueryDataSourceResultMessageSchema,
|
|
30
|
+
legacyQueryDataSourceResultMessageSchema,
|
|
27
31
|
createPageResultMessageSchema,
|
|
28
32
|
getPageResultMessageSchema,
|
|
29
33
|
getUserResultMessageSchema,
|
|
@@ -24,7 +24,7 @@ export const customBlockQueryDataSourceErrorInfoSchema = v.object({
|
|
|
24
24
|
/**
|
|
25
25
|
* Message sent by the host to the sandbox in response to a `queryDataSource` request.
|
|
26
26
|
*/
|
|
27
|
-
export const
|
|
27
|
+
export const legacyQueryDataSourceResultMessageSchema = v.object({
|
|
28
28
|
type: v.literal("queryDataSourceResult"),
|
|
29
29
|
requestId: v.string(),
|
|
30
30
|
snapshotId: v.string(),
|
|
@@ -33,6 +33,33 @@ export const queryDataSourceResultMessageSchema = v.object({
|
|
|
33
33
|
error: v.optional(customBlockQueryDataSourceErrorInfoSchema),
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
+
export const statusQueryDataSourceResultMessageSchema = v.variant("status", [
|
|
37
|
+
v.object({
|
|
38
|
+
type: v.literal("queryDataSourceResult"),
|
|
39
|
+
requestId: v.string(),
|
|
40
|
+
snapshotId: v.string(),
|
|
41
|
+
status: v.literal("success"),
|
|
42
|
+
items: v.array(notionDataSourcePageBridgeSchema),
|
|
43
|
+
hasMore: v.boolean(),
|
|
44
|
+
}),
|
|
45
|
+
v.object({
|
|
46
|
+
type: v.literal("queryDataSourceResult"),
|
|
47
|
+
requestId: v.string(),
|
|
48
|
+
snapshotId: v.string(),
|
|
49
|
+
status: v.literal("error"),
|
|
50
|
+
error: customBlockQueryDataSourceErrorInfoSchema,
|
|
51
|
+
}),
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
56
|
+
* Protocol version 2 hosts and sandboxes use the legacy optional-error shape.
|
|
57
|
+
*/
|
|
58
|
+
export const queryDataSourceResultMessageSchema = v.union([
|
|
59
|
+
legacyQueryDataSourceResultMessageSchema,
|
|
60
|
+
statusQueryDataSourceResultMessageSchema,
|
|
61
|
+
])
|
|
62
|
+
|
|
36
63
|
export type QueryDataSourceResultMessage = v.InferOutput<
|
|
37
64
|
typeof queryDataSourceResultMessageSchema
|
|
38
65
|
>
|
|
@@ -115,6 +115,8 @@ export function createCustomBlockHost(
|
|
|
115
115
|
snapshotId: string
|
|
116
116
|
response: CustomBlockHostQueryDataSourceResult
|
|
117
117
|
}) {
|
|
118
|
+
// TODO(custom-blocks): Update when bumping bridge protocol version to 3.
|
|
119
|
+
// Protocol v2 sandboxes require the legacy optional-error result shape.
|
|
118
120
|
const message: QueryDataSourceResultMessage = {
|
|
119
121
|
type: "queryDataSourceResult",
|
|
120
122
|
requestId: args.requestId,
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import type { NotionDataSourcePageBridge } from "../../bridge/dataSources/dataSourcePage.js"
|
|
1
2
|
import type { QueryDataSourceMessage } from "../../bridge/messages/queryDataSource.js"
|
|
2
|
-
import type {
|
|
3
|
-
CustomBlockQueryDataSourceErrorInfo,
|
|
4
|
-
QueryDataSourceResultMessage,
|
|
5
|
-
} from "../../bridge/messages/queryDataSourceResult.js"
|
|
3
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "../../bridge/messages/queryDataSourceResult.js"
|
|
6
4
|
|
|
7
5
|
export type CustomBlockHostQueryDataSourceResult = {
|
|
8
|
-
items:
|
|
6
|
+
items: NotionDataSourcePageBridge[]
|
|
9
7
|
hasMore?: boolean
|
|
10
8
|
error?: CustomBlockQueryDataSourceErrorInfo
|
|
11
9
|
}
|