@notionhq/custom-blocks-host 0.2.3 → 0.2.5

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/README.md CHANGED
@@ -179,9 +179,9 @@ For SDKs using protocol 3 or 4, the runtime adds synthetic metadata schemas to o
179
179
  the actual database schema supplied by the host. Protocol 5 SDKs receive that schema directly and
180
180
  add the metadata read schemas themselves.
181
181
 
182
- The runtime validates option names, supported sort types, and the limit of ten unique sort
183
- properties before it invokes the handler. Sorts retain their array order. Extra fields and mixed
184
- filter types fail protocol validation.
182
+ The runtime validates option names, Status group names, supported sort types, and ten unique sort
183
+ properties before it invokes the handler. It checks group names against the current bound schema.
184
+ Sorts retain their array order. Extra fields and mixed filter types fail protocol validation.
185
185
 
186
186
  Derive bindings from the successful `connect` message inside `getInitialState` and return them in
187
187
  `initialState.dataSources`.
@@ -246,7 +246,10 @@ The returned handle exposes:
246
246
 
247
247
  State updates are sent after `initResult.success`. Updates made earlier are held until
248
248
  initialization completes. `refreshQuery()` re-runs `queryDataSource` for every active subscription
249
- with the supplied data source ID, preserving each subscription's filter, sorts, and limit.
249
+ with the supplied data source ID, preserving each subscription's filter, sorts, and limit. If that
250
+ query is already running, refresh requests coalesce into one follow-up query. The running query
251
+ delivers its snapshot before the follow-up starts, so continuous changes do not starve updates.
252
+ Unsubscribing, replacing the query, or stopping the host discards its queued refresh.
250
253
 
251
254
  After `stop()`, the host drops outbound messages, including pending request responses. The runtime
252
255
  removes a subscription when it receives `unsubscribeDataSourceQuery`. Repeated unsubscribe messages
@@ -1 +1 @@
1
- {"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAI5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8C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AC,KACrD,IAAI,CAAA;IACT,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,KAAK,IAAI,CAAA;IAClE,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,KAAK,IAAI,CAAA;IACjE,cAAc,EAAE,CAAC,WAAW,EAAE,iCAAiC,KAAK,IAAI,CAAA;IACxE,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC1E,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,YAAY,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;KACzD,KAAK,IAAI,CAAA;CACV,CAAA;AAQD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CAuYvB"}
@@ -109,25 +109,33 @@ export function createCustomBlockHost(options) {
109
109
  sendInitializedMessage(message);
110
110
  }
111
111
  async function handleQuery(message, token = querySubscriptions.subscribe(message)) {
112
- const collectionSchema = getCollectionSchema(activeDataSources, message.dataSourceId);
113
- const queryError = getQueryValidationError(message, collectionSchema);
114
- if (queryError !== undefined) {
115
- if (querySubscriptions.isCurrent(message.subscriptionId, token)) {
116
- postQueryDataSourceResult({
117
- subscriptionId: message.subscriptionId,
118
- response: { status: "error", error: queryError },
119
- });
112
+ try {
113
+ const collectionSchema = getCollectionSchema(activeDataSources, message.dataSourceId);
114
+ const queryError = getQueryValidationError(message, collectionSchema);
115
+ if (queryError !== undefined) {
116
+ if (querySubscriptions.isCurrent(message.subscriptionId, token)) {
117
+ postQueryDataSourceResult({
118
+ subscriptionId: message.subscriptionId,
119
+ response: { status: "error", error: queryError },
120
+ });
121
+ }
122
+ return;
120
123
  }
121
- return;
124
+ const response = await handlers.queryDataSource(message);
125
+ if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
126
+ return;
127
+ }
128
+ postQueryDataSourceResult({
129
+ subscriptionId: message.subscriptionId,
130
+ response,
131
+ });
122
132
  }
123
- const response = await handlers.queryDataSource(message);
124
- if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
125
- return;
133
+ finally {
134
+ const refresh = querySubscriptions.finish(message.subscriptionId, token);
135
+ if (refresh !== undefined) {
136
+ void handleQuery(refresh.message, refresh.token);
137
+ }
126
138
  }
127
- postQueryDataSourceResult({
128
- subscriptionId: message.subscriptionId,
129
- response,
130
- });
131
139
  }
132
140
  function updateHostState(update) {
133
141
  if (initializationController.status === "stopped" ||
@@ -313,7 +321,7 @@ export function createCustomBlockHost(options) {
313
321
  }
314
322
  const normalizedDataSourceId = v.parse(notionDataSourceIdSchema, dataSourceId);
315
323
  const refreshes = querySubscriptions.refresh(normalizedDataSourceId);
316
- if (refreshes.length === 0) {
324
+ if (refreshes === undefined) {
317
325
  emit("warn", `No active query exists for data source "${dataSourceId}"`);
318
326
  return;
319
327
  }
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export type { GetPageMessage } from "./protocol/messages/getPage.js";
4
4
  export type { GetUserMessage } from "./protocol/messages/getUser.js";
5
5
  export type { ListUsersMessage } from "./protocol/messages/listUsers.js";
6
6
  export type { OpenPageMessage } from "./protocol/messages/openPage.js";
7
- export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
7
+ export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockStatusFilterOperator, CustomBlockStatusGroupFilterOperator, CustomBlockStatusGroupName, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
8
8
  export type { ResizeMessage } from "./protocol/messages/resize.js";
9
9
  export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
10
10
  export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,k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0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
@@ -88,6 +88,28 @@ export declare const customBlockOptionFilterOperatorSchema: v.UnionSchema<[v.Str
88
88
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
89
89
  }, undefined>], undefined>], undefined>;
90
90
  export type CustomBlockOptionFilterOperator = v.InferOutput<typeof customBlockOptionFilterOperatorSchema>;
91
+ export declare const customBlockStatusGroupNameSchema: v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>;
92
+ export type CustomBlockStatusGroupName = v.InferOutput<typeof customBlockStatusGroupNameSchema>;
93
+ export declare const customBlockStatusGroupFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
94
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
95
+ }, undefined>, v.StrictObjectSchema<{
96
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
97
+ }, undefined>], undefined>;
98
+ export type CustomBlockStatusGroupFilterOperator = v.InferOutput<typeof customBlockStatusGroupFilterOperatorSchema>;
99
+ export declare const customBlockStatusFilterOperatorSchema: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
100
+ readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
101
+ }, undefined>, v.StrictObjectSchema<{
102
+ readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
103
+ }, undefined>, v.UnionSchema<[v.StrictObjectSchema<{
104
+ readonly is_empty: v.LiteralSchema<true, undefined>;
105
+ }, undefined>, v.StrictObjectSchema<{
106
+ readonly is_not_empty: v.LiteralSchema<true, undefined>;
107
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
108
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
109
+ }, undefined>, v.StrictObjectSchema<{
110
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
111
+ }, undefined>], undefined>], undefined>;
112
+ export type CustomBlockStatusFilterOperator = v.InferOutput<typeof customBlockStatusFilterOperatorSchema>;
91
113
  export declare const customBlockContainsFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
92
114
  readonly contains: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
93
115
  }, undefined>, v.StrictObjectSchema<{
@@ -280,7 +302,7 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
280
302
  }, undefined>], undefined>], undefined>;
281
303
  }, undefined>, v.StrictObjectSchema<{
282
304
  readonly propertyId: v.StringSchema<undefined>;
283
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
305
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
284
306
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
285
307
  }, undefined>, v.StrictObjectSchema<{
286
308
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -288,6 +310,10 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
288
310
  readonly is_empty: v.LiteralSchema<true, undefined>;
289
311
  }, undefined>, v.StrictObjectSchema<{
290
312
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
313
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
314
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
315
+ }, undefined>, v.StrictObjectSchema<{
316
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
291
317
  }, undefined>], undefined>], undefined>;
292
318
  }, undefined>, v.StrictObjectSchema<{
293
319
  readonly propertyId: v.StringSchema<undefined>;
@@ -489,7 +515,7 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
489
515
  }, undefined>], undefined>], undefined>;
490
516
  }, undefined>, v.StrictObjectSchema<{
491
517
  readonly propertyId: v.StringSchema<undefined>;
492
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
518
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
493
519
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
494
520
  }, undefined>, v.StrictObjectSchema<{
495
521
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -497,6 +523,10 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
497
523
  readonly is_empty: v.LiteralSchema<true, undefined>;
498
524
  }, undefined>, v.StrictObjectSchema<{
499
525
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
526
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
527
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
528
+ }, undefined>, v.StrictObjectSchema<{
529
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
500
530
  }, undefined>], undefined>], undefined>;
501
531
  }, undefined>, v.StrictObjectSchema<{
502
532
  readonly propertyId: v.StringSchema<undefined>;
@@ -697,7 +727,7 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
697
727
  }, undefined>], undefined>], undefined>;
698
728
  }, undefined>, v.StrictObjectSchema<{
699
729
  readonly propertyId: v.StringSchema<undefined>;
700
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
730
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
701
731
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
702
732
  }, undefined>, v.StrictObjectSchema<{
703
733
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -705,6 +735,10 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
705
735
  readonly is_empty: v.LiteralSchema<true, undefined>;
706
736
  }, undefined>, v.StrictObjectSchema<{
707
737
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
738
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
739
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
740
+ }, undefined>, v.StrictObjectSchema<{
741
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
708
742
  }, undefined>], undefined>], undefined>;
709
743
  }, undefined>, v.StrictObjectSchema<{
710
744
  readonly propertyId: v.StringSchema<undefined>;
@@ -930,7 +964,7 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
930
964
  }, undefined>], undefined>], undefined>;
931
965
  }, undefined>, v.StrictObjectSchema<{
932
966
  readonly propertyId: v.StringSchema<undefined>;
933
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
967
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
934
968
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
935
969
  }, undefined>, v.StrictObjectSchema<{
936
970
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -938,6 +972,10 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
938
972
  readonly is_empty: v.LiteralSchema<true, undefined>;
939
973
  }, undefined>, v.StrictObjectSchema<{
940
974
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
975
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
976
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
977
+ }, undefined>, v.StrictObjectSchema<{
978
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
941
979
  }, undefined>], undefined>], undefined>;
942
980
  }, undefined>, v.StrictObjectSchema<{
943
981
  readonly propertyId: v.StringSchema<undefined>;
@@ -1138,7 +1176,7 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
1138
1176
  }, undefined>], undefined>], undefined>;
1139
1177
  }, undefined>, v.StrictObjectSchema<{
1140
1178
  readonly propertyId: v.StringSchema<undefined>;
1141
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
1179
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
1142
1180
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
1143
1181
  }, undefined>, v.StrictObjectSchema<{
1144
1182
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -1146,6 +1184,10 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
1146
1184
  readonly is_empty: v.LiteralSchema<true, undefined>;
1147
1185
  }, undefined>, v.StrictObjectSchema<{
1148
1186
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
1187
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
1188
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
1189
+ }, undefined>, v.StrictObjectSchema<{
1190
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
1149
1191
  }, undefined>], undefined>], undefined>;
1150
1192
  }, undefined>, v.StrictObjectSchema<{
1151
1193
  readonly propertyId: v.StringSchema<undefined>;
@@ -55,6 +55,27 @@ export const customBlockOptionFilterOperatorSchema = v.union([
55
55
  v.strictObject({ does_not_equal: stringOrStringArraySchema }),
56
56
  emptyOperatorSchema,
57
57
  ]);
58
+ export const customBlockStatusGroupNameSchema = v.picklist([
59
+ "To-do",
60
+ "In progress",
61
+ "Complete",
62
+ "Current",
63
+ "Future",
64
+ ]);
65
+ const customBlockStatusGroupFilterValueSchema = v.union([
66
+ customBlockStatusGroupNameSchema,
67
+ v.pipe(v.array(customBlockStatusGroupNameSchema), v.minLength(1), v.maxLength(5)),
68
+ ]);
69
+ export const customBlockStatusGroupFilterOperatorSchema = v.union([
70
+ v.strictObject({ group_equals: customBlockStatusGroupFilterValueSchema }),
71
+ v.strictObject({
72
+ group_does_not_equal: customBlockStatusGroupFilterValueSchema,
73
+ }),
74
+ ]);
75
+ export const customBlockStatusFilterOperatorSchema = v.union([
76
+ customBlockOptionFilterOperatorSchema,
77
+ customBlockStatusGroupFilterOperatorSchema,
78
+ ]);
58
79
  export const customBlockContainsFilterOperatorSchema = v.union([
59
80
  v.strictObject({ contains: stringOrStringArraySchema }),
60
81
  v.strictObject({ contains_all: stringOrStringArraySchema }),
@@ -112,7 +133,7 @@ export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
112
133
  }),
113
134
  v.strictObject({
114
135
  propertyId: v.string(),
115
- status: customBlockOptionFilterOperatorSchema,
136
+ status: customBlockStatusFilterOperatorSchema,
116
137
  }),
117
138
  v.strictObject({
118
139
  propertyId: v.string(),
@@ -222,7 +222,7 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
222
222
  }, undefined>], undefined>], undefined>;
223
223
  }, undefined>, v.StrictObjectSchema<{
224
224
  readonly propertyId: v.StringSchema<undefined>;
225
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
225
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
226
226
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
227
227
  }, undefined>, v.StrictObjectSchema<{
228
228
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -230,6 +230,10 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
230
230
  readonly is_empty: v.LiteralSchema<true, undefined>;
231
231
  }, undefined>, v.StrictObjectSchema<{
232
232
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
233
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
234
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
235
+ }, undefined>, v.StrictObjectSchema<{
236
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
233
237
  }, undefined>], undefined>], undefined>;
234
238
  }, undefined>, v.StrictObjectSchema<{
235
239
  readonly propertyId: v.StringSchema<undefined>;
@@ -430,7 +434,7 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
430
434
  }, undefined>], undefined>], undefined>;
431
435
  }, undefined>, v.StrictObjectSchema<{
432
436
  readonly propertyId: v.StringSchema<undefined>;
433
- readonly status: v.UnionSchema<[v.StrictObjectSchema<{
437
+ readonly status: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
434
438
  readonly equals: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
435
439
  }, undefined>, v.StrictObjectSchema<{
436
440
  readonly does_not_equal: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
@@ -438,6 +442,10 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
438
442
  readonly is_empty: v.LiteralSchema<true, undefined>;
439
443
  }, undefined>, v.StrictObjectSchema<{
440
444
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
445
+ }, undefined>], undefined>], undefined>, v.UnionSchema<[v.StrictObjectSchema<{
446
+ readonly group_equals: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
447
+ }, undefined>, v.StrictObjectSchema<{
448
+ readonly group_does_not_equal: v.UnionSchema<[v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<["To-do", "In progress", "Complete", "Current", "Future"], undefined>, undefined>, v.MinLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 1, undefined>, v.MaxLengthAction<("Complete" | "Current" | "Future" | "In progress" | "To-do")[], 5, undefined>]>], undefined>;
441
449
  }, undefined>], undefined>], undefined>;
442
450
  }, undefined>, v.StrictObjectSchema<{
443
451
  readonly propertyId: v.StringSchema<undefined>;
@@ -12,7 +12,8 @@ export declare class QuerySubscriptions {
12
12
  subscribe(message: QueryDataSourceMessage): QuerySubscriptionToken;
13
13
  isCurrent(subscriptionId: string, token: QuerySubscriptionToken): boolean;
14
14
  unsubscribe(subscriptionId: string): void;
15
- refresh(dataSourceId: NotionDataSourceId): QueryRefresh[];
15
+ refresh(dataSourceId: NotionDataSourceId): QueryRefresh[] | undefined;
16
+ finish(subscriptionId: string, token: QuerySubscriptionToken): QueryRefresh | undefined;
16
17
  unsubscribeAll(): void;
17
18
  }
18
19
  //# sourceMappingURL=querySubscriptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"querySubscriptions.d.ts","sourceRoot":"","sources":["../../src/queries/querySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAE1G,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,sBAAsB,CAAA;IAC/B,KAAK,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAA;CACvC,CAAA;AAOD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4C;IAE7E,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB,CASjE;IAED,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAExE;IAED,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAExC;IAED,OAAO,CAAC,YAAY,EAAE,kBAAkB,GAAG,YAAY,EAAE,CAgBxD;IAED,cAAc,SAEb;CACD"}
1
+ {"version":3,"file":"querySubscriptions.d.ts","sourceRoot":"","sources":["../../src/queries/querySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAE1G,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,sBAAsB,CAAA;IAC/B,KAAK,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAA;CACvC,CAAA;AASD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4C;IAE7E,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB,CAWjE;IAED,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAExE;IAED,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAExC;IAED,OAAO,CAAC,YAAY,EAAE,kBAAkB,GAAG,YAAY,EAAE,GAAG,SAAS,CAmBpE;IAED,MAAM,CACL,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,sBAAsB,GAC3B,YAAY,GAAG,SAAS,CAY1B;IAED,cAAc,SAEb;CACD"}
@@ -7,6 +7,8 @@ export class QuerySubscriptions {
7
7
  this.bySubscriptionId.set(message.subscriptionId, {
8
8
  message,
9
9
  token,
10
+ isRefreshing: true,
11
+ shouldRefreshAgain: false,
10
12
  });
11
13
  return token;
12
14
  }
@@ -18,20 +20,36 @@ export class QuerySubscriptions {
18
20
  }
19
21
  refresh(dataSourceId) {
20
22
  const refreshes = [];
23
+ let hasSubscriptions = false;
21
24
  for (const queryState of this.bySubscriptionId.values()) {
22
25
  if (queryState.message.dataSourceId !== dataSourceId) {
23
26
  continue;
24
27
  }
25
- const token = {
26
- _tag: "QuerySubscriptionToken",
27
- };
28
- queryState.token = token;
28
+ hasSubscriptions = true;
29
+ if (queryState.isRefreshing) {
30
+ queryState.shouldRefreshAgain = true;
31
+ continue;
32
+ }
33
+ queryState.isRefreshing = true;
29
34
  refreshes.push({
30
35
  message: queryState.message,
31
- token,
36
+ token: queryState.token,
32
37
  });
33
38
  }
34
- return refreshes;
39
+ return hasSubscriptions ? refreshes : undefined;
40
+ }
41
+ finish(subscriptionId, token) {
42
+ const state = this.bySubscriptionId.get(subscriptionId);
43
+ if (state?.token !== token) {
44
+ return undefined;
45
+ }
46
+ state.isRefreshing = false;
47
+ if (!state.shouldRefreshAgain) {
48
+ return undefined;
49
+ }
50
+ state.shouldRefreshAgain = false;
51
+ state.isRefreshing = true;
52
+ return { message: state.message, token: state.token };
35
53
  }
36
54
  unsubscribeAll() {
37
55
  this.bySubscriptionId.clear();
@@ -29,6 +29,23 @@ function validatePropertyFilter(filter, collectionSchema) {
29
29
  isRetryable: false,
30
30
  };
31
31
  }
32
+ if ("status" in filter && propertySchema.type === "status") {
33
+ const operator = filter.status;
34
+ if ("group_equals" in operator || "group_does_not_equal" in operator) {
35
+ const value = "group_equals" in operator
36
+ ? operator.group_equals
37
+ : operator.group_does_not_equal;
38
+ const names = Array.isArray(value) ? value : [value];
39
+ const unknownName = names.find(name => !propertySchema.groups.some(group => group.name === name));
40
+ return unknownName === undefined
41
+ ? undefined
42
+ : {
43
+ code: "invalid_data_source_query_filter",
44
+ message: `Unknown status group "${unknownName}".`,
45
+ isRetryable: false,
46
+ };
47
+ }
48
+ }
32
49
  const optionFilter = getOptionFilter(filter);
33
50
  if (optionFilter === undefined ||
34
51
  propertySchema.type !== optionFilter.propertyType) {
@@ -53,7 +70,10 @@ function getOptionFilter(filter) {
53
70
  return { propertyType: "multi_select", operator: filter.multi_select };
54
71
  }
55
72
  if ("status" in filter) {
56
- return { propertyType: "status", operator: filter.status };
73
+ const operator = filter.status;
74
+ return "group_equals" in operator || "group_does_not_equal" in operator
75
+ ? undefined
76
+ : { propertyType: "status", operator };
57
77
  }
58
78
  return undefined;
59
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-host",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Reusable host runtime for Notion custom blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -247,28 +247,35 @@ export function createCustomBlockHost(
247
247
  message: QueryDataSourceMessage,
248
248
  token: QuerySubscriptionToken = querySubscriptions.subscribe(message),
249
249
  ) {
250
- const collectionSchema = getCollectionSchema(
251
- activeDataSources,
252
- message.dataSourceId,
253
- )
254
- const queryError = getQueryValidationError(message, collectionSchema)
255
- if (queryError !== undefined) {
256
- if (querySubscriptions.isCurrent(message.subscriptionId, token)) {
257
- postQueryDataSourceResult({
258
- subscriptionId: message.subscriptionId,
259
- response: { status: "error", error: queryError },
260
- })
250
+ try {
251
+ const collectionSchema = getCollectionSchema(
252
+ activeDataSources,
253
+ message.dataSourceId,
254
+ )
255
+ const queryError = getQueryValidationError(message, collectionSchema)
256
+ if (queryError !== undefined) {
257
+ if (querySubscriptions.isCurrent(message.subscriptionId, token)) {
258
+ postQueryDataSourceResult({
259
+ subscriptionId: message.subscriptionId,
260
+ response: { status: "error", error: queryError },
261
+ })
262
+ }
263
+ return
264
+ }
265
+ const response = await handlers.queryDataSource(message)
266
+ if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
267
+ return
268
+ }
269
+ postQueryDataSourceResult({
270
+ subscriptionId: message.subscriptionId,
271
+ response,
272
+ })
273
+ } finally {
274
+ const refresh = querySubscriptions.finish(message.subscriptionId, token)
275
+ if (refresh !== undefined) {
276
+ void handleQuery(refresh.message, refresh.token)
261
277
  }
262
- return
263
- }
264
- const response = await handlers.queryDataSource(message)
265
- if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
266
- return
267
278
  }
268
- postQueryDataSourceResult({
269
- subscriptionId: message.subscriptionId,
270
- response,
271
- })
272
279
  }
273
280
 
274
281
  function updateHostState(update: HostStateUpdates) {
@@ -487,7 +494,7 @@ export function createCustomBlockHost(
487
494
  dataSourceId,
488
495
  )
489
496
  const refreshes = querySubscriptions.refresh(normalizedDataSourceId)
490
- if (refreshes.length === 0) {
497
+ if (refreshes === undefined) {
491
498
  emit("warn", `No active query exists for data source "${dataSourceId}"`)
492
499
  return
493
500
  }
package/src/index.ts CHANGED
@@ -13,6 +13,9 @@ export type {
13
13
  CustomBlockOptionFilterOperator,
14
14
  CustomBlockPeopleFilterOperator,
15
15
  CustomBlockPersonFilterValue,
16
+ CustomBlockStatusFilterOperator,
17
+ CustomBlockStatusGroupFilterOperator,
18
+ CustomBlockStatusGroupName,
16
19
  CustomBlockTextFilterOperator,
17
20
  QueryDataSourceMessage,
18
21
  ResolvedCustomBlockDataSourceFilter,
@@ -13,6 +13,8 @@ export type QuerySubscriptionToken = {
13
13
  type QuerySubscriptionState = {
14
14
  message: QueryDataSourceMessage
15
15
  token: QuerySubscriptionToken
16
+ isRefreshing: boolean
17
+ shouldRefreshAgain: boolean
16
18
  }
17
19
 
18
20
  export class QuerySubscriptions {
@@ -25,6 +27,8 @@ export class QuerySubscriptions {
25
27
  this.bySubscriptionId.set(message.subscriptionId, {
26
28
  message,
27
29
  token,
30
+ isRefreshing: true,
31
+ shouldRefreshAgain: false,
28
32
  })
29
33
  return token
30
34
  }
@@ -37,22 +41,42 @@ export class QuerySubscriptions {
37
41
  this.bySubscriptionId.delete(subscriptionId)
38
42
  }
39
43
 
40
- refresh(dataSourceId: NotionDataSourceId): QueryRefresh[] {
44
+ refresh(dataSourceId: NotionDataSourceId): QueryRefresh[] | undefined {
41
45
  const refreshes: QueryRefresh[] = []
46
+ let hasSubscriptions = false
42
47
  for (const queryState of this.bySubscriptionId.values()) {
43
48
  if (queryState.message.dataSourceId !== dataSourceId) {
44
49
  continue
45
50
  }
46
- const token: QuerySubscriptionToken = {
47
- _tag: "QuerySubscriptionToken",
51
+ hasSubscriptions = true
52
+ if (queryState.isRefreshing) {
53
+ queryState.shouldRefreshAgain = true
54
+ continue
48
55
  }
49
- queryState.token = token
56
+ queryState.isRefreshing = true
50
57
  refreshes.push({
51
58
  message: queryState.message,
52
- token,
59
+ token: queryState.token,
53
60
  })
54
61
  }
55
- return refreshes
62
+ return hasSubscriptions ? refreshes : undefined
63
+ }
64
+
65
+ finish(
66
+ subscriptionId: string,
67
+ token: QuerySubscriptionToken,
68
+ ): QueryRefresh | undefined {
69
+ const state = this.bySubscriptionId.get(subscriptionId)
70
+ if (state?.token !== token) {
71
+ return undefined
72
+ }
73
+ state.isRefreshing = false
74
+ if (!state.shouldRefreshAgain) {
75
+ return undefined
76
+ }
77
+ state.shouldRefreshAgain = false
78
+ state.isRefreshing = true
79
+ return { message: state.message, token: state.token }
56
80
  }
57
81
 
58
82
  unsubscribeAll() {
@@ -52,6 +52,27 @@ function validatePropertyFilter(
52
52
  }
53
53
  }
54
54
 
55
+ if ("status" in filter && propertySchema.type === "status") {
56
+ const operator = filter.status
57
+ if ("group_equals" in operator || "group_does_not_equal" in operator) {
58
+ const value =
59
+ "group_equals" in operator
60
+ ? operator.group_equals
61
+ : operator.group_does_not_equal
62
+ const names = Array.isArray(value) ? value : [value]
63
+ const unknownName = names.find(
64
+ name => !propertySchema.groups.some(group => group.name === name),
65
+ )
66
+ return unknownName === undefined
67
+ ? undefined
68
+ : {
69
+ code: "invalid_data_source_query_filter",
70
+ message: `Unknown status group "${unknownName}".`,
71
+ isRetryable: false,
72
+ }
73
+ }
74
+ }
75
+
55
76
  const optionFilter = getOptionFilter(filter)
56
77
  if (
57
78
  optionFilter === undefined ||
@@ -88,7 +109,10 @@ function getOptionFilter(filter: ResolvedCustomBlockDataSourcePropertyFilter):
88
109
  return { propertyType: "multi_select", operator: filter.multi_select }
89
110
  }
90
111
  if ("status" in filter) {
91
- return { propertyType: "status", operator: filter.status }
112
+ const operator = filter.status
113
+ return "group_equals" in operator || "group_does_not_equal" in operator
114
+ ? undefined
115
+ : { propertyType: "status", operator }
92
116
  }
93
117
  return undefined
94
118
  }