Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

groq-js

Package Overview
Dependencies
Maintainers
35
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

groq-js - npm Package Compare versions

Comparing version 1.1.4-beta.0 to 1.1.4-beta.1

146

dist/index.d.ts

@@ -1,2 +0,2 @@

declare interface AccessAttributeNode extends BaseNode {
export declare interface AccessAttributeNode extends BaseNode {
type: 'AccessAttribute'

@@ -7,3 +7,3 @@ base?: ExprNode

declare interface AccessElementNode extends BaseNode {
export declare interface AccessElementNode extends BaseNode {
type: 'AccessElement'

@@ -14,3 +14,3 @@ base: ExprNode

declare interface AndNode extends BaseNode {
export declare interface AndNode extends BaseNode {
type: 'And'

@@ -31,3 +31,3 @@ left: ExprNode

declare interface ArrayCoerceNode extends BaseNode {
export declare interface ArrayCoerceNode extends BaseNode {
type: 'ArrayCoerce'

@@ -37,3 +37,3 @@ base: ExprNode

declare interface ArrayElementNode extends BaseNode {
export declare interface ArrayElementNode extends BaseNode {
type: 'ArrayElement'

@@ -44,3 +44,3 @@ value: ExprNode

declare interface ArrayNode extends BaseNode {
export declare interface ArrayNode extends BaseNode {
type: 'Array'

@@ -52,3 +52,3 @@ elements: ArrayElementNode[]

declare interface AscNode extends BaseNode {
export declare interface AscNode extends BaseNode {
type: 'Asc'

@@ -59,3 +59,3 @@ base: ExprNode

/** The base interface for SyntaxNode. */
declare interface BaseNode {
export declare interface BaseNode {
type: string

@@ -77,3 +77,3 @@ }

declare interface ContextNode extends BaseNode {
export declare interface ContextNode extends BaseNode {
type: 'Context'

@@ -97,3 +97,3 @@ key: string

declare interface DerefNode extends BaseNode {
export declare interface DerefNode extends BaseNode {
type: 'Deref'

@@ -103,3 +103,3 @@ base: ExprNode

declare interface DescNode extends BaseNode {
export declare interface DescNode extends BaseNode {
type: 'Desc'

@@ -113,3 +113,3 @@ base: ExprNode

export declare function evaluate(
tree: NodeTypes.ExprNode,
tree: ExprNode,
options?: EvaluateOptions

@@ -132,13 +132,10 @@ ): Value | PromiseLike<Value>

declare interface EverythingNode extends BaseNode {
export declare interface EverythingNode extends BaseNode {
type: 'Everything'
}
export declare type Executor<N = NodeTypes.ExprNode> = (
node: N,
scope: Scope
) => Value | PromiseLike<Value>
export declare type Executor<N = ExprNode> = (node: N, scope: Scope) => Value | PromiseLike<Value>
/** A node which can be evaluated into a value. */
declare type ExprNode =
export declare type ExprNode =
| AccessAttributeNode

@@ -177,3 +174,3 @@ | AccessElementNode

declare interface FilterNode extends BaseNode {
export declare interface FilterNode extends BaseNode {
type: 'Filter'

@@ -184,3 +181,3 @@ base: ExprNode

declare interface FlatMapNode extends BaseNode {
export declare interface FlatMapNode extends BaseNode {
type: 'FlatMap'

@@ -191,3 +188,3 @@ base: ExprNode

declare interface FuncCallNode extends BaseNode {
export declare interface FuncCallNode extends BaseNode {
type: 'FuncCall'

@@ -227,3 +224,3 @@ func: GroqFunction

declare interface GroupNode extends BaseNode {
export declare interface GroupNode extends BaseNode {
type: 'Group'

@@ -233,3 +230,3 @@ base: ExprNode

declare interface InRangeNode extends BaseNode {
export declare interface InRangeNode extends BaseNode {
type: 'InRange'

@@ -242,3 +239,3 @@ base: ExprNode

declare interface MapNode extends BaseNode {
export declare interface MapNode extends BaseNode {
type: 'Map'

@@ -249,3 +246,3 @@ base: ExprNode

declare interface NegNode extends BaseNode {
export declare interface NegNode extends BaseNode {
type: 'Neg'

@@ -255,51 +252,3 @@ base: ExprNode

declare namespace NodeTypes {
export {
SyntaxNode,
ObjectAttributeNode,
ExprNode,
OpCall,
BaseNode,
AndNode,
ArrayElementNode,
ArrayNode,
ArrayCoerceNode,
AscNode,
ContextNode,
DerefNode,
DescNode,
EverythingNode,
FuncCallNode,
GroupNode,
InRangeNode,
NegNode,
NotNode,
ObjectAttributeValueNode,
ObjectConditionalSplatNode,
ObjectNode,
ObjectSplatNode,
OpCallNode,
OrNode,
ParameterNode,
ParentNode_2 as ParentNode,
PipeFuncCallNode,
PosNode,
SelectAlternativeNode,
SelectNode,
SelectorNode,
ThisNode,
TupleNode,
ValueNode,
FlatMapNode,
MapNode,
AccessAttributeNode,
AccessElementNode,
SliceNode,
FilterNode,
ProjectionNode,
}
}
export {NodeTypes}
declare interface NotNode extends BaseNode {
export declare interface NotNode extends BaseNode {
type: 'Not'

@@ -313,3 +262,3 @@ base: ExprNode

declare type ObjectAttributeNode =
export declare type ObjectAttributeNode =
| ObjectAttributeValueNode

@@ -319,3 +268,3 @@ | ObjectConditionalSplatNode

declare interface ObjectAttributeValueNode extends BaseNode {
export declare interface ObjectAttributeValueNode extends BaseNode {
type: 'ObjectAttributeValue'

@@ -326,3 +275,3 @@ name: string

declare interface ObjectConditionalSplatNode extends BaseNode {
export declare interface ObjectConditionalSplatNode extends BaseNode {
type: 'ObjectConditionalSplat'

@@ -333,3 +282,3 @@ condition: ExprNode

declare interface ObjectNode extends BaseNode {
export declare interface ObjectNode extends BaseNode {
type: 'Object'

@@ -339,3 +288,3 @@ attributes: ObjectAttributeNode[]

declare interface ObjectSplatNode extends BaseNode {
export declare interface ObjectSplatNode extends BaseNode {
type: 'ObjectSplat'

@@ -347,3 +296,3 @@ value: ExprNode

declare type OpCall =
export declare type OpCall =
| '=='

@@ -364,3 +313,3 @@ | '!='

declare interface OpCallNode extends BaseNode {
export declare interface OpCallNode extends BaseNode {
type: 'OpCall'

@@ -372,3 +321,3 @@ op: OpCall

declare interface OrNode extends BaseNode {
export declare interface OrNode extends BaseNode {
type: 'Or'

@@ -379,3 +328,3 @@ left: ExprNode

declare interface ParameterNode extends BaseNode {
export declare interface ParameterNode extends BaseNode {
type: 'Parameter'

@@ -389,2 +338,3 @@ name: string

}
export {ParentNode_2 as ParentNode}

@@ -394,3 +344,3 @@ /**

*/
export declare function parse(input: string, options?: ParseOptions): NodeTypes.ExprNode
export declare function parse(input: string, options?: ParseOptions): ExprNode

@@ -412,3 +362,3 @@ export declare interface ParseOptions {

declare interface PipeFuncCallNode extends BaseNode {
export declare interface PipeFuncCallNode extends BaseNode {
type: 'PipeFuncCall'

@@ -421,3 +371,3 @@ func: GroqPipeFunction

declare interface PosNode extends BaseNode {
export declare interface PosNode extends BaseNode {
type: 'Pos'

@@ -427,3 +377,3 @@ base: ExprNode

declare interface ProjectionNode extends BaseNode {
export declare interface ProjectionNode extends BaseNode {
type: 'Projection'

@@ -452,3 +402,3 @@ base: ExprNode

declare interface SelectAlternativeNode extends BaseNode {
export declare interface SelectAlternativeNode extends BaseNode {
type: 'SelectAlternative'

@@ -459,3 +409,3 @@ condition: ExprNode

declare interface SelectNode extends BaseNode {
export declare interface SelectNode extends BaseNode {
type: 'Select'

@@ -466,7 +416,7 @@ alternatives: SelectAlternativeNode[]

declare interface SelectorNode extends BaseNode {
export declare interface SelectorNode extends BaseNode {
type: 'Selector'
}
declare interface SliceNode extends BaseNode {
export declare interface SliceNode extends BaseNode {
type: 'Slice'

@@ -504,11 +454,13 @@ base: ExprNode

/** Any sort of node which appears as syntax */
declare type SyntaxNode = ExprNode | ArrayElementNode | ObjectAttributeNode | SelectAlternativeNode
export declare type SyntaxNode =
| ExprNode
| ArrayElementNode
| ObjectAttributeNode
| SelectAlternativeNode
declare interface ThisNode extends BaseNode {
export declare interface ThisNode extends BaseNode {
type: 'This'
}
export declare function tryConstantEvaluate(node: ExprNode): Value | null
declare interface TupleNode extends BaseNode {
export declare interface TupleNode extends BaseNode {
type: 'Tuple'

@@ -523,3 +475,3 @@ members: Array<ExprNode>

declare interface ValueNode<P = any> {
export declare interface ValueNode<P = any> {
type: 'Value'

@@ -526,0 +478,0 @@ value: P

{
"name": "groq-js",
"version": "1.1.4-beta.0",
"version": "1.1.4-beta.1",
"license": "MIT",

@@ -43,2 +43,4 @@ "author": "Sanity.io <hello@sanity.io>",

"node-arg": [
"--loader",
"esbuild-register/loader",
"-r",

@@ -45,0 +47,0 @@ "esbuild-register"

@@ -1,2 +0,25 @@

export * from './evaluator'
export * from './parser'
export {evaluate} from './evaluator'
export type {GroqFunction, GroqFunctionArg, GroqPipeFunction} from './evaluator/functions'
export type {Scope} from './evaluator/scope'
export type {EvaluateOptions} from './evaluator/types'
export type {Context, Executor} from './evaluator/types'
export * from './nodeTypes'
export {parse} from './parser'
export type {ParseOptions} from './types'
export type {
AnyStaticValue,
ArrayValue,
BooleanValue,
DateTime,
DateTimeValue,
GroqType,
NullValue,
NumberValue,
ObjectValue,
Path,
PathValue,
StaticValue,
StreamValue,
StringValue,
Value,
} from './values'

@@ -1,2 +0,2 @@

import * as NodeTypes from '../nodeTypes'
import {ExprNode, FuncCallNode, PipeFuncCallNode} from '../nodeTypes'
import {

@@ -17,3 +17,3 @@ FALSE_VALUE,

export function evaluate(
node: NodeTypes.ExprNode,
node: ExprNode,
scope: Scope,

@@ -29,4 +29,4 @@ execute: Executor = evaluate

type ExecutorMap = {
[key in NodeTypes.ExprNode['type']]: (
node: NarrowNode<NodeTypes.ExprNode, key>,
[key in ExprNode['type']]: (
node: NarrowNode<ExprNode, key>,
scope: Scope,

@@ -169,7 +169,7 @@ exec: Executor

FuncCall({func, args}: NodeTypes.FuncCallNode, scope: Scope, execute) {
FuncCall({func, args}: FuncCallNode, scope: Scope, execute) {
return func(args, scope, execute)
},
async PipeFuncCall({func, base, args}: NodeTypes.PipeFuncCallNode, scope: Scope, execute) {
async PipeFuncCall({func, base, args}: PipeFuncCallNode, scope: Scope, execute) {
const baseValue = await execute(base, scope)

@@ -461,3 +461,3 @@ return func(baseValue, args, scope, execute)

export function evaluateQuery(
tree: NodeTypes.ExprNode,
tree: ExprNode,
options: EvaluateOptions = {}

@@ -484,22 +484,1 @@ ): Value | PromiseLike<Value> {

}
export type {EvaluateOptions, NodeTypes, Value}
export type {
AnyStaticValue,
ArrayValue,
BooleanValue,
DateTime,
DateTimeValue,
GroqType,
NullValue,
NumberValue,
ObjectValue,
Path,
PathValue,
StaticValue,
StreamValue,
StringValue,
} from '../values'
export type {GroqFunction, GroqFunctionArg,GroqPipeFunction} from './functions'
export type {Scope} from './scope'
export type {Context,Executor} from './types'
export {tryConstantEvaluate} from './constantEvaluate'
export type {
AnyStaticValue,
ArrayValue,
BooleanValue,
Context,
DateTime,
DateTimeValue,
EvaluateOptions,
Executor,
GroqFunction,
GroqFunctionArg,
GroqPipeFunction,
GroqType,
NodeTypes,
NullValue,
NumberValue,
ObjectValue,
Path,
PathValue,
Scope,
StaticValue,
StreamValue,
StringValue,
Value,
} from './evaluate'
export {evaluateQuery as evaluate} from './evaluate'

@@ -14,3 +14,3 @@ import {OpCall} from '../nodeTypes'

import {isEqual} from './equality'
import {gatherText, matchAnalyzePattern,matchText, matchTokenize, Pattern, Token} from './matching'
import {gatherText, matchAnalyzePattern, matchText, matchTokenize, Pattern, Token} from './matching'
import {partialCompare} from './ordering'

@@ -17,0 +17,0 @@

@@ -1,6 +0,6 @@

import * as NodeTypes from '../nodeTypes'
import {ExprNode} from '../nodeTypes'
import {Value} from '../values'
import {Scope} from './scope'
export type Executor<N = NodeTypes.ExprNode> = (node: N, scope: Scope) => Value | PromiseLike<Value>
export type Executor<N = ExprNode> = (node: N, scope: Scope) => Value | PromiseLike<Value>

@@ -7,0 +7,0 @@ export interface EvaluateOptions {

@@ -5,3 +5,12 @@ /* eslint-disable camelcase */

import {Mark, MarkProcessor, MarkVisitor} from './markProcessor'
import * as NodeTypes from './nodeTypes'
import {
ExprNode,
ParentNode,
OpCall,
ObjectAttributeNode,
ArrayElementNode,
SelectNode,
ObjectSplatNode,
FuncCallNode,
} from './nodeTypes'
import {parse as rawParse} from './rawParser'

@@ -40,3 +49,3 @@ import {

const EXPR_BUILDER: MarkVisitor<NodeTypes.ExprNode> = {
const EXPR_BUILDER: MarkVisitor<ExprNode> = {
group(p) {

@@ -66,3 +75,3 @@ const inner = p.process(EXPR_BUILDER)

dblparent(p) {
const next = p.process(EXPR_BUILDER) as NodeTypes.ParentNode
const next = p.process(EXPR_BUILDER) as ParentNode
return {

@@ -197,3 +206,3 @@ type: 'Parent',

const left = p.process(EXPR_BUILDER)
const op = p.processString() as NodeTypes.OpCall
const op = p.processString() as OpCall
const right = p.process(EXPR_BUILDER)

@@ -281,3 +290,3 @@ return {

object(p) {
const attributes: NodeTypes.ObjectAttributeNode[] = []
const attributes: ObjectAttributeNode[] = []
while (p.getMark().name !== 'object_end') {

@@ -295,3 +304,3 @@ attributes.push(p.process(OBJECT_BUILDER))

array(p) {
const elements: NodeTypes.ArrayElementNode[] = []
const elements: ArrayElementNode[] = []
while (p.getMark().name !== 'array_end') {

@@ -318,3 +327,3 @@ let isSplat = false

tuple(p) {
const members: NodeTypes.ExprNode[] = []
const members: ExprNode[] = []
while (p.getMark().name !== 'tuple_end') {

@@ -339,3 +348,3 @@ members.push(p.process(EXPR_BUILDER))

if (namespace === 'global' && name === 'select') {
const result: NodeTypes.SelectNode = {
const result: SelectNode = {
type: 'Select',

@@ -366,3 +375,3 @@ alternatives: [],

const args: NodeTypes.ExprNode[] = []
const args: ExprNode[] = []

@@ -433,3 +442,3 @@ while (p.getMark().name !== 'func_args_end') {

const name = p.processString()
const args: NodeTypes.ExprNode[] = []
const args: ExprNode[] = []

@@ -540,3 +549,3 @@ const oldAllowBoost = p.allowBoost

const OBJECT_BUILDER: MarkVisitor<NodeTypes.ObjectAttributeNode> = {
const OBJECT_BUILDER: MarkVisitor<ObjectAttributeNode> = {
object_expr(p) {

@@ -576,3 +585,3 @@ if (p.getMark().name === 'pair') {

object_splat(p): NodeTypes.ObjectSplatNode {
object_splat(p): ObjectSplatNode {
const value = p.process(EXPR_BUILDER)

@@ -586,3 +595,3 @@

object_splat_this(): NodeTypes.ObjectSplatNode {
object_splat_this(): ObjectSplatNode {
return {

@@ -668,3 +677,3 @@ type: 'ObjectSplat',

const wrap = (base: NodeTypes.ExprNode): NodeTypes.ExprNode =>
const wrap = (base: ExprNode): ExprNode =>
attr ? {type: 'AccessAttribute', base, name: attr} : base

@@ -795,3 +804,3 @@

func_call(p, mark) {
const func = EXPR_BUILDER.func_call(p, mark) as NodeTypes.FuncCallNode
const func = EXPR_BUILDER.func_call(p, mark) as FuncCallNode
if (func.name === 'anywhere' && func.args.length === 1) return null

@@ -835,3 +844,3 @@

function extractPropertyKey(node: NodeTypes.ExprNode): string {
function extractPropertyKey(node: ExprNode): string {
if (node.type === 'AccessAttribute' && !node.base) {

@@ -889,3 +898,3 @@ return node.name

*/
export function parse(input: string, options: ParseOptions = {}): NodeTypes.ExprNode {
export function parse(input: string, options: ParseOptions = {}): ExprNode {
const result = rawParse(input)

@@ -898,3 +907,1 @@ if (result.type === 'error') {

}
export type {ParseOptions}
import type {Path} from './Path'
import type {StreamValue} from './StreamValue'
import type {DateTime,StaticValue} from './utils'
import type {DateTime, StaticValue} from './utils'

@@ -5,0 +5,0 @@ /**

@@ -1,2 +0,2 @@

import {formatRFC3339,parseRFC3339} from './dateHelpers'
import {formatRFC3339, parseRFC3339} from './dateHelpers'
import {Path} from './Path'

@@ -3,0 +3,0 @@ import {StreamValue} from './StreamValue'

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 too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc