MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / runtimeQueryToFilterQuery

Method runtimeQueryToFilterQuery

src/api/TaskNotesAPI.ts:1461–1509  ·  view source on GitHub ↗
(
		query: TaskNotesRuntimeNormalizedTaskQuery,
		issues: TaskNotesRuntimeQueryIssue[],
		warnings: TaskNotesRuntimeQueryWarning[]
	)

Source from the content-addressed store, hash-verified

1459 }
1460
1461 private runtimeQueryToFilterQuery(
1462 query: TaskNotesRuntimeNormalizedTaskQuery,
1463 issues: TaskNotesRuntimeQueryIssue[],
1464 warnings: TaskNotesRuntimeQueryWarning[]
1465 ): FilterQuery {
1466 const root = this.runtimePredicateToFilterNode(query.where, "$.where", issues);
1467 const children = root
1468 ? root.type === "group" && root.conjunction === "and"
1469 ? root.children
1470 : [root]
1471 : [];
1472 const filterQuery: FilterQuery = {
1473 type: "group",
1474 id: "runtime-query-root",
1475 conjunction: "and",
1476 children,
1477 };
1478
1479 const sort = query.sort[0];
1480 if (sort) {
1481 const sortKey = this.runtimeFieldToSortKey(sort.field);
1482 if (sortKey) {
1483 filterQuery.sortKey = sortKey;
1484 filterQuery.sortDirection = sort.direction ?? "asc";
1485 } else {
1486 warnings.push({
1487 path: "$.sort.0.field",
1488 code: "sort_not_applied",
1489 message: `Sort field ${sort.field} could not be mapped to TaskNotes sorting.`,
1490 });
1491 }
1492 }
1493
1494 const group = query.group[0];
1495 if (group) {
1496 const groupKey = this.runtimeFieldToGroupKey(group.field);
1497 if (groupKey) {
1498 filterQuery.groupKey = groupKey;
1499 } else {
1500 warnings.push({
1501 path: "$.group.0.field",
1502 code: "group_not_applied",
1503 message: `Group field ${group.field} could not be mapped to TaskNotes grouping.`,
1504 });
1505 }
1506 }
1507
1508 return filterQuery;
1509 }
1510
1511 private runtimePredicateToFilterNode(
1512 predicate: TaskNotesRuntimeNormalizedPredicate | undefined,

Callers 1

Calls 3

runtimeFieldToSortKeyMethod · 0.95

Tested by

no test coverage detected