Comparing version 1.5.0 to 1.6.0
@@ -149,2 +149,3 @@ export declare interface AccessAttributeNode extends BaseNode { | ||
* Evaluates a query. | ||
* @internal | ||
*/ | ||
@@ -177,3 +178,6 @@ export declare function evaluate( | ||
/** A node which can be evaluated into a value. */ | ||
/** | ||
* A node which can be evaluated into a value. | ||
* @public | ||
*/ | ||
export declare type ExprNode = | ||
@@ -233,2 +237,3 @@ | AccessAttributeNode | ||
/** @public */ | ||
export declare type GroqFunction = ( | ||
@@ -240,2 +245,3 @@ args: GroqFunctionArg[], | ||
/** @public */ | ||
export declare type GroqFunctionArg = ExprNode | ||
@@ -242,0 +248,0 @@ |
{ | ||
"name": "groq-js", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"keywords": [ | ||
@@ -18,23 +18,13 @@ "sanity", | ||
"type": "commonjs", | ||
"Exports": { | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"source": "./src/1.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js", | ||
"node": { | ||
"module": "./dist/index.mjs", | ||
"import": "./dist/index.cjs.mjs" | ||
}, | ||
"import": "./dist/index.mjs", | ||
"default": "./dist/index.js" | ||
}, | ||
"./1": { | ||
"types": "./dist/1.d.ts", | ||
"source": "./src/1.ts", | ||
"import": "./dist/1.mjs", | ||
"require": "./dist/1.js", | ||
"node": { | ||
"module": "./dist/1.mjs", | ||
"import": "./dist/1.cjs.mjs" | ||
}, | ||
"import": "./dist/1.mjs", | ||
"default": "./dist/1.js" | ||
@@ -58,3 +48,2 @@ }, | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
@@ -85,8 +74,8 @@ "dist", | ||
"devDependencies": { | ||
"@sanity/pkg-utils": "^5.0.4", | ||
"@sanity/pkg-utils": "^5.1.5", | ||
"@sanity/semantic-release-preset": "^4.1.7", | ||
"@types/debug": "^4.1.12", | ||
"@types/tap": "^15.0.11", | ||
"@typescript-eslint/eslint-plugin": "^7.3.0", | ||
"@typescript-eslint/parser": "^7.3.0", | ||
"@typescript-eslint/eslint-plugin": "^7.5.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"eslint": "^8.57.0", | ||
@@ -99,3 +88,3 @@ "eslint-config-prettier": "^9.1.0", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-packagejson": "^2.4.12", | ||
"prettier-plugin-packagejson": "^2.4.14", | ||
"rimraf": "^5.0.0", | ||
@@ -102,0 +91,0 @@ "semver": "^7.5.4", |
@@ -460,2 +460,3 @@ import {ExprNode, FuncCallNode, PipeFuncCallNode} from '../nodeTypes' | ||
* Evaluates a query. | ||
* @internal | ||
*/ | ||
@@ -462,0 +463,0 @@ export function evaluateQuery( |
@@ -62,2 +62,3 @@ import type {ExprNode} from '../nodeTypes' | ||
/** @public */ | ||
export type GroqFunctionArg = ExprNode | ||
@@ -71,2 +72,3 @@ type WithOptions<T> = T & { | ||
/** @public */ | ||
export type GroqFunction = ( | ||
@@ -73,0 +75,0 @@ args: GroqFunctionArg[], |
@@ -1,2 +0,2 @@ | ||
import {GroqFunction, GroqPipeFunction} from './evaluator/functions' | ||
import type {GroqFunction, GroqPipeFunction} from './evaluator/functions' | ||
@@ -11,3 +11,6 @@ /** Any sort of node which appears as syntax */ | ||
/** A node which can be evaluated into a value. */ | ||
/** | ||
* A node which can be evaluated into a value. | ||
* @public | ||
*/ | ||
export type ExprNode = | ||
@@ -14,0 +17,0 @@ | AccessAttributeNode |
@@ -21,2 +21,3 @@ import debug from 'debug' | ||
MapNode, | ||
NegNode, | ||
NotNode, | ||
@@ -26,2 +27,3 @@ ObjectNode, | ||
ParentNode, | ||
PosNode, | ||
ProjectionNode, | ||
@@ -588,2 +590,20 @@ SelectNode, | ||
function handleNegNode(node: NegNode, scope: Scope): NumberTypeNode | NullTypeNode { | ||
const base = walk({node: node.base, scope}) | ||
if (base.type !== 'number') { | ||
return {type: 'null'} | ||
} | ||
if (base.value !== undefined) { | ||
return {type: 'number', value: -base.value} | ||
} | ||
return base | ||
} | ||
function handlePosNode(node: PosNode, scope: Scope): NumberTypeNode | NullTypeNode { | ||
const base = walk({node: node.base, scope}) | ||
if (base.type !== 'number') { | ||
return {type: 'null'} | ||
} | ||
return base | ||
} | ||
function handleEverythingNode(_: EverythingNode, scope: Scope): TypeNode { | ||
@@ -719,7 +739,11 @@ return { | ||
} | ||
case 'Neg': { | ||
return handleNegNode(node, scope) | ||
} | ||
case 'Pos': { | ||
return handlePosNode(node, scope) | ||
} | ||
// everything else | ||
case 'Asc': | ||
case 'Desc': | ||
case 'Neg': | ||
case 'Pos': | ||
case 'Context': | ||
@@ -726,0 +750,0 @@ case 'Tuple': |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
875890
50
12411
3