feeds-fun 1.26.0 → 1.27.0
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 +1 -1
- package/src/logic/enums.ts +5 -3
- package/src/logic/tests/types.test.ts +30 -0
- package/src/logic/types.ts +2 -2
package/package.json
CHANGED
package/src/logic/enums.ts
CHANGED
|
@@ -148,11 +148,13 @@ export const MinNewsTagCountProperties = new Map<MinNewsTagCount, MinNewsTagCoun
|
|
|
148
148
|
/////////
|
|
149
149
|
|
|
150
150
|
export enum Marker {
|
|
151
|
-
Read =
|
|
151
|
+
Read = 1,
|
|
152
|
+
CanSeeTags = 2
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
export const reverseMarker: {[key:
|
|
155
|
-
|
|
155
|
+
export const reverseMarker: {[key: number]: Marker} = {
|
|
156
|
+
[Marker.Read]: Marker.Read,
|
|
157
|
+
[Marker.CanSeeTags]: Marker.CanSeeTags
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
/////////////////////
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {describe, expect, it} from "vitest";
|
|
2
|
+
|
|
3
|
+
import * as e from "@/logic/enums";
|
|
4
|
+
import {entryFromJSON, type RawEntry} from "@/logic/types";
|
|
5
|
+
|
|
6
|
+
function rawEntry(markers: number[]): RawEntry {
|
|
7
|
+
return {
|
|
8
|
+
id: "ed278ccf-f8e3-4e8b-b065-1ad120444b47",
|
|
9
|
+
feedId: "dca40ac1-73da-49dc-b7d8-40dac312ae40",
|
|
10
|
+
title: "Entry",
|
|
11
|
+
url: "https://example.com/entry",
|
|
12
|
+
tags: [],
|
|
13
|
+
markers,
|
|
14
|
+
score: 0,
|
|
15
|
+
scoreContributions: {},
|
|
16
|
+
publishedAt: "2026-05-11T12:00:00Z"
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("entryFromJSON", () => {
|
|
21
|
+
it("translates integer markers to frontend enum values", () => {
|
|
22
|
+
const entry = entryFromJSON(rawEntry([1, 2]), {});
|
|
23
|
+
|
|
24
|
+
expect(entry.markers).toEqual([e.Marker.Read, e.Marker.CanSeeTags]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("rejects unknown integer markers", () => {
|
|
28
|
+
expect(() => entryFromJSON(rawEntry([100]), {})).toThrow("Unknown marker: 100");
|
|
29
|
+
});
|
|
30
|
+
});
|
package/src/logic/types.ts
CHANGED
|
@@ -290,7 +290,7 @@ export type RawEntry = {
|
|
|
290
290
|
title: string;
|
|
291
291
|
url: string;
|
|
292
292
|
tags: number[];
|
|
293
|
-
markers:
|
|
293
|
+
markers: number[];
|
|
294
294
|
score: number;
|
|
295
295
|
scoreContributions: {[key: number]: number};
|
|
296
296
|
publishedAt: string;
|
|
@@ -311,7 +311,7 @@ export function entryFromJSON(rawEntry: RawEntry, tagsMapping: {[key: number]: s
|
|
|
311
311
|
title: rawEntry.title,
|
|
312
312
|
url: toURL(rawEntry.url),
|
|
313
313
|
tags: rawEntry.tags.map((t: number) => tagsMapping[t]),
|
|
314
|
-
markers: rawEntry.markers.map((m:
|
|
314
|
+
markers: rawEntry.markers.map((m: number) => {
|
|
315
315
|
if (m in e.reverseMarker) {
|
|
316
316
|
return e.reverseMarker[m];
|
|
317
317
|
}
|