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

Function convertWithItem

packages/graph/src/astToSteps.ts:828–902  ·  view source on GitHub ↗

* Convert a WITH item AST node to a WithItemConfig.

(item: WithItem)

Source from the content-addressed store, hash-verified

826 * Convert a WITH item AST node to a WithItemConfig.
827 */
828function convertWithItem(item: WithItem): WithItemConfig {
829 const expr = item.expression;
830
831 // Handle null literal: WITH null AS x
832 if (expr === null) {
833 return {
834 type: "expression",
835 value: { type: "null" },
836 alias: item.alias,
837 };
838 }
839
840 if (expr.type === "VariableRef") {
841 return {
842 type: "variable",
843 sourceVariable: expr.variable,
844 alias: item.alias,
845 };
846 }
847
848 if (expr.type === "PropertyAccess") {
849 return {
850 type: "property",
851 sourceVariable: expr.variable,
852 property: expr.property,
853 alias: item.alias,
854 };
855 }
856
857 if (expr.type === "WithAggregate") {
858 return {
859 type: "aggregate",
860 function: expr.function,
861 sourceVariable: expr.variable,
862 property: expr.property,
863 alias: item.alias,
864 };
865 }
866
867 if (expr.type === "FunctionCall") {
868 // Function calls like type(r), size(list), etc.
869 return {
870 type: "functionCall",
871 functionName: expr.name,
872 args: expr.args.map((arg) => convertConditionValue(arg)),
873 distinct: expr.distinct,
874 alias: item.alias,
875 };
876 }
877
878 if (expr.type === "ListLiteral") {
879 // List literals like [1, 2, 3]
880 return {
881 type: "expression",
882 value: convertConditionValue(expr),
883 alias: item.alias,
884 };
885 }

Callers 1

convertWithClauseFunction · 0.85

Calls 2

convertConditionValueFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected