@sanity/client
Advanced tools
Comparing version 6.21.2 to 6.21.3-bundle-perspective
@@ -249,4 +249,3 @@ const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, reKeySegment = /_key\s*==\s*['"](.*)['"]/, reIndexTuple = /^\d*:\d*$/; | ||
); | ||
if (!baseUrl) | ||
return; | ||
if (!baseUrl) return; | ||
const { _id, _type, _projectId, _dataset } = sourceDoc; | ||
@@ -253,0 +252,0 @@ return { |
@@ -6,4 +6,3 @@ var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 }, u = new Array(4).fill(String.fromCodePoint(c[0])).join(""); | ||
let n = r.charCodeAt(0); | ||
if (n > 255) | ||
throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`); | ||
if (n > 255) throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`); | ||
return Array.from(n.toString(4).padStart(4, "0")).map((o) => String.fromCodePoint(c[o])).join(""); | ||
@@ -10,0 +9,0 @@ }).join("")}`; |
@@ -283,4 +283,3 @@ import { C } from "./stegaClean.js"; | ||
); | ||
if (!baseUrl) | ||
return value; | ||
if (!baseUrl) return value; | ||
const { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument; | ||
@@ -287,0 +286,0 @@ return C( |
@@ -5,4 +5,3 @@ import { walkMap, resolveMapping, parseJsonPath, toString, DRAFTS_PREFIX, getPublishedId, get, jsonPath, studioPathToJsonPath, resolveEditInfo, createEditUrl } from "./_chunks-es/resolveEditInfo.js"; | ||
function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn = defaultUpdateFunction, perspective = "raw") { | ||
if (!resultSourceMap) | ||
return result; | ||
if (!resultSourceMap) return result; | ||
if (perspective !== "published" && perspective !== "raw" && perspective !== "previewDrafts") | ||
@@ -9,0 +8,0 @@ throw new Error(`Unknown perspective "${perspective}"`); |
@@ -90,4 +90,3 @@ import { getIt } from "get-it"; | ||
function shouldRetry(err, attempt, options) { | ||
if (options.maxRetries === 0) | ||
return !1; | ||
if (options.maxRetries === 0) return !1; | ||
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503); | ||
@@ -631,3 +630,8 @@ return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options); | ||
function _getDocument(client, httpRequest, id, opts = {}) { | ||
const options = { uri: _getDataUrl(client, "doc", id), json: !0, tag: opts.tag }; | ||
const options = { | ||
uri: _getDataUrl(client, "doc", id), | ||
json: !0, | ||
tag: opts.tag, | ||
signal: opts.signal | ||
}; | ||
return _requestObservable(client, httpRequest, options).pipe( | ||
@@ -639,3 +643,8 @@ filter(isResponse), | ||
function _getDocuments(client, httpRequest, ids, opts = {}) { | ||
const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: !0, tag: opts.tag }; | ||
const options = { | ||
uri: _getDataUrl(client, "doc", ids.join(",")), | ||
json: !0, | ||
tag: opts.tag, | ||
signal: opts.signal | ||
}; | ||
return _requestObservable(client, httpRequest, options).pipe( | ||
@@ -693,2 +702,3 @@ filter(isResponse), | ||
perspective: options.perspective, | ||
bundlePerspective: options.bundlePerspective, | ||
resultSourceMap: options.resultSourceMap, | ||
@@ -731,4 +741,4 @@ lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId, | ||
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query }); | ||
const perspective = options.perspective || config.perspective; | ||
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }); | ||
const perspective = options.perspective || config.perspective, bundlePerspective = options.bundlePerspective || config.bundlePerspective; | ||
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), typeof bundlePerspective == "string" && (options.query = { perspective: void 0, bundlePerspective, ...options.query }), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }); | ||
} | ||
@@ -735,0 +745,0 @@ const reqOptions = requestOptions( |
@@ -90,4 +90,3 @@ import { getIt } from "get-it"; | ||
function shouldRetry(err, attempt, options) { | ||
if (options.maxRetries === 0) | ||
return !1; | ||
if (options.maxRetries === 0) return !1; | ||
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503); | ||
@@ -631,3 +630,8 @@ return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options); | ||
function _getDocument(client, httpRequest, id, opts = {}) { | ||
const options = { uri: _getDataUrl(client, "doc", id), json: !0, tag: opts.tag }; | ||
const options = { | ||
uri: _getDataUrl(client, "doc", id), | ||
json: !0, | ||
tag: opts.tag, | ||
signal: opts.signal | ||
}; | ||
return _requestObservable(client, httpRequest, options).pipe( | ||
@@ -639,3 +643,8 @@ filter(isResponse), | ||
function _getDocuments(client, httpRequest, ids, opts = {}) { | ||
const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: !0, tag: opts.tag }; | ||
const options = { | ||
uri: _getDataUrl(client, "doc", ids.join(",")), | ||
json: !0, | ||
tag: opts.tag, | ||
signal: opts.signal | ||
}; | ||
return _requestObservable(client, httpRequest, options).pipe( | ||
@@ -693,2 +702,3 @@ filter(isResponse), | ||
perspective: options.perspective, | ||
bundlePerspective: options.bundlePerspective, | ||
resultSourceMap: options.resultSourceMap, | ||
@@ -731,4 +741,4 @@ lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId, | ||
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query }); | ||
const perspective = options.perspective || config.perspective; | ||
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }); | ||
const perspective = options.perspective || config.perspective, bundlePerspective = options.bundlePerspective || config.bundlePerspective; | ||
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), typeof bundlePerspective == "string" && (options.query = { perspective: void 0, bundlePerspective, ...options.query }), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }); | ||
} | ||
@@ -1503,3 +1513,3 @@ const reqOptions = requestOptions( | ||
} | ||
var name = "@sanity/client", version = "6.21.2"; | ||
var name = "@sanity/client", version = "6.21.3-bundle-perspective"; | ||
const middleware = [ | ||
@@ -1506,0 +1516,0 @@ debug({ verbose: !0, namespace: "sanity:client" }), |
{ | ||
"name": "@sanity/client", | ||
"version": "6.21.2", | ||
"version": "6.21.3-bundle-perspective", | ||
"description": "Client for retrieving, creating and patching data from Sanity.io", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -132,5 +132,10 @@ import {from, type MonoTypeOperatorFunction, Observable} from 'rxjs' | ||
id: string, | ||
opts: {tag?: string} = {}, | ||
opts: {signal?: AbortSignal; tag?: string} = {}, | ||
): Observable<SanityDocument<R> | undefined> { | ||
const options = {uri: _getDataUrl(client, 'doc', id), json: true, tag: opts.tag} | ||
const options = { | ||
uri: _getDataUrl(client, 'doc', id), | ||
json: true, | ||
tag: opts.tag, | ||
signal: opts.signal, | ||
} | ||
return _requestObservable<SanityDocument<R> | undefined>(client, httpRequest, options).pipe( | ||
@@ -147,5 +152,10 @@ filter(isResponse), | ||
ids: string[], | ||
opts: {tag?: string} = {}, | ||
opts: {signal?: AbortSignal; tag?: string} = {}, | ||
): Observable<(SanityDocument<R> | null)[]> { | ||
const options = {uri: _getDataUrl(client, 'doc', ids.join(',')), json: true, tag: opts.tag} | ||
const options = { | ||
uri: _getDataUrl(client, 'doc', ids.join(',')), | ||
json: true, | ||
tag: opts.tag, | ||
signal: opts.signal, | ||
} | ||
return _requestObservable<(SanityDocument<R> | null)[]>(client, httpRequest, options).pipe( | ||
@@ -307,2 +317,3 @@ filter(isResponse), | ||
perspective: options.perspective, | ||
bundlePerspective: options.bundlePerspective, | ||
resultSourceMap: options.resultSourceMap, | ||
@@ -401,2 +412,3 @@ lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId, | ||
const perspective = options.perspective || config.perspective | ||
const bundlePerspective = options.bundlePerspective || config.bundlePerspective | ||
if (typeof perspective === 'string' && perspective !== 'raw') { | ||
@@ -412,2 +424,9 @@ validateApiPerspective(perspective) | ||
if (typeof bundlePerspective === 'string') { | ||
if (perspective) { | ||
// printWarning() | ||
} | ||
options.query = {perspective: undefined, bundlePerspective, ...options.query} | ||
} | ||
if (options.lastLiveEventId) { | ||
@@ -414,0 +433,0 @@ options.query = {...options.query, lastLiveEventId: options.lastLiveEventId} |
@@ -903,3 +903,3 @@ import {lastValueFrom, Observable} from 'rxjs' | ||
id: string, | ||
options?: {tag?: string}, | ||
options?: {signal?: AbortSignal; tag?: string}, | ||
): Promise<SanityDocument<R> | undefined> { | ||
@@ -920,3 +920,3 @@ return lastValueFrom(dataMethods._getDocument<R>(this, this.#httpRequest, id, options)) | ||
ids: string[], | ||
options?: {tag?: string}, | ||
options?: {signal?: AbortSignal; tag?: string}, | ||
): Promise<(SanityDocument<R> | null)[]> { | ||
@@ -923,0 +923,0 @@ return lastValueFrom(dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options)) |
@@ -45,2 +45,3 @@ // deno-lint-ignore-file no-empty-interface | ||
perspective?: ClientPerspective | ||
bundlePerspective?: string | ||
apiHost?: string | ||
@@ -225,3 +226,3 @@ apiVersion?: string | ||
/** | ||
* Present when `perspective` is set to `previewDrafts` | ||
* Present when `perspective` is set to `previewDrafts` or `bundlePerspective` is specified | ||
*/ | ||
@@ -311,2 +312,3 @@ _originalId?: string | ||
perspective?: ClientPerspective | ||
bundlePerspective?: string | ||
lastLiveEventId?: string | ||
@@ -378,2 +380,6 @@ } | ||
displayName: string | ||
/** | ||
* @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications | ||
* @see https://www.sanity.io/help/studio-host-user-applications | ||
*/ | ||
studioHost: string | null | ||
@@ -391,2 +397,6 @@ organizationId: string | null | ||
color?: string | ||
/** | ||
* @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications | ||
* @see https://www.sanity.io/help/studio-host-user-applications | ||
*/ | ||
externalStudioHost?: string | ||
@@ -471,2 +481,4 @@ } | ||
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */ | ||
bundlePerspective?: never | ||
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */ | ||
query?: never | ||
@@ -937,2 +949,3 @@ /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */ | ||
perspective?: ClientPerspective | ||
bundlePerspective?: string | ||
resultSourceMap?: boolean | 'withKeyArraySelector' | ||
@@ -939,0 +952,0 @@ returnQuery?: boolean |
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 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 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 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 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 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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
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
2165364
24643
1
6