MCPcopy Create free account
hub / github.com/codemix/graph / projectPath

Method projectPath

packages/graph/src/Steps.ts:6849–6897  ·  view source on GitHub ↗
(
    path: TraversalPath<any, any, any>,
    items: readonly WithItemConfig[],
    context?: QueryContext,
  )

Source from the content-addressed store, hash-verified

6847 }
6848
6849 protected projectPath(
6850 path: TraversalPath<any, any, any>,
6851 items: readonly WithItemConfig[],
6852 context?: QueryContext,
6853 ): TraversalPath<any, any, any> | undefined {
6854 // Start a new path with the first item's value
6855 let newPath: TraversalPath<any, any, any> | undefined;
6856
6857 for (const item of items) {
6858 let value: any;
6859
6860 switch (item.type) {
6861 case "variable": {
6862 const pathNode = path.get(item.sourceVariable);
6863 if (!pathNode) return undefined; // Variable not found
6864 value = pathNode.value;
6865 break;
6866 }
6867 case "property": {
6868 const pathNode = path.get(item.sourceVariable);
6869 if (!pathNode) return undefined;
6870 value = pathNode.property(item.property as never);
6871 break;
6872 }
6873 case "aggregate":
6874 // Aggregates are handled separately in computeAggregates
6875 continue;
6876 case "functionCall": {
6877 // Evaluate function call
6878 const resolvedArgs = item.args.map((arg) => resolveConditionValue(path, arg, context));
6879 value = evaluateFunction(item.functionName, resolvedArgs, path, item.distinct);
6880 break;
6881 }
6882 case "expression": {
6883 // Evaluate arbitrary expression (e.g., list literals)
6884 value = resolveConditionValue(path, item.value, context);
6885 break;
6886 }
6887 }
6888
6889 if (!newPath) {
6890 newPath = new TraversalPath(undefined, value, [item.alias]);
6891 } else {
6892 newPath = newPath.with(value, [item.alias]);
6893 }
6894 }
6895
6896 return newPath;
6897 }
6898
6899 protected computeAggregates(
6900 paths: readonly TraversalPath<any, any, any>[],

Callers 1

traverseMethod · 0.95

Calls 6

resolveConditionValueFunction · 0.85
evaluateFunctionFunction · 0.85
withMethod · 0.80
getMethod · 0.65
propertyMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected