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

@sanity/client

Package Overview
Dependencies
Maintainers
64
Versions
1003
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 6.23.0 to 6.24.0-canary.0

2

package.json
{
"name": "@sanity/client",
"version": "6.23.0",
"version": "6.24.0-canary.0",
"description": "Client for retrieving, creating and patching data from Sanity.io",

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

@@ -31,5 +31,27 @@ import {generateHelpUrl} from './generateHelpUrl'

export const validateApiPerspective = function validateApiPerspective(perspective: string) {
export const validateApiPerspective = function validateApiPerspective(perspective: unknown) {
if (Array.isArray(perspective)) {
for (const perspectiveValue of perspective) {
if (perspectiveValue === 'published') {
continue
}
if (perspectiveValue === 'drafts') {
continue
}
if (
typeof perspectiveValue === 'string' &&
perspectiveValue.startsWith('r') &&
perspectiveValue !== 'raw'
) {
continue
}
throw new TypeError(
'Invalid API perspective value, expected `published`, `drafts` or a valid release identifier string',
)
}
return
}
switch (perspective as ClientPerspective) {
case 'previewDrafts':
case 'drafts':
case 'published':

@@ -78,3 +100,3 @@ case 'raw':

if (typeof newConfig.perspective === 'string') {
if (typeof newConfig.perspective !== 'undefined') {
validateApiPerspective(newConfig.perspective)

@@ -81,0 +103,0 @@ }

@@ -408,8 +408,13 @@ import {from, type MonoTypeOperatorFunction, Observable} from 'rxjs'

}
const perspective = options.perspective || config.perspective
if (typeof perspective === 'string' && perspective !== 'raw') {
validateApiPerspective(perspective)
options.query = {perspective, ...options.query}
const perspectiveOption = options.perspective || config.perspective
if (typeof perspectiveOption !== 'undefined') {
validateApiPerspective(perspectiveOption)
options.query = {
perspective: Array.isArray(perspectiveOption)
? perspectiveOption.join(',')
: perspectiveOption,
...options.query,
}
// If the perspective is set to `previewDrafts` we can't use the CDN, the API will throw
if (perspective === 'previewDrafts' && useCdn) {
if (perspectiveOption === 'previewDrafts' && useCdn) {
useCdn = false

@@ -416,0 +421,0 @@ printCdnPreviewDraftsWarning()

@@ -35,5 +35,13 @@ // deno-lint-ignore-file no-empty-interface

/** @public */
export type ClientPerspective = 'previewDrafts' | 'published' | 'raw'
export type ReleaseId = `r${string}`
/** @public */
export type ClientPerspective =
| 'previewDrafts'
| 'published'
| 'drafts'
| 'raw'
| ('published' | 'drafts' | ReleaseId)[]
/** @public */
export interface ClientConfig {

@@ -40,0 +48,0 @@ projectId?: string

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

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 not supported yet

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

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 not supported yet

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

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

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