feedkeeper 0.45.0 → 0.46.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/server/dist/api/feeds.js +37 -2
- package/server/dist/api/items.js +25 -1
- package/server/dist/api/v1/resources.js +53 -7
- package/server/dist/api/v1/serialize.js +3 -1
- package/server/dist/db/migrations/0049_media_positions_and_feed_moves.sql +13 -0
- package/server/dist/feeds/fetcher.js +26 -3
- package/server/dist/feeds/mediaPosition.js +56 -0
- package/server/dist/feeds/poller.js +60 -11
- package/server/dist/feeds/repository.js +20 -9
- package/server/dist/feeds/searchQuery.js +101 -0
- package/server/package.json +1 -1
- package/web/dist/assets/index-C-Cqi_Uh.js +113 -0
- package/web/dist/assets/index-CAofPYDH.css +2 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-BSInpowW.js +0 -113
- package/web/dist/assets/index-Cq-H4L1-.css +0 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const TOKEN_RE = /(\w+:"[^"]*"|\w+:[^\s]+|\S+)/g;
|
|
2
|
+
/**
|
|
3
|
+
* Splits a search query into structured filter operators (`has:audio`, `has:video`,
|
|
4
|
+
* `has:notes`, `has:media`, `is:unread`, `is:read`, `is:starred`, `feed:...`)
|
|
5
|
+
* and the remaining free-text search string.
|
|
6
|
+
*/
|
|
7
|
+
export function parseSearchQuery(raw) {
|
|
8
|
+
const result = {
|
|
9
|
+
textQuery: "",
|
|
10
|
+
hasAudio: false,
|
|
11
|
+
hasVideo: false,
|
|
12
|
+
hasMedia: false,
|
|
13
|
+
hasNotes: false,
|
|
14
|
+
readState: null,
|
|
15
|
+
starredOnly: false,
|
|
16
|
+
feedTerms: [],
|
|
17
|
+
hasOperators: false,
|
|
18
|
+
};
|
|
19
|
+
const textParts = [];
|
|
20
|
+
const tokens = raw.trim().match(TOKEN_RE) ?? [];
|
|
21
|
+
for (const token of tokens) {
|
|
22
|
+
const lower = token.toLowerCase();
|
|
23
|
+
if (lower === "has:audio") {
|
|
24
|
+
result.hasAudio = true;
|
|
25
|
+
result.hasOperators = true;
|
|
26
|
+
}
|
|
27
|
+
else if (lower === "has:video") {
|
|
28
|
+
result.hasVideo = true;
|
|
29
|
+
result.hasOperators = true;
|
|
30
|
+
}
|
|
31
|
+
else if (lower === "has:media") {
|
|
32
|
+
result.hasMedia = true;
|
|
33
|
+
result.hasOperators = true;
|
|
34
|
+
}
|
|
35
|
+
else if (lower === "has:notes" || lower === "has:note") {
|
|
36
|
+
result.hasNotes = true;
|
|
37
|
+
result.hasOperators = true;
|
|
38
|
+
}
|
|
39
|
+
else if (lower === "is:unread") {
|
|
40
|
+
result.readState = "unread";
|
|
41
|
+
result.hasOperators = true;
|
|
42
|
+
}
|
|
43
|
+
else if (lower === "is:read") {
|
|
44
|
+
result.readState = "read";
|
|
45
|
+
result.hasOperators = true;
|
|
46
|
+
}
|
|
47
|
+
else if (lower === "is:starred" || lower === "is:bookmarked" || lower === "is:saved") {
|
|
48
|
+
result.starredOnly = true;
|
|
49
|
+
result.hasOperators = true;
|
|
50
|
+
}
|
|
51
|
+
else if (lower.startsWith("feed:")) {
|
|
52
|
+
const value = token.slice(5).replace(/^"(.*)"$/, "$1").trim();
|
|
53
|
+
if (value) {
|
|
54
|
+
result.feedTerms.push(value);
|
|
55
|
+
result.hasOperators = true;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
textParts.push(token);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
textParts.push(token);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
result.textQuery = textParts.join(" ").trim();
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/** Appends SQL WHERE conditions for parsed search operators (expects `items i`, `subscriptions s`, `item_reads r`, `item_bookmarks b`). */
|
|
69
|
+
export function appendSearchOperatorConditions(parsed, userId, conditions, params) {
|
|
70
|
+
if (parsed.hasAudio && parsed.hasVideo) {
|
|
71
|
+
conditions.push("i.enclosure_url IS NOT NULL");
|
|
72
|
+
}
|
|
73
|
+
else if (parsed.hasAudio) {
|
|
74
|
+
conditions.push("(i.enclosure_url IS NOT NULL AND (i.enclosure_type IS NULL OR LOWER(i.enclosure_type) NOT LIKE 'video/%'))");
|
|
75
|
+
}
|
|
76
|
+
else if (parsed.hasVideo) {
|
|
77
|
+
conditions.push("(i.enclosure_url IS NOT NULL AND LOWER(i.enclosure_type) LIKE 'video/%')");
|
|
78
|
+
}
|
|
79
|
+
else if (parsed.hasMedia) {
|
|
80
|
+
conditions.push("i.enclosure_url IS NOT NULL");
|
|
81
|
+
}
|
|
82
|
+
if (parsed.hasNotes) {
|
|
83
|
+
conditions.push("i.id IN (SELECT item_id FROM item_notes WHERE user_id = ?)");
|
|
84
|
+
params.push(userId);
|
|
85
|
+
}
|
|
86
|
+
if (parsed.readState === "unread") {
|
|
87
|
+
conditions.push("r.item_id IS NULL");
|
|
88
|
+
}
|
|
89
|
+
else if (parsed.readState === "read") {
|
|
90
|
+
conditions.push("r.item_id IS NOT NULL");
|
|
91
|
+
}
|
|
92
|
+
if (parsed.starredOnly) {
|
|
93
|
+
conditions.push("b.item_id IS NOT NULL");
|
|
94
|
+
}
|
|
95
|
+
for (const term of parsed.feedTerms.slice(0, 3)) {
|
|
96
|
+
const pattern = `%${term.toLowerCase()}%`;
|
|
97
|
+
conditions.push("EXISTS (SELECT 1 FROM feeds f_op WHERE f_op.id = i.feed_id AND (LOWER(COALESCE(NULLIF(TRIM(s.label), ''), NULLIF(TRIM(f_op.title), ''), f_op.url)) LIKE ? OR LOWER(f_op.url) LIKE ?))");
|
|
98
|
+
params.push(pattern, pattern);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=searchQuery.js.map
|