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

Method normalizeRuntimeCondition

src/api/TaskNotesAPI.ts:1298–1362  ·  view source on GitHub ↗
(
		condition: Record<string, unknown>,
		path: string,
		issues: TaskNotesRuntimeQueryIssue[]
	)

Source from the content-addressed store, hash-verified

1296 }
1297
1298 private normalizeRuntimeCondition(
1299 condition: Record<string, unknown>,
1300 path: string,
1301 issues: TaskNotesRuntimeQueryIssue[]
1302 ): TaskNotesRuntimeNormalizedCondition | undefined {
1303 if (typeof condition["field"] !== "string" || condition["field"].trim().length === 0) {
1304 issues.push({
1305 path: `${path}.field`,
1306 code: "field_required",
1307 message: "Runtime query condition requires a field.",
1308 });
1309 return undefined;
1310 }
1311 const field = this.resolveRuntimeQueryField(condition["field"]);
1312 if (!field) {
1313 issues.push({
1314 path: `${path}.field`,
1315 code: "field_unknown",
1316 message: `Unsupported runtime query field: ${condition["field"]}`,
1317 });
1318 return undefined;
1319 }
1320
1321 const op = normalizeRuntimeOperator(condition["op"]);
1322 if (!op) {
1323 issues.push({
1324 path: `${path}.op`,
1325 code: "operator_unknown",
1326 message: `Unsupported runtime query operator: ${String(condition["op"])}`,
1327 });
1328 return undefined;
1329 }
1330 if (!field.definition.supportedOperators.includes(op)) {
1331 issues.push({
1332 path: `${path}.op`,
1333 code: "operator_unsupported",
1334 message: `Operator ${op} is not supported for ${field.definition.id}.`,
1335 });
1336 return undefined;
1337 }
1338
1339 const requiresValue = runtimeOperatorRequiresValue(op);
1340 if (requiresValue && typeof condition["value"] === "undefined") {
1341 issues.push({
1342 path: `${path}.value`,
1343 code: "value_required",
1344 message: `Operator ${op} requires a value.`,
1345 });
1346 return undefined;
1347 }
1348 if ((op === "in" || op === "notIn") && !Array.isArray(condition["value"])) {
1349 issues.push({
1350 path: `${path}.value`,
1351 code: "value_array_required",
1352 message: `Operator ${op} requires an array value.`,
1353 });
1354 return undefined;
1355 }

Callers 1

Calls 4

normalizeRuntimeOperatorFunction · 0.85
normalizeRuntimeValueFunction · 0.85

Tested by

no test coverage detected