@remit/web-client 0.0.284 → 0.0.285

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client",
3
- "version": "0.0.284",
3
+ "version": "0.0.285",
4
4
  "type": "module",
5
5
  "description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
6
6
  "exports": {
@@ -78,6 +78,7 @@ export const useRulePreview = (
78
78
  setState({
79
79
  count: response.matchedCount,
80
80
  matchedIds: response.messageIds,
81
+ indexEmpty: response.semanticIndexEmpty === true,
81
82
  previewedSignature: signature,
82
83
  });
83
84
  })
@@ -276,6 +276,36 @@ describe("derivePreview", () => {
276
276
  );
277
277
  });
278
278
 
279
+ it("carries the empty-index answer through, so a zero can say why (#452)", () => {
280
+ assert.deepEqual(
281
+ derivePreview(
282
+ { count: 0, indexEmpty: true, previewedSignature: signature },
283
+ signature,
284
+ ),
285
+ { status: "ready", count: 0, indexEmpty: true },
286
+ );
287
+ });
288
+
289
+ it("keeps the empty-index answer on a stale count", () => {
290
+ assert.deepEqual(
291
+ derivePreview(
292
+ { count: 0, indexEmpty: true, previewedSignature: "sig-old" },
293
+ signature,
294
+ ),
295
+ { status: "ready", count: 0, stale: true, indexEmpty: true },
296
+ );
297
+ });
298
+
299
+ it("leaves the flag off when the index answered", () => {
300
+ assert.deepEqual(
301
+ derivePreview(
302
+ { count: 0, indexEmpty: false, previewedSignature: signature },
303
+ signature,
304
+ ),
305
+ { status: "ready", count: 0 },
306
+ );
307
+ });
308
+
279
309
  it("surfaces an error raised for the current predicate", () => {
280
310
  assert.deepEqual(
281
311
  derivePreview(
@@ -253,6 +253,8 @@ export interface PreviewState {
253
253
  count?: number;
254
254
  /** The ids that count was counted over, as the server bounded them. */
255
255
  matchedIds?: readonly string[];
256
+ /** The server said the semantic index had nothing to answer with (#452). */
257
+ indexEmpty?: boolean;
256
258
  /** The signature the {@link count} was counted for. */
257
259
  previewedSignature?: string;
258
260
  /** The signature the last error was raised for. */
@@ -274,10 +276,11 @@ export const derivePreview = (
274
276
  return { status: "error", reason: state.error };
275
277
  }
276
278
  if (state.count === undefined) return { status: "loading" };
279
+ const indexEmpty = state.indexEmpty === true ? { indexEmpty: true } : {};
277
280
  if (state.previewedSignature === currentSignature) {
278
- return { status: "ready", count: state.count };
281
+ return { status: "ready", count: state.count, ...indexEmpty };
279
282
  }
280
- return { status: "ready", count: state.count, stale: true };
283
+ return { status: "ready", count: state.count, stale: true, ...indexEmpty };
281
284
  };
282
285
 
283
286
  /** How long a rule change settles before the next preview fires. */