roam-research-mcp 5.0.0 → 5.0.1
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.
|
@@ -16,31 +16,34 @@ export class StatusSearchHandler extends BaseSearchHandler {
|
|
|
16
16
|
// Build query based on whether we're searching in a specific page
|
|
17
17
|
let queryStr;
|
|
18
18
|
let queryParams;
|
|
19
|
-
//
|
|
19
|
+
// Match both formats: {{[[TODO]]}} does not contain "{{TODO", so each needs its own marker
|
|
20
|
+
const [bracketed, bare] = SearchUtils.statusMarkers(status);
|
|
20
21
|
if (targetPageUid) {
|
|
21
22
|
queryStr = `[:find ?block-uid ?block-str ?page-title ?block-create-time ?block-edit-time
|
|
22
|
-
:in $ ?
|
|
23
|
+
:in $ ?bracketed ?bare ?page-uid
|
|
23
24
|
:where [?p :block/uid ?page-uid]
|
|
24
25
|
[?p :node/title ?page-title]
|
|
25
26
|
[?b :block/page ?p]
|
|
26
27
|
[?b :block/string ?block-str]
|
|
27
28
|
[?b :block/uid ?block-uid]
|
|
28
|
-
[(clojure.string/includes? ?block-str
|
|
29
|
+
(or [(clojure.string/includes? ?block-str ?bracketed)]
|
|
30
|
+
[(clojure.string/includes? ?block-str ?bare)])
|
|
29
31
|
[(get-else $ ?b :create/time 0) ?block-create-time]
|
|
30
32
|
[(get-else $ ?b :edit/time 0) ?block-edit-time]]`;
|
|
31
|
-
queryParams = [
|
|
33
|
+
queryParams = [bracketed, bare, targetPageUid];
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
36
|
queryStr = `[:find ?block-uid ?block-str ?page-title ?block-create-time ?block-edit-time
|
|
35
|
-
:in $ ?
|
|
37
|
+
:in $ ?bracketed ?bare
|
|
36
38
|
:where [?b :block/string ?block-str]
|
|
37
39
|
[?b :block/uid ?block-uid]
|
|
38
40
|
[?b :block/page ?p]
|
|
39
41
|
[?p :node/title ?page-title]
|
|
40
|
-
[(clojure.string/includes? ?block-str
|
|
42
|
+
(or [(clojure.string/includes? ?block-str ?bracketed)]
|
|
43
|
+
[(clojure.string/includes? ?block-str ?bare)])
|
|
41
44
|
[(get-else $ ?b :create/time 0) ?block-create-time]
|
|
42
45
|
[(get-else $ ?b :edit/time 0) ?block-edit-time]]`;
|
|
43
|
-
queryParams = [
|
|
46
|
+
queryParams = [bracketed, bare];
|
|
44
47
|
}
|
|
45
48
|
const rawResults = await q(this.graph, queryStr, queryParams);
|
|
46
49
|
// Resolve block references in content
|
package/build/search/utils.js
CHANGED
|
@@ -174,4 +174,12 @@ export class SearchUtils {
|
|
|
174
174
|
const clauses = variations.map(t => `[${variable} :node/title "${t}"]`);
|
|
175
175
|
return `(or ${clauses.join(' ')})`;
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* The two spellings of a status marker: `{{[[TODO]]}}` (what Roam's checkbox
|
|
179
|
+
* writes) and the bare `{{TODO}}`. Neither contains the other, so a search
|
|
180
|
+
* must test for both.
|
|
181
|
+
*/
|
|
182
|
+
static statusMarkers(status) {
|
|
183
|
+
return [`{{[[${status}]]}}`, `{{${status}`];
|
|
184
|
+
}
|
|
177
185
|
}
|