🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@sanity/client

Package Overview
Dependencies
Maintainers
2
Versions
1154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/client - npm Package Compare versions

Comparing version
7.23.2
to
7.24.0
+1
-1
package.json
{
"name": "@sanity/client",
"version": "7.23.2",
"version": "7.24.0",
"description": "Client for retrieving, creating and patching data from Sanity.io",

@@ -5,0 +5,0 @@ "keywords": [

@@ -552,2 +552,3 @@ import {getDraftId, getVersionFromId, getVersionId, isDraftId} from '@sanity/client/csm'

perspective: options.perspective,
variant: options.variant,
resultSourceMap: options.resultSourceMap,

@@ -704,2 +705,32 @@ lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,

const variantOption = options.variant || config.variant
if (typeof variantOption !== 'undefined') {
if (typeof variantOption === 'string') {
options.query = {
variant: variantOption,
...options.query,
}
}
if (typeof variantOption === 'object') {
const variantConditions = Object.entries(variantOption)
const searchParams = variantConditionPairsToSearchParams(variantConditions).slice(0, 1)
if (variantConditions.length > 1) {
const formatter = new Intl.ListFormat('en')
// eslint-disable-next-line no-console -- will be removed in an upcoming version; it's better this behaviour is noisy and obvious
console.warn(
`The Sanity client's beta \`variant\` option currently only supports one condition. Dropped: ${formatter.format(variantConditions.slice(1).map(([subject]) => JSON.stringify(subject)))}.`,
)
}
options.query = {
...Object.fromEntries(searchParams),
...options.query,
}
}
}
if (options.lastLiveEventId) {

@@ -848,1 +879,10 @@ options.query = {...options.query, lastLiveEventId: options.lastLiveEventId}

}
function variantConditionPairsToSearchParams(
variantConditionPairs: string[][],
): ['variantCondition', `${string}:${string}`][] {
return variantConditionPairs.map(([condition, value]) => [
'variantCondition',
`${condition}:${value}`,
])
}

@@ -58,2 +58,14 @@ // deno-lint-ignore-file no-empty-interface

/**
* @public
* @beta
*/
export type ClientVariantConditions = Record<string, string>
/**
* @public
* @beta
*/
export type ClientVariant = ClientVariantConditions | string
type ClientConfigResource =

@@ -115,2 +127,6 @@ | {

perspective?: ClientPerspective
/**
* @beta
*/
variant?: ClientVariant
apiHost?: string

@@ -489,2 +505,6 @@

perspective?: ClientPerspective
/**
* @beta
*/
variant?: ClientVariant
lastLiveEventId?: string

@@ -685,2 +705,4 @@ cacheMode?: 'noStale'

/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
variant?: never
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
query?: never

@@ -1431,2 +1453,6 @@ /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */

perspective?: ClientPerspective
/**
* @beta
*/
variant?: ClientVariant
resultSourceMap?: boolean | 'withKeyArraySelector'

@@ -1433,0 +1459,0 @@ returnQuery?: boolean

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display