@notionhq/custom-blocks-host 0.2.6 → 0.2.8

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
@@ -81,9 +81,10 @@ const host = createCustomBlockHost({
81
81
  onInitialized: state => {
82
82
  console.log("Initialized manifest", state.manifest)
83
83
  },
84
- onFailure: error => {
84
+ onConnectionFailure: error => {
85
85
  showHostError(error)
86
86
  },
87
+ onQueryUnsubscribed: undefined,
87
88
  onLog: (direction, payload) => {
88
89
  console.log(direction, payload)
89
90
  },
@@ -101,8 +102,8 @@ Each host handles one initialization handshake with one sandbox iframe:
101
102
  malformed ones. A connection after an initialization timeout does not restart it.
102
103
  - The first observed iframe `load` is allowed, including when initialization completes before it.
103
104
  - A second observed `load` stops the host and reports retryable `iframe_reloaded` through
104
- `onFailure`. A reload or navigation can replace the sandbox document, so the host ends the
105
- connection instead of continuing to serve the replacement.
105
+ `onConnectionFailure`. A reload or navigation can replace the sandbox document, so the host ends
106
+ the connection instead of continuing to serve the replacement.
106
107
  - Stopping removes message and load listeners, clears initialization timers, ends query
107
108
  subscriptions, and prevents further outbound messages, including pending responses.
108
109
  - To retry or apply a deployment or configuration change, the embedder creates a new host and
@@ -142,8 +143,12 @@ iframe reload.
142
143
 
143
144
  - `onInitialized` reports success after the sandbox accepts initialization. It provides the selected
144
145
  `manifest` and the sandbox's optional `initialHeight`.
145
- - `onFailure` reports a handshake failure, timeout, unavailable page context, or iframe reload. It
146
- can run after initialization succeeds.
146
+ - `onConnectionFailure` reports a handshake failure, timeout, unavailable page context, or iframe
147
+ reload. It can run after initialization succeeds.
148
+
149
+ - `onQueryUnsubscribed` reports when a query subscription ends. Use it to release per-query
150
+ resources, such as listeners or timers. The host removes the subscription itself. A query failure
151
+ can end one subscription while the connection remains active.
147
152
 
148
153
  `queryDataSource` is required. Other request handlers are optional. Every request handler may return
149
154
  its result synchronously or as a promise. Results use a `status` discriminator: successful results
@@ -256,6 +261,15 @@ removes a subscription when it receives `unsubscribeDataSourceQuery`. Repeated u
256
261
  are safe. The runtime also ignores results from a query that was unsubscribed while its handler was
257
262
  running.
258
263
 
264
+ A non-retryable query error ends the subscription and discards any queued refresh. This includes
265
+ validation errors before the query handler runs. Retryable errors retain the subscription.
266
+
267
+ Use `onQueryUnsubscribed(subscriptionId)` to release adapter resources such as collection listeners.
268
+ The callback runs when a subscription ends through an explicit unsubscribe, replacement, terminal
269
+ error, or host stop. Repeated removal of the same subscription does not repeat the callback. A late
270
+ result from a replaced query cannot remove its replacement. The sandbox still receives the terminal
271
+ error result.
272
+
259
273
  Call `stop()` when the iframe is removed. It detaches listeners, clears timeouts, and discards
260
274
  active query subscriptions.
261
275
 
@@ -33,7 +33,9 @@ export type CustomBlockHostOptions = {
33
33
  * before this callback runs.
34
34
  * This callback can run after initialization succeeds.
35
35
  */
36
- onFailure?: (error: CustomBlockHostFailure) => void;
36
+ onConnectionFailure: ((error: CustomBlockHostFailure) => void) | undefined;
37
+ /** Releases adapter resources when a query ends, including replacement and terminal errors. */
38
+ onQueryUnsubscribed: ((subscriptionId: string) => void) | undefined;
37
39
  onLog?: (direction: CustomBlockHostLogDirection, payload: unknown) => void;
38
40
  getInitialState: CustomBlockHostGetInitialState;
39
41
  initialStateTimeoutMs?: number;
@@ -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,8CAA8C,CAAA;AAiBvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAA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AM,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,CA8YvB"}
@@ -19,7 +19,7 @@ import { unreachable } from "./utils.js";
19
19
  // Earlier SDKs cannot represent this context, so the host reports context_unavailable.
20
20
  const BRIDGE_PROTOCOL_VERSION_INTRODUCING_UNAVAILABLE_PAGE = 5;
21
21
  export function createCustomBlockHost(options) {
22
- const { iframe, getInitialState, handlers, onManifest, onInitialized, onFailure, onLog, sandboxOrigin, minBridgeProtocolVersion: configuredMinBridgeProtocolVersion, noConnectTimeoutMs, initialStateTimeoutMs, noInitResultTimeoutMs, } = options;
22
+ const { iframe, getInitialState, handlers, onManifest, onInitialized, onConnectionFailure, onLog, onQueryUnsubscribed, sandboxOrigin, minBridgeProtocolVersion: configuredMinBridgeProtocolVersion, noConnectTimeoutMs, initialStateTimeoutMs, noInitResultTimeoutMs, } = options;
23
23
  // Callers can retire older SDKs, but cannot restore support for protocols
24
24
  // the runtime no longer implements. Omission uses the runtime minimum.
25
25
  const minBridgeProtocolVersion = Math.max(configuredMinBridgeProtocolVersion ??
@@ -29,7 +29,9 @@ export function createCustomBlockHost(options) {
29
29
  let manifest;
30
30
  let activeDataSources;
31
31
  let sandboxBridgeProtocolVersion = LATEST_BRIDGE_PROTOCOL_VERSION;
32
- const querySubscriptions = new QuerySubscriptions();
32
+ const querySubscriptions = new QuerySubscriptions(subscriptionId => {
33
+ onQueryUnsubscribed?.(subscriptionId);
34
+ });
33
35
  function emit(direction, payload) {
34
36
  onLog?.(direction, payload);
35
37
  }
@@ -114,6 +116,7 @@ export function createCustomBlockHost(options) {
114
116
  const queryError = getQueryValidationError(message, collectionSchema);
115
117
  if (queryError !== undefined) {
116
118
  if (querySubscriptions.isCurrent(message.subscriptionId, token)) {
119
+ querySubscriptions.unsubscribe(message.subscriptionId);
117
120
  postQueryDataSourceResult({
118
121
  subscriptionId: message.subscriptionId,
119
122
  response: { status: "error", error: queryError },
@@ -125,6 +128,9 @@ export function createCustomBlockHost(options) {
125
128
  if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
126
129
  return;
127
130
  }
131
+ if (response.status === "error" && !response.error.isRetryable) {
132
+ querySubscriptions.unsubscribe(message.subscriptionId);
133
+ }
128
134
  postQueryDataSourceResult({
129
135
  subscriptionId: message.subscriptionId,
130
136
  response,
@@ -203,7 +209,7 @@ export function createCustomBlockHost(options) {
203
209
  onInitialized?.({ manifest, initialHeight: message.initialHeight });
204
210
  }
205
211
  },
206
- onFailure,
212
+ onConnectionFailure,
207
213
  });
208
214
  function prepareInitialState(result) {
209
215
  if (result.status === "error") {
@@ -270,7 +276,7 @@ export function createCustomBlockHost(options) {
270
276
  function stopWithFailure(error) {
271
277
  stop();
272
278
  emit("warn", error);
273
- onFailure?.(error);
279
+ onConnectionFailure?.(error);
274
280
  }
275
281
  return {
276
282
  stop,
@@ -15,7 +15,7 @@ export type InitializationControllerOptions = {
15
15
  noInitResultTimeoutMs?: number;
16
16
  stopHostWithFailure: (error: CustomBlockHostFailure) => void;
17
17
  onInitResult?: (message: InitResultMessage) => void;
18
- onFailure?: (error: CustomBlockHostFailure) => void;
18
+ onConnectionFailure: ((error: CustomBlockHostFailure) => void) | undefined;
19
19
  };
20
20
  export type InitializationController = {
21
21
  readonly status: InitStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"initializationController.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initializationController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EACX,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAIlE,OAAO,KAAK,EACX,qBAAqB,EACrB,iCAAiC,EACjC,UAAU,EACV,MAAM,YAAY,CAAA;AAMnB,MAAM,MAAM,+BAA+B,GAAG;IAC7C,WAAW,EAAE,CACZ,OAAO,EAAE,qBAAqB,KAC1B,OAAO,CAAC,iCAAiC,CAAC,CAAA;IAC/C,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,KAAK,IAAI,CAAA;IACxE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAChC,4BAA4B,EAAE,MAAM,IAAI,CAAA;IACxC,wBAAwB,EAAE,MAAM,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAC5D,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACnD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IACrC,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAA;IAChD,gBAAgB,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACtD,oBAAoB,EAAE,CAAC,IAAI,EAAE;QAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;QAC/B,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAA;KACzC,KAAK,SAAS,GAAG,MAAM,CAAA;IACxB,uBAAuB,EAAE,CAAC,IAAI,EAAE;QAC/B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;KAC/B,KAAK,IAAI,CAAA;IACV,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,+BAA+B,GACtC,wBAAwB,CAiU1B"}
1
+ {"version":3,"file":"initializationController.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initializationController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EACX,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAIlE,OAAO,KAAK,EACX,qBAAqB,EACrB,iCAAiC,EACjC,UAAU,EACV,MAAM,YAAY,CAAA;AAMnB,MAAM,MAAM,+BAA+B,GAAG;IAC7C,WAAW,EAAE,CACZ,OAAO,EAAE,qBAAqB,KAC1B,OAAO,CAAC,iCAAiC,CAAC,CA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AAA;CAChB,CAAA;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,+BAA+B,GACtC,wBAAwB,CAiU1B"}
@@ -6,7 +6,7 @@ const DEFAULT_NO_CONNECT_TIMEOUT_MS = 5_000;
6
6
  const DEFAULT_INITIAL_STATE_TIMEOUT_MS = 5_000;
7
7
  const DEFAULT_NO_INIT_RESULT_TIMEOUT_MS = 5_000;
8
8
  export function createInitializationController(options) {
9
- const { prepareInit, sendInitMessage, warn, flushPendingHostStateChanges, minBridgeProtocolVersion, noConnectTimeoutMs = DEFAULT_NO_CONNECT_TIMEOUT_MS, initialStateTimeoutMs = DEFAULT_INITIAL_STATE_TIMEOUT_MS, noInitResultTimeoutMs = DEFAULT_NO_INIT_RESULT_TIMEOUT_MS, stopHostWithFailure, onInitResult, onFailure, } = options;
9
+ const { prepareInit, sendInitMessage, warn, flushPendingHostStateChanges, minBridgeProtocolVersion, noConnectTimeoutMs = DEFAULT_NO_CONNECT_TIMEOUT_MS, initialStateTimeoutMs = DEFAULT_INITIAL_STATE_TIMEOUT_MS, noInitResultTimeoutMs = DEFAULT_NO_INIT_RESULT_TIMEOUT_MS, stopHostWithFailure, onInitResult, onConnectionFailure, } = options;
10
10
  let initStatus = "waitingForConnect";
11
11
  let noConnectTimeoutId;
12
12
  let initialStateTimeoutId;
@@ -56,7 +56,7 @@ export function createInitializationController(options) {
56
56
  status: "error",
57
57
  error,
58
58
  });
59
- onFailure?.(error);
59
+ onConnectionFailure?.(error);
60
60
  }
61
61
  async function prepareAndSendInit(connect) {
62
62
  if (initStatus !== "waitingForConnect") {
@@ -110,7 +110,7 @@ export function createInitializationController(options) {
110
110
  }
111
111
  initStatus = "error";
112
112
  const error = initErrorForFailureReason("no_init_result");
113
- onFailure?.(error);
113
+ onConnectionFailure?.(error);
114
114
  warn({
115
115
  ...error,
116
116
  initializationId: connect.initializationId,
@@ -210,7 +210,7 @@ export function createInitializationController(options) {
210
210
  clearNoInitResultTimeout();
211
211
  initStatus = "error";
212
212
  warn(error);
213
- onFailure?.(error);
213
+ onConnectionFailure?.(error);
214
214
  }
215
215
  function onIframeLoad() {
216
216
  if (initStatus === "stopped") {
@@ -238,7 +238,7 @@ export function createInitializationController(options) {
238
238
  initStatus = "error";
239
239
  const error = initErrorForFailureReason("no_connect");
240
240
  warn(error);
241
- onFailure?.(error);
241
+ onConnectionFailure?.(error);
242
242
  }, noConnectTimeoutMs);
243
243
  }
244
244
  function handleInitResult(message) {
@@ -256,7 +256,7 @@ export function createInitializationController(options) {
256
256
  flushPendingHostStateChanges();
257
257
  }
258
258
  else {
259
- onFailure?.(message.error);
259
+ onConnectionFailure?.(message.error);
260
260
  }
261
261
  onInitResult?.(message);
262
262
  }
@@ -122,21 +122,44 @@ export declare const customBlockContainsFilterOperatorSchema: v.UnionSchema<[v.S
122
122
  readonly is_not_empty: v.LiteralSchema<true, undefined>;
123
123
  }, undefined>], undefined>], undefined>;
124
124
  export type CustomBlockContainsFilterOperator = v.InferOutput<typeof customBlockContainsFilterOperatorSchema>;
125
+ export declare const customBlockRelativeDateValueSchema: v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>;
126
+ export type CustomBlockRelativeDateValue = v.InferOutput<typeof customBlockRelativeDateValueSchema>;
125
127
  export declare const customBlockDateFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
126
128
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
127
- readonly equals: v.StringSchema<undefined>;
129
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
130
+ }, undefined>, v.StrictObjectSchema<{
131
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
132
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
133
+ }, undefined>, v.StrictObjectSchema<{
134
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
135
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
136
+ }, undefined>, v.StrictObjectSchema<{
137
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
138
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
139
+ }, undefined>, v.StrictObjectSchema<{
140
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
141
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
128
142
  }, undefined>, v.StrictObjectSchema<{
129
143
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
130
- readonly before: v.StringSchema<undefined>;
144
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
131
145
  }, undefined>, v.StrictObjectSchema<{
132
146
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
133
- readonly after: v.StringSchema<undefined>;
147
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
134
148
  }, undefined>, v.StrictObjectSchema<{
135
149
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
136
- readonly on_or_before: v.StringSchema<undefined>;
150
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
137
151
  }, undefined>, v.StrictObjectSchema<{
138
152
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
139
- readonly on_or_after: v.StringSchema<undefined>;
153
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
154
+ }, undefined>, v.StrictObjectSchema<{
155
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
156
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
157
+ }, undefined>, v.StrictObjectSchema<{
158
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
159
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
160
+ }, undefined>, v.StrictObjectSchema<{
161
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
162
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
140
163
  }, undefined>, v.StrictObjectSchema<{
141
164
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
142
165
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -326,19 +349,40 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
326
349
  readonly propertyId: v.StringSchema<undefined>;
327
350
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
328
351
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
329
- readonly equals: v.StringSchema<undefined>;
352
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
353
+ }, undefined>, v.StrictObjectSchema<{
354
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
355
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
330
356
  }, undefined>, v.StrictObjectSchema<{
331
357
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
332
- readonly before: v.StringSchema<undefined>;
358
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
333
359
  }, undefined>, v.StrictObjectSchema<{
334
360
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
335
- readonly after: v.StringSchema<undefined>;
361
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
336
362
  }, undefined>, v.StrictObjectSchema<{
337
363
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
338
- readonly on_or_before: v.StringSchema<undefined>;
364
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
339
365
  }, undefined>, v.StrictObjectSchema<{
340
366
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
341
- readonly on_or_after: v.StringSchema<undefined>;
367
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
368
+ }, undefined>, v.StrictObjectSchema<{
369
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
370
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
371
+ }, undefined>, v.StrictObjectSchema<{
372
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
373
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
374
+ }, undefined>, v.StrictObjectSchema<{
375
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
376
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
377
+ }, undefined>, v.StrictObjectSchema<{
378
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
379
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
380
+ }, undefined>, v.StrictObjectSchema<{
381
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
382
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
383
+ }, undefined>, v.StrictObjectSchema<{
384
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
385
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
342
386
  }, undefined>, v.StrictObjectSchema<{
343
387
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
344
388
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -546,19 +590,40 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
546
590
  readonly propertyId: v.StringSchema<undefined>;
547
591
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
548
592
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
549
- readonly equals: v.StringSchema<undefined>;
593
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
594
+ }, undefined>, v.StrictObjectSchema<{
595
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
596
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
597
+ }, undefined>, v.StrictObjectSchema<{
598
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
599
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
600
+ }, undefined>, v.StrictObjectSchema<{
601
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
602
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
603
+ }, undefined>, v.StrictObjectSchema<{
604
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
605
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
606
+ }, undefined>, v.StrictObjectSchema<{
607
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
608
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
609
+ }, undefined>, v.StrictObjectSchema<{
610
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
611
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
612
+ }, undefined>, v.StrictObjectSchema<{
613
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
614
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
550
615
  }, undefined>, v.StrictObjectSchema<{
551
616
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
552
- readonly before: v.StringSchema<undefined>;
617
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
553
618
  }, undefined>, v.StrictObjectSchema<{
554
619
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
555
- readonly after: v.StringSchema<undefined>;
620
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
556
621
  }, undefined>, v.StrictObjectSchema<{
557
622
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
558
- readonly on_or_before: v.StringSchema<undefined>;
623
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
559
624
  }, undefined>, v.StrictObjectSchema<{
560
625
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
561
- readonly on_or_after: v.StringSchema<undefined>;
626
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
562
627
  }, undefined>, v.StrictObjectSchema<{
563
628
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
564
629
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -765,19 +830,40 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
765
830
  readonly propertyId: v.StringSchema<undefined>;
766
831
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
767
832
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
768
- readonly equals: v.StringSchema<undefined>;
833
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
834
+ }, undefined>, v.StrictObjectSchema<{
835
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
836
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
837
+ }, undefined>, v.StrictObjectSchema<{
838
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
839
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
840
+ }, undefined>, v.StrictObjectSchema<{
841
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
842
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
843
+ }, undefined>, v.StrictObjectSchema<{
844
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
845
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
769
846
  }, undefined>, v.StrictObjectSchema<{
770
847
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
771
- readonly before: v.StringSchema<undefined>;
848
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
772
849
  }, undefined>, v.StrictObjectSchema<{
773
850
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
774
- readonly after: v.StringSchema<undefined>;
851
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
775
852
  }, undefined>, v.StrictObjectSchema<{
776
853
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
777
- readonly on_or_before: v.StringSchema<undefined>;
854
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
778
855
  }, undefined>, v.StrictObjectSchema<{
779
856
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
780
- readonly on_or_after: v.StringSchema<undefined>;
857
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
858
+ }, undefined>, v.StrictObjectSchema<{
859
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
860
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
861
+ }, undefined>, v.StrictObjectSchema<{
862
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
863
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
864
+ }, undefined>, v.StrictObjectSchema<{
865
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
866
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
781
867
  }, undefined>, v.StrictObjectSchema<{
782
868
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
783
869
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -1009,19 +1095,40 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
1009
1095
  readonly propertyId: v.StringSchema<undefined>;
1010
1096
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
1011
1097
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1012
- readonly equals: v.StringSchema<undefined>;
1098
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1099
+ }, undefined>, v.StrictObjectSchema<{
1100
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1101
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1013
1102
  }, undefined>, v.StrictObjectSchema<{
1014
1103
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1015
- readonly before: v.StringSchema<undefined>;
1104
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1016
1105
  }, undefined>, v.StrictObjectSchema<{
1017
1106
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1018
- readonly after: v.StringSchema<undefined>;
1107
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1019
1108
  }, undefined>, v.StrictObjectSchema<{
1020
1109
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1021
- readonly on_or_before: v.StringSchema<undefined>;
1110
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1022
1111
  }, undefined>, v.StrictObjectSchema<{
1023
1112
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1024
- readonly on_or_after: v.StringSchema<undefined>;
1113
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
1114
+ }, undefined>, v.StrictObjectSchema<{
1115
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1116
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
1117
+ }, undefined>, v.StrictObjectSchema<{
1118
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1119
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
1120
+ }, undefined>, v.StrictObjectSchema<{
1121
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1122
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
1123
+ }, undefined>, v.StrictObjectSchema<{
1124
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1125
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
1126
+ }, undefined>, v.StrictObjectSchema<{
1127
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1128
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
1129
+ }, undefined>, v.StrictObjectSchema<{
1130
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1131
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
1025
1132
  }, undefined>, v.StrictObjectSchema<{
1026
1133
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1027
1134
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -1228,19 +1335,40 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
1228
1335
  readonly propertyId: v.StringSchema<undefined>;
1229
1336
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
1230
1337
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1231
- readonly equals: v.StringSchema<undefined>;
1338
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1339
+ }, undefined>, v.StrictObjectSchema<{
1340
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1341
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1342
+ }, undefined>, v.StrictObjectSchema<{
1343
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1344
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1345
+ }, undefined>, v.StrictObjectSchema<{
1346
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1347
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1348
+ }, undefined>, v.StrictObjectSchema<{
1349
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1350
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
1351
+ }, undefined>, v.StrictObjectSchema<{
1352
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1353
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
1354
+ }, undefined>, v.StrictObjectSchema<{
1355
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1356
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
1357
+ }, undefined>, v.StrictObjectSchema<{
1358
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1359
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
1232
1360
  }, undefined>, v.StrictObjectSchema<{
1233
1361
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1234
- readonly before: v.StringSchema<undefined>;
1362
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
1235
1363
  }, undefined>, v.StrictObjectSchema<{
1236
1364
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1237
- readonly after: v.StringSchema<undefined>;
1365
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
1238
1366
  }, undefined>, v.StrictObjectSchema<{
1239
1367
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1240
- readonly on_or_before: v.StringSchema<undefined>;
1368
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
1241
1369
  }, undefined>, v.StrictObjectSchema<{
1242
1370
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1243
- readonly on_or_after: v.StringSchema<undefined>;
1371
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
1244
1372
  }, undefined>, v.StrictObjectSchema<{
1245
1373
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
1246
1374
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -83,26 +83,67 @@ export const customBlockContainsFilterOperatorSchema = v.union([
83
83
  emptyOperatorSchema,
84
84
  ]);
85
85
  const dateTargetSchema = v.picklist(["start_date", "end_date"]);
86
+ export const customBlockRelativeDateValueSchema = v.picklist([
87
+ "today",
88
+ "tomorrow",
89
+ "yesterday",
90
+ "one_week_ago",
91
+ "one_week_from_now",
92
+ "one_month_ago",
93
+ "one_month_from_now",
94
+ ]);
95
+ const dateComparisonValueSchema = v.union([
96
+ customBlockRelativeDateValueSchema,
97
+ v.string(),
98
+ ]);
86
99
  export const customBlockDateFilterOperatorSchema = v.union([
87
100
  v.strictObject({
88
101
  target: v.optional(dateTargetSchema),
89
- equals: v.string(),
102
+ equals: dateComparisonValueSchema,
103
+ }),
104
+ v.strictObject({
105
+ target: v.optional(dateTargetSchema),
106
+ before: dateComparisonValueSchema,
107
+ }),
108
+ v.strictObject({
109
+ target: v.optional(dateTargetSchema),
110
+ after: dateComparisonValueSchema,
111
+ }),
112
+ v.strictObject({
113
+ target: v.optional(dateTargetSchema),
114
+ on_or_before: dateComparisonValueSchema,
115
+ }),
116
+ v.strictObject({
117
+ target: v.optional(dateTargetSchema),
118
+ on_or_after: dateComparisonValueSchema,
119
+ }),
120
+ v.strictObject({
121
+ target: v.optional(dateTargetSchema),
122
+ this_week: v.strictObject({}),
123
+ }),
124
+ v.strictObject({
125
+ target: v.optional(dateTargetSchema),
126
+ past_week: v.strictObject({}),
127
+ }),
128
+ v.strictObject({
129
+ target: v.optional(dateTargetSchema),
130
+ past_month: v.strictObject({}),
90
131
  }),
91
132
  v.strictObject({
92
133
  target: v.optional(dateTargetSchema),
93
- before: v.string(),
134
+ past_year: v.strictObject({}),
94
135
  }),
95
136
  v.strictObject({
96
137
  target: v.optional(dateTargetSchema),
97
- after: v.string(),
138
+ next_week: v.strictObject({}),
98
139
  }),
99
140
  v.strictObject({
100
141
  target: v.optional(dateTargetSchema),
101
- on_or_before: v.string(),
142
+ next_month: v.strictObject({}),
102
143
  }),
103
144
  v.strictObject({
104
145
  target: v.optional(dateTargetSchema),
105
- on_or_after: v.string(),
146
+ next_year: v.strictObject({}),
106
147
  }),
107
148
  v.strictObject({
108
149
  target: v.optional(dateTargetSchema),
@@ -239,19 +239,40 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
239
239
  readonly propertyId: v.StringSchema<undefined>;
240
240
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
241
241
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
242
- readonly equals: v.StringSchema<undefined>;
242
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
243
+ }, undefined>, v.StrictObjectSchema<{
244
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
245
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
246
+ }, undefined>, v.StrictObjectSchema<{
247
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
248
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
249
+ }, undefined>, v.StrictObjectSchema<{
250
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
251
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
252
+ }, undefined>, v.StrictObjectSchema<{
253
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
254
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
255
+ }, undefined>, v.StrictObjectSchema<{
256
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
257
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
258
+ }, undefined>, v.StrictObjectSchema<{
259
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
260
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
261
+ }, undefined>, v.StrictObjectSchema<{
262
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
263
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
243
264
  }, undefined>, v.StrictObjectSchema<{
244
265
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
245
- readonly before: v.StringSchema<undefined>;
266
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
246
267
  }, undefined>, v.StrictObjectSchema<{
247
268
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
248
- readonly after: v.StringSchema<undefined>;
269
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
249
270
  }, undefined>, v.StrictObjectSchema<{
250
271
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
251
- readonly on_or_before: v.StringSchema<undefined>;
272
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
252
273
  }, undefined>, v.StrictObjectSchema<{
253
274
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
254
- readonly on_or_after: v.StringSchema<undefined>;
275
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
255
276
  }, undefined>, v.StrictObjectSchema<{
256
277
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
257
278
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -458,19 +479,40 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
458
479
  readonly propertyId: v.StringSchema<undefined>;
459
480
  readonly date: v.UnionSchema<[v.StrictObjectSchema<{
460
481
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
461
- readonly equals: v.StringSchema<undefined>;
482
+ readonly equals: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
483
+ }, undefined>, v.StrictObjectSchema<{
484
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
485
+ readonly before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
486
+ }, undefined>, v.StrictObjectSchema<{
487
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
488
+ readonly after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
489
+ }, undefined>, v.StrictObjectSchema<{
490
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
491
+ readonly on_or_before: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
492
+ }, undefined>, v.StrictObjectSchema<{
493
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
494
+ readonly on_or_after: v.UnionSchema<[v.PicklistSchema<["today", "tomorrow", "yesterday", "one_week_ago", "one_week_from_now", "one_month_ago", "one_month_from_now"], undefined>, v.StringSchema<undefined>], undefined>;
495
+ }, undefined>, v.StrictObjectSchema<{
496
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
497
+ readonly this_week: v.StrictObjectSchema<{}, undefined>;
498
+ }, undefined>, v.StrictObjectSchema<{
499
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
500
+ readonly past_week: v.StrictObjectSchema<{}, undefined>;
501
+ }, undefined>, v.StrictObjectSchema<{
502
+ readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
503
+ readonly past_month: v.StrictObjectSchema<{}, undefined>;
462
504
  }, undefined>, v.StrictObjectSchema<{
463
505
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
464
- readonly before: v.StringSchema<undefined>;
506
+ readonly past_year: v.StrictObjectSchema<{}, undefined>;
465
507
  }, undefined>, v.StrictObjectSchema<{
466
508
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
467
- readonly after: v.StringSchema<undefined>;
509
+ readonly next_week: v.StrictObjectSchema<{}, undefined>;
468
510
  }, undefined>, v.StrictObjectSchema<{
469
511
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
470
- readonly on_or_before: v.StringSchema<undefined>;
512
+ readonly next_month: v.StrictObjectSchema<{}, undefined>;
471
513
  }, undefined>, v.StrictObjectSchema<{
472
514
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
473
- readonly on_or_after: v.StringSchema<undefined>;
515
+ readonly next_year: v.StrictObjectSchema<{}, undefined>;
474
516
  }, undefined>, v.StrictObjectSchema<{
475
517
  readonly target: v.OptionalSchema<v.PicklistSchema<["start_date", "end_date"], undefined>, undefined>;
476
518
  readonly is_empty: v.LiteralSchema<true, undefined>;
@@ -8,7 +8,9 @@ export type QuerySubscriptionToken = {
8
8
  readonly _tag: "QuerySubscriptionToken";
9
9
  };
10
10
  export declare class QuerySubscriptions {
11
+ private readonly onUnsubscribe;
11
12
  private readonly bySubscriptionId;
13
+ constructor(onUnsubscribe: (subscriptionId: string) => void);
12
14
  subscribe(message: QueryDataSourceMessage): QuerySubscriptionToken;
13
15
  isCurrent(subscriptionId: string, token: QuerySubscriptionToken): boolean;
14
16
  unsubscribe(subscriptionId: string): void;
@@ -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;AASD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,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S,CAmBpE;IAED,MAAM,CACL,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,sBAAsB,GAC3B,YAAY,GAAG,SAAS,CAY1B;IAED,cAAc,SAIb;CACD"}
@@ -1,6 +1,11 @@
1
1
  export class QuerySubscriptions {
2
+ onUnsubscribe;
2
3
  bySubscriptionId = new Map();
4
+ constructor(onUnsubscribe) {
5
+ this.onUnsubscribe = onUnsubscribe;
6
+ }
3
7
  subscribe(message) {
8
+ this.unsubscribe(message.subscriptionId);
4
9
  const token = {
5
10
  _tag: "QuerySubscriptionToken",
6
11
  };
@@ -16,7 +21,9 @@ export class QuerySubscriptions {
16
21
  return this.bySubscriptionId.get(subscriptionId)?.token === token;
17
22
  }
18
23
  unsubscribe(subscriptionId) {
19
- this.bySubscriptionId.delete(subscriptionId);
24
+ if (this.bySubscriptionId.delete(subscriptionId)) {
25
+ this.onUnsubscribe(subscriptionId);
26
+ }
20
27
  }
21
28
  refresh(dataSourceId) {
22
29
  const refreshes = [];
@@ -52,6 +59,8 @@ export class QuerySubscriptions {
52
59
  return { message: state.message, token: state.token };
53
60
  }
54
61
  unsubscribeAll() {
55
- this.bySubscriptionId.clear();
62
+ for (const subscriptionId of this.bySubscriptionId.keys()) {
63
+ this.unsubscribe(subscriptionId);
64
+ }
56
65
  }
57
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-host",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Reusable host runtime for Notion custom blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -83,7 +83,9 @@ export type CustomBlockHostOptions = {
83
83
  * before this callback runs.
84
84
  * This callback can run after initialization succeeds.
85
85
  */
86
- onFailure?: (error: CustomBlockHostFailure) => void
86
+ onConnectionFailure: ((error: CustomBlockHostFailure) => void) | undefined
87
+ /** Releases adapter resources when a query ends, including replacement and terminal errors. */
88
+ onQueryUnsubscribed: ((subscriptionId: string) => void) | undefined
87
89
  onLog?: (direction: CustomBlockHostLogDirection, payload: unknown) => void
88
90
  getInitialState: CustomBlockHostGetInitialState
89
91
  initialStateTimeoutMs?: number
@@ -119,8 +121,9 @@ export function createCustomBlockHost(
119
121
  handlers,
120
122
  onManifest,
121
123
  onInitialized,
122
- onFailure,
124
+ onConnectionFailure,
123
125
  onLog,
126
+ onQueryUnsubscribed,
124
127
  sandboxOrigin,
125
128
  minBridgeProtocolVersion: configuredMinBridgeProtocolVersion,
126
129
  noConnectTimeoutMs,
@@ -143,7 +146,9 @@ export function createCustomBlockHost(
143
146
  let manifest: CustomBlockManifest | undefined
144
147
  let activeDataSources: CustomBlockHostNormalizedDataSourcesPayload | undefined
145
148
  let sandboxBridgeProtocolVersion = LATEST_BRIDGE_PROTOCOL_VERSION
146
- const querySubscriptions = new QuerySubscriptions()
149
+ const querySubscriptions = new QuerySubscriptions(subscriptionId => {
150
+ onQueryUnsubscribed?.(subscriptionId)
151
+ })
147
152
 
148
153
  function emit(direction: CustomBlockHostLogDirection, payload: unknown) {
149
154
  onLog?.(direction, payload)
@@ -255,6 +260,7 @@ export function createCustomBlockHost(
255
260
  const queryError = getQueryValidationError(message, collectionSchema)
256
261
  if (queryError !== undefined) {
257
262
  if (querySubscriptions.isCurrent(message.subscriptionId, token)) {
263
+ querySubscriptions.unsubscribe(message.subscriptionId)
258
264
  postQueryDataSourceResult({
259
265
  subscriptionId: message.subscriptionId,
260
266
  response: { status: "error", error: queryError },
@@ -266,6 +272,9 @@ export function createCustomBlockHost(
266
272
  if (!querySubscriptions.isCurrent(message.subscriptionId, token)) {
267
273
  return
268
274
  }
275
+ if (response.status === "error" && !response.error.isRetryable) {
276
+ querySubscriptions.unsubscribe(message.subscriptionId)
277
+ }
269
278
  postQueryDataSourceResult({
270
279
  subscriptionId: message.subscriptionId,
271
280
  response,
@@ -348,7 +357,7 @@ export function createCustomBlockHost(
348
357
  onInitialized?.({ manifest, initialHeight: message.initialHeight })
349
358
  }
350
359
  },
351
- onFailure,
360
+ onConnectionFailure,
352
361
  })
353
362
 
354
363
  function prepareInitialState(
@@ -431,7 +440,7 @@ export function createCustomBlockHost(
431
440
  function stopWithFailure(error: CustomBlockHostFailure) {
432
441
  stop()
433
442
  emit("warn", error)
434
- onFailure?.(error)
443
+ onConnectionFailure?.(error)
435
444
  }
436
445
 
437
446
  return {
@@ -33,7 +33,7 @@ export type InitializationControllerOptions = {
33
33
  noInitResultTimeoutMs?: number
34
34
  stopHostWithFailure: (error: CustomBlockHostFailure) => void
35
35
  onInitResult?: (message: InitResultMessage) => void
36
- onFailure?: (error: CustomBlockHostFailure) => void
36
+ onConnectionFailure: ((error: CustomBlockHostFailure) => void) | undefined
37
37
  }
38
38
 
39
39
  export type InitializationController = {
@@ -68,7 +68,7 @@ export function createInitializationController(
68
68
  noInitResultTimeoutMs = DEFAULT_NO_INIT_RESULT_TIMEOUT_MS,
69
69
  stopHostWithFailure,
70
70
  onInitResult,
71
- onFailure,
71
+ onConnectionFailure,
72
72
  } = options
73
73
 
74
74
  let initStatus: InitStatus = "waitingForConnect"
@@ -127,7 +127,7 @@ export function createInitializationController(
127
127
  status: "error",
128
128
  error,
129
129
  })
130
- onFailure?.(error)
130
+ onConnectionFailure?.(error)
131
131
  }
132
132
 
133
133
  async function prepareAndSendInit(connect: ConnectSuccessMessage) {
@@ -184,7 +184,7 @@ export function createInitializationController(
184
184
  }
185
185
  initStatus = "error"
186
186
  const error = initErrorForFailureReason("no_init_result")
187
- onFailure?.(error)
187
+ onConnectionFailure?.(error)
188
188
  warn({
189
189
  ...error,
190
190
  initializationId: connect.initializationId,
@@ -301,7 +301,7 @@ export function createInitializationController(
301
301
  clearNoInitResultTimeout()
302
302
  initStatus = "error"
303
303
  warn(error)
304
- onFailure?.(error)
304
+ onConnectionFailure?.(error)
305
305
  }
306
306
 
307
307
  function onIframeLoad() {
@@ -331,7 +331,7 @@ export function createInitializationController(
331
331
  initStatus = "error"
332
332
  const error = initErrorForFailureReason("no_connect")
333
333
  warn(error)
334
- onFailure?.(error)
334
+ onConnectionFailure?.(error)
335
335
  }, noConnectTimeoutMs)
336
336
  }
337
337
 
@@ -351,7 +351,7 @@ export function createInitializationController(
351
351
  if (message.status === "success") {
352
352
  flushPendingHostStateChanges()
353
353
  } else {
354
- onFailure?.(message.error)
354
+ onConnectionFailure?.(message.error)
355
355
  }
356
356
  onInitResult?.(message)
357
357
  }
@@ -20,7 +20,12 @@ type QuerySubscriptionState = {
20
20
  export class QuerySubscriptions {
21
21
  private readonly bySubscriptionId = new Map<string, QuerySubscriptionState>()
22
22
 
23
+ constructor(
24
+ private readonly onUnsubscribe: (subscriptionId: string) => void,
25
+ ) {}
26
+
23
27
  subscribe(message: QueryDataSourceMessage): QuerySubscriptionToken {
28
+ this.unsubscribe(message.subscriptionId)
24
29
  const token: QuerySubscriptionToken = {
25
30
  _tag: "QuerySubscriptionToken",
26
31
  }
@@ -38,7 +43,9 @@ export class QuerySubscriptions {
38
43
  }
39
44
 
40
45
  unsubscribe(subscriptionId: string): void {
41
- this.bySubscriptionId.delete(subscriptionId)
46
+ if (this.bySubscriptionId.delete(subscriptionId)) {
47
+ this.onUnsubscribe(subscriptionId)
48
+ }
42
49
  }
43
50
 
44
51
  refresh(dataSourceId: NotionDataSourceId): QueryRefresh[] | undefined {
@@ -80,6 +87,8 @@ export class QuerySubscriptions {
80
87
  }
81
88
 
82
89
  unsubscribeAll() {
83
- this.bySubscriptionId.clear()
90
+ for (const subscriptionId of this.bySubscriptionId.keys()) {
91
+ this.unsubscribe(subscriptionId)
92
+ }
84
93
  }
85
94
  }