Comparing version 1.10.1-canary.0 to 1.11.0
{ | ||
"name": "groq-js", | ||
"version": "1.10.1-canary.0", | ||
"version": "1.11.0", | ||
"keywords": [ | ||
@@ -82,3 +82,3 @@ "sanity", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-simple-import-sort": "^12.1.0", | ||
"eslint-plugin-simple-import-sort": "^12.1.1", | ||
"ndjson": "^2.0.0", | ||
@@ -85,0 +85,0 @@ "prettier": "^3.3.2", |
@@ -429,2 +429,34 @@ import type {ExprNode} from '../nodeTypes' | ||
// eslint-disable-next-line require-await | ||
sanity['versionOf'] = async function (args, scope, execute) { | ||
if (!scope.source.isArray()) return NULL_VALUE | ||
const value = await execute(args[0], scope) | ||
if (value.type !== 'string') return NULL_VALUE | ||
const baseId = value.data | ||
// All the document are a version of the given ID if: | ||
// 1. Document ID is of the ford bundleId.documentGroupId | ||
// 2. And, they have a field called _version which is an object. | ||
const versionIds: string[] = [] | ||
for await (const value of scope.source) { | ||
if (getType(value) === 'object') { | ||
const val = await value.get() | ||
if ( | ||
val && | ||
'_id' in val && | ||
val._id.split('.').length === 2 && | ||
val._id.endsWith(`.${baseId}`) && | ||
'_version' in val && | ||
typeof val._version === 'object' | ||
) { | ||
versionIds.push(val._id) | ||
} | ||
} | ||
} | ||
return fromJS(versionIds) | ||
} | ||
sanity['versionOf'].arity = 1 | ||
export type GroqPipeFunction = ( | ||
@@ -431,0 +463,0 @@ base: Value, |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable max-statements */ | ||
import type {FuncCallNode} from '../nodeTypes' | ||
@@ -299,2 +300,11 @@ import {Scope} from './scope' | ||
} | ||
case 'sanity.versionOf': { | ||
const typeNode = walk({node: node.args[0], scope}) | ||
return mapConcrete(typeNode, scope, (typeNode) => { | ||
if (typeNode.type !== 'string') { | ||
return {type: 'null'} | ||
} | ||
return {type: 'array', of: {type: 'string'}} | ||
}) | ||
} | ||
default: { | ||
@@ -301,0 +311,0 @@ return {type: 'unknown'} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
979583
13385
1