* Resolve a single property value - handles literal values, parameter references, * property access (variable.property), and variable references.
(
value: unknown,
context?: QueryContext,
path?: TraversalPath<any, any, any>,
)
| 426 | * property access (variable.property), and variable references. |
| 427 | */ |
| 428 | protected resolvePropertyValue( |
| 429 | value: unknown, |
| 430 | context?: QueryContext, |
| 431 | path?: TraversalPath<any, any, any>, |
| 432 | ): unknown { |
| 433 | if (value === null || typeof value !== "object" || !("type" in value)) { |
| 434 | return value; |
| 435 | } |
| 436 | |
| 437 | const typedValue = value as { type: string; [key: string]: any }; |
| 438 | |
| 439 | if (typedValue.type === "ParameterRef") { |
| 440 | const params = context?.params ?? getQueryParams(); |
| 441 | return params[typedValue.name as string]; |
| 442 | } |
| 443 | |
| 444 | if (typedValue.type === "PropertyAccess" && path) { |
| 445 | const sourcePath = path.get(typedValue.variable as string); |
| 446 | if (!sourcePath) { |
| 447 | return null; // Variable not found |
| 448 | } |
| 449 | const sourceElement = sourcePath.value; |
| 450 | if (sourceElement instanceof Vertex || sourceElement instanceof Edge) { |
| 451 | return sourceElement.get(typedValue.property as never); |
| 452 | } |
| 453 | // Handle map/object values |
| 454 | if ( |
| 455 | sourceElement !== null && |
| 456 | typeof sourceElement === "object" && |
| 457 | typedValue.property in sourceElement |
| 458 | ) { |
| 459 | return (sourceElement as Record<string, unknown>)[typedValue.property as string]; |
| 460 | } |
| 461 | return null; |
| 462 | } |
| 463 | |
| 464 | if (typedValue.type === "VariableRef" && path) { |
| 465 | const sourcePath = path.get(typedValue.variable as string); |
| 466 | if (!sourcePath) { |
| 467 | return null; // Variable not found |
| 468 | } |
| 469 | return sourcePath.value; |
| 470 | } |
| 471 | |
| 472 | // Handle ListLiteral - recursively resolve values |
| 473 | if (typedValue.type === "ListLiteral") { |
| 474 | const values = typedValue.values as unknown[]; |
| 475 | return values.map((v) => this.resolvePropertyValue(v, context, path)); |
| 476 | } |
| 477 | |
| 478 | return value; |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * Resolve all property values in a properties map, replacing parameter references |
nothing calls this directly
no test coverage detected