@remit/backend 0.0.69 → 0.0.71

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/backend",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "description": "Remit Mail Inspector API backend",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -1,11 +1,11 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { describe, it } from "node:test";
3
- import type { SemanticSearchResult } from "@remit/api-openapi-types";
4
3
  import type {
5
4
  SearchParams,
6
5
  SearchResult,
7
6
  SearchService,
8
7
  } from "@remit/search-service";
8
+ import { toResponse } from "./search.js";
9
9
 
10
10
  interface CapturedSearch {
11
11
  calls: SearchParams[];
@@ -29,27 +29,6 @@ const buildFakeSearch = (
29
29
  return { service, captured };
30
30
  };
31
31
 
32
- const toResponse = (item: SearchResult): SemanticSearchResult => {
33
- const result: SemanticSearchResult = {
34
- messageId: item.messageId,
35
- threadId: item.threadId,
36
- score: item.score,
37
- matchedChunkType: item.matchedChunkType,
38
- mailboxIds: item.mailboxIds,
39
- sentDate: item.sentDate,
40
- };
41
- if (item.fromName !== undefined) {
42
- result.fromName = item.fromName ?? undefined;
43
- }
44
- if (item.subject !== undefined) {
45
- result.subject = item.subject;
46
- }
47
- if (item.category !== undefined) {
48
- result.category = item.category;
49
- }
50
- return result;
51
- };
52
-
53
32
  describe("SemanticSearch handler response mapping", () => {
54
33
  it("maps SearchResult into SemanticSearchResult preserving all fields", () => {
55
34
  const item: SearchResult = {
@@ -15,7 +15,7 @@ import type { OperationHandler, SemanticSearchOperationIds } from "../types.js";
15
15
 
16
16
  const DEFAULT_LIMIT = 25;
17
17
 
18
- const toResponse = (item: SearchResult): SemanticSearchResult => {
18
+ export const toResponse = (item: SearchResult): SemanticSearchResult => {
19
19
  const result: SemanticSearchResult = {
20
20
  messageId: item.messageId,
21
21
  threadId: item.threadId,
@@ -341,4 +341,26 @@ describe("POST /system/update", () => {
341
341
  assert.ok(!(forbidden in request));
342
342
  }
343
343
  });
344
+
345
+ it("stamps requestedAt with the moment of the request, in UTC", async () => {
346
+ // The updater installs a request only while it is still current (#587), so
347
+ // requestedAt is the field that decides it. A missing, fixed or non-UTC
348
+ // stamp would make every request expire on arrival.
349
+ writeState(okState);
350
+ const before = Date.now();
351
+
352
+ await applyUpdate("v1.5.0", buildEvent(USER));
353
+
354
+ const after = Date.now();
355
+ const request = JSON.parse(
356
+ readFileSync(join(controlDir, "request.json"), "utf8"),
357
+ ) as { requestedAt: string };
358
+
359
+ assert.match(
360
+ request.requestedAt,
361
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/,
362
+ );
363
+ const stamped = Date.parse(request.requestedAt);
364
+ assert.ok(stamped >= before - 1000 && stamped <= after + 1000);
365
+ });
344
366
  });