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

Method normalizeRuntimeGroups

src/api/TaskNotesAPI.ts:1413–1459  ·  view source on GitHub ↗
(
		value: unknown,
		issues: TaskNotesRuntimeQueryIssue[],
		warnings: TaskNotesRuntimeQueryWarning[]
	)

Source from the content-addressed store, hash-verified

1411 }
1412
1413 private normalizeRuntimeGroups(
1414 value: unknown,
1415 issues: TaskNotesRuntimeQueryIssue[],
1416 warnings: TaskNotesRuntimeQueryWarning[]
1417 ): TaskNotesRuntimeNormalizedTaskQuery["group"] {
1418 if (typeof value === "undefined") return [];
1419 if (!Array.isArray(value)) {
1420 issues.push({
1421 path: "$.group",
1422 code: "group_not_array",
1423 message: "Runtime query group must be an array.",
1424 });
1425 return [];
1426 }
1427
1428 const groups = value
1429 .map((entry, index): TaskNotesRuntimeNormalizedTaskQuery["group"][number] | null => {
1430 if (!isRecord(entry) || typeof entry["field"] !== "string") {
1431 issues.push({
1432 path: `$.group.${index}`,
1433 code: "group_invalid",
1434 message: "Runtime query group entries require a field.",
1435 });
1436 return null;
1437 }
1438 const field = this.resolveRuntimeQueryField(entry["field"]);
1439 if (!field || !field.definition.groupable) {
1440 issues.push({
1441 path: `$.group.${index}.field`,
1442 code: "group_field_unsupported",
1443 message: `Runtime query field is not groupable: ${entry["field"]}`,
1444 });
1445 return null;
1446 }
1447 return { field: field.definition.id };
1448 })
1449 .filter(isDefined);
1450
1451 if (groups.length > 1) {
1452 warnings.push({
1453 path: "$.group",
1454 code: "multiple_groups",
1455 message: "Only the first group is currently applied by TaskNotes.",
1456 });
1457 }
1458 return groups;
1459 }
1460
1461 private runtimeQueryToFilterQuery(
1462 query: TaskNotesRuntimeNormalizedTaskQuery,

Callers 1

Calls 2

isRecordFunction · 0.70

Tested by

no test coverage detected