From ea77e7e36a5835e86836dbfa5171580249406e16 Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Wed, 6 Sep 2023 13:23:05 +0200 Subject: [PATCH] feat: expose `namespace` on FuncCall node (fixes #145) --- src/nodeTypes.ts | 1 + src/parser.ts | 1 + tap-snapshots/test/parse.test.ts.test.cjs | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/nodeTypes.ts b/src/nodeTypes.ts index 346a0ed1..edf9a67d 100644 --- a/src/nodeTypes.ts +++ b/src/nodeTypes.ts @@ -113,6 +113,7 @@ export interface EverythingNode extends BaseNode { export interface FuncCallNode extends BaseNode { type: 'FuncCall' func: GroqFunction + namespace: string name: string args: ExprNode[] } diff --git a/src/parser.ts b/src/parser.ts index 6610c591..63650581 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -411,6 +411,7 @@ const EXPR_BUILDER: MarkVisitor = { return { type: 'FuncCall', func, + namespace, name, args, } diff --git a/tap-snapshots/test/parse.test.ts.test.cjs b/tap-snapshots/test/parse.test.ts.test.cjs index 8c9b101c..d9a14b07 100644 --- a/tap-snapshots/test/parse.test.ts.test.cjs +++ b/tap-snapshots/test/parse.test.ts.test.cjs @@ -64,6 +64,7 @@ Object { ], "func": AsyncFunction path(args, scope, execute), "name": "path", + "namespace": "global", "type": "FuncCall", }, "type": "OpCall", @@ -103,11 +104,13 @@ Object { ], "func": AsyncFunction (args, scope, execute), "name": "unique", + "namespace": "array", "type": "FuncCall", }, ], "func": AsyncFunction count(args, scope, execute), "name": "count", + "namespace": "global", "type": "FuncCall", } `