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

groq-js

Package Overview
Dependencies
Maintainers
44
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.4.4-canary.1 to 1.5.0-canary.1

src/typeEvaluator/functions.ts

13

API.md

@@ -10,3 +10,4 @@ # API

- [`parse`](#parse)
- [`evalute`](#evaluate)
- [`evaluate`](#evaluate)
- [`typeEvaluate`](#typeEvaluate)

@@ -73,1 +74,11 @@ ## `parse`

`evaluate` accepts a node returned by [`parse`](#parse) and evaluates the query.
## `typeEvaluate`
_**Beta**_
```typescript
export declare function typeEvaluate(ast: ExprNode, schema: SchemaType): TypeNode
```
`typeEvaluate` accepts a node returned by [`parse`](#parse) and a schema and evaluates the type that would be returned by the query in combination with the schema.

@@ -45,2 +45,7 @@ export declare interface AccessAttributeNode extends BaseNode {

export declare interface ArrayTypeNode<T extends TypeNode = TypeNode> {
type: 'array'
of: T
}
export declare type ArrayValue = StaticValue<unknown[], 'array'>

@@ -58,2 +63,7 @@

export declare interface BooleanTypeNode {
type: 'boolean'
value?: boolean
}
export declare type BooleanValue = StaticValue<boolean, 'boolean'>

@@ -78,2 +88,12 @@

/**
* createReferenceTypeNode creates a ObjectTypeNode representing a reference type
* it adds required attributes for a reference type.
* @param name - The name of the reference type
* @param inArray - Whether the reference is in an array
* @returns A ObjectTypeNode representing a reference type
* @internal
*/
export declare function createReferenceTypeNode(name: string, inArray?: boolean): ObjectTypeNode
export declare class DateTime {

@@ -114,2 +134,8 @@ date: Date

export declare interface DocumentSchemaType {
type: 'document'
name: string
attributes: Record<string, ObjectAttribute>
}
/**

@@ -232,2 +258,7 @@ * Evaluates a query.

export declare interface InlineTypeNode {
type: 'inline'
name: string
}
export declare interface InRangeNode extends BaseNode {

@@ -257,6 +288,21 @@ type: 'InRange'

export declare interface NullTypeNode {
type: 'null'
}
export declare type NullValue = StaticValue<null, 'null'>
export declare interface NumberTypeNode {
type: 'number'
value?: number
}
export declare type NumberValue = StaticValue<number, 'number'>
export declare interface ObjectAttribute<T extends TypeNode = TypeNode> {
type: 'objectAttribute'
value: T
optional?: boolean
}
export declare type ObjectAttributeNode =

@@ -289,2 +335,9 @@ | ObjectAttributeValueNode

export declare interface ObjectTypeNode<T extends TypeNode = TypeNode> {
type: 'object'
attributes: Record<string, ObjectAttribute<T>>
rest?: ObjectTypeNode | UnknownTypeNode | InlineTypeNode
dereferencesTo?: string
}
export declare type ObjectValue = StaticValue<Record<string, unknown>, 'object'>

@@ -365,2 +418,4 @@

export declare type PrimitiveTypeNode = StringTypeNode | NumberTypeNode | BooleanTypeNode
export declare interface ProjectionNode extends BaseNode {

@@ -372,2 +427,4 @@ type: 'Projection'

export declare type SchemaType = (DocumentSchemaType | TypeDeclarationSchemaType)[]
export declare class Scope {

@@ -437,2 +494,7 @@ params: Record<string, unknown>

export declare interface StringTypeNode {
type: 'string'
value?: string
}
export declare type StringValue = StaticValue<string, 'string'>

@@ -456,3 +518,39 @@

export declare interface TypeDeclarationSchemaType {
type: 'type'
name: string
value: TypeNode
}
/**
* Evaluates the type of a query and schema.
*
* @param ast - The query ast to evaluate.
* @param schema - The schemas to use for type evaluation.
* @returns The type of the query.
* @beta
*/
export declare function typeEvaluate(ast: ExprNode, schema: SchemaType): TypeNode
export declare type TypeNode =
| ObjectTypeNode
| StringTypeNode
| NullTypeNode
| NumberTypeNode
| BooleanTypeNode
| ArrayTypeNode
| UnionTypeNode
| InlineTypeNode
| UnknownTypeNode
export declare interface UnionTypeNode<T extends TypeNode = TypeNode> {
type: 'union'
of: T[]
}
export declare type UnknownTypeNode = {
type: 'unknown'
}
/**
* The result of an expression.

@@ -459,0 +557,0 @@ */

28

package.json
{
"name": "groq-js",
"version": "1.4.4-canary.1",
"version": "1.5.0-canary.1",
"keywords": [

@@ -18,3 +18,3 @@ "sanity",

"type": "commonjs",
"exports": {
"Exports": {
".": {

@@ -52,2 +52,5 @@ "types": "./dist/index.d.ts",

"./dist/1.d.ts"
],
"typeEvaluator": [
"./dist/typeEvaluator/index.d.ts"
]

@@ -70,3 +73,3 @@ }

"prettify-check": "prettier --check .",
"test": "tap --no-timeout test/*.test.*",
"test": "tap --no-timeout --coverage-report=html --no-browser test/*.test.*",
"test:generate": "./test/generate.sh"

@@ -79,16 +82,15 @@ },

"-r",
"esbuild-register"
"tsx/cjs"
]
},
"devDependencies": {
"@sanity/pkg-utils": "^4.2.11",
"@sanity/semantic-release-preset": "^4.1.6",
"@sanity/pkg-utils": "^4.3.1",
"@sanity/semantic-release-preset": "^4.1.7",
"@types/debug": "^4.1.12",
"@types/tap": "^15.0.11",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"esbuild": "^0.20.1",
"esbuild-register": "^3.5.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-sanity": "^7.0.2",
"eslint-config-sanity": "^7.1.1",
"eslint-plugin-prettier": "^5.1.3",

@@ -102,2 +104,3 @@ "eslint-plugin-simple-import-sort": "^12.0.0",

"tap": "^16.3.10",
"tsx": "^4.7.1",
"typescript": "^5.3.3"

@@ -110,3 +113,6 @@ },

"provenance": true
},
"dependencies": {
"debug": "^4.3.4"
}
}

@@ -30,1 +30,5 @@ export {evaluate} from './evaluator'

export {DateTime, Path} from './values'
// Type evaluation
export type * from './typeEvaluator'
export {createReferenceTypeNode, typeEvaluate} from './typeEvaluator'

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

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