@sanity/client
Advanced tools
Comparing version 6.27.3-canary.2 to 6.28.0-resources.0
@@ -62,4 +62,6 @@ const BASE_URL = "https://www.sanity.io/help/"; | ||
]), printCdnPreviewDraftsWarning = createWarningPrinter([ | ||
"The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.", | ||
"The Sanity client is configured with the `perspective` set to `drafts` or `previewDrafts`, which doesn't support the API-CDN.", | ||
"The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning." | ||
]), printPreviewDraftsDeprecationWarning = createWarningPrinter([ | ||
"The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version" | ||
]), printBrowserTokenWarning = createWarningPrinter([ | ||
@@ -117,3 +119,13 @@ "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.", | ||
...specifiedConfig | ||
}, projectBased = newConfig.useProjectHostname; | ||
}, projectId$1 = newConfig.projectId; | ||
if (projectId$1?.startsWith("resource.")) { | ||
const [, resourceType, resourceId] = projectId$1.split("."); | ||
resourceType && resourceId && (newConfig.experimental_resource = { | ||
type: resourceType, | ||
id: resourceId | ||
}); | ||
} | ||
const experimentalResource = newConfig.experimental_resource; | ||
experimentalResource && (newConfig.useProjectHostname = !1); | ||
const projectBased = newConfig.useProjectHostname; | ||
if (typeof Promise > "u") { | ||
@@ -144,3 +156,7 @@ const helpUrl = generateHelpUrl("js-client-promise-polyfill"); | ||
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host; | ||
return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig; | ||
if (newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), experimentalResource) { | ||
const resourceSuffix = `${experimentalResource.type}/${experimentalResource.id}`; | ||
newConfig.url = `${newConfig.url}/${resourceSuffix}`, newConfig.cdnUrl = `${newConfig.cdnUrl}/${resourceSuffix}`; | ||
} | ||
return newConfig; | ||
}; | ||
@@ -154,2 +170,3 @@ export { | ||
printNoDefaultExport, | ||
printPreviewDraftsDeprecationWarning, | ||
requestTag, | ||
@@ -156,0 +173,0 @@ requireDocumentId, |
@@ -298,3 +298,3 @@ import { C } from "./stegaClean.js"; | ||
({ sourcePath, sourceDocument, resultPath, value }) => { | ||
if ((typeof filter == "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === !1) | ||
if ((typeof filter == "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, value })) === !1) | ||
return logger && report.skipped.push({ | ||
@@ -301,0 +301,0 @@ path: prettyPathForLogging(sourcePath), |
@@ -40,3 +40,3 @@ /** | ||
export declare type ClientPerspective = | ||
| 'previewDrafts' | ||
| DeprecatedPreviewDrafts | ||
| 'published' | ||
@@ -165,2 +165,7 @@ | 'drafts' | ||
/** | ||
* @deprecated use 'drafts' instead | ||
*/ | ||
declare type DeprecatedPreviewDrafts = 'previewDrafts' | ||
/** @internal */ | ||
@@ -167,0 +172,0 @@ export declare type DraftId = Opaque<string, 'draftId'> |
import { getIt } from "get-it"; | ||
import { adapter, environment } from "get-it"; | ||
import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from "get-it/middleware"; | ||
import { Observable, defer, isObservable, of, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, timer, throwError, tap, finalize, share, merge, EMPTY } from "rxjs"; | ||
import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY } from "rxjs"; | ||
import { stegaClean } from "./_chunks-es/stegaClean.js"; | ||
import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators"; | ||
import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requestTag, validateApiPerspective, printCdnPreviewDraftsWarning, hasDataset, validateAssetType, dataset, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js"; | ||
import { validateObject, validateInsert, requireDocumentId, validateDocumentId, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, dataset, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js"; | ||
class ClientError extends Error { | ||
@@ -723,14 +723,24 @@ response; | ||
} | ||
function _resourceBase(resource) { | ||
return `/${resource.type}/${resource.id}`; | ||
} | ||
function isDataRequestUri(uri, resource) { | ||
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0; | ||
} | ||
function isDataQueryRequestUri(uri, resource) { | ||
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0; | ||
} | ||
function _requestObservable(client, httpRequest, options) { | ||
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn; | ||
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && isDataRequestUri(uri, config.experimental_resource) : options.canUseCdn; | ||
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn; | ||
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix; | ||
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) { | ||
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && isDataQueryRequestUri(uri, config.experimental_resource)) { | ||
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap; | ||
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query }); | ||
const perspectiveOption = options.perspective || config.perspective; | ||
typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = { | ||
typeof perspectiveOption < "u" && (perspectiveOption === "previewDrafts" && printPreviewDraftsDeprecationWarning(), validateApiPerspective(perspectiveOption), options.query = { | ||
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption, | ||
...options.query | ||
}, perspectiveOption === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query }); | ||
}, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat | ||
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query }); | ||
} | ||
@@ -754,8 +764,14 @@ const reqOptions = requestOptions( | ||
function _getDataUrl(client, operation, path) { | ||
const config = client.config(), catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`; | ||
const config = client.config(); | ||
if (config.experimental_resource) { | ||
const baseUri2 = `/${operation}`; | ||
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1"); | ||
} | ||
const catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`; | ||
return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1"); | ||
} | ||
function _getUrl(client, uri, canUseCdn = !1) { | ||
const { url, cdnUrl } = client.config(); | ||
return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`; | ||
const { url, cdnUrl, experimental_resource } = client.config(); | ||
let base = canUseCdn ? cdnUrl : url; | ||
return experimental_resource && (uri.indexOf("/users") !== -1 || uri.indexOf("/assets") !== -1) && (base = base.replace(_resourceBase(experimental_resource), "")), `${base}/${uri.replace(/^\//, "")}`; | ||
} | ||
@@ -814,3 +830,3 @@ function _withAbortSignal(signal) { | ||
meta && !meta.length && (meta = ["none"]); | ||
const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = { | ||
const config = client.config(), resource = config.experimental_resource, dataset2 = resource ? void 0 : hasDataset(config), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = { | ||
label, | ||
@@ -827,3 +843,3 @@ title, | ||
timeout: options.timeout || 0, | ||
uri: `/assets/${assetEndpoint}/${dataset2}`, | ||
uri: resource ? `/assets/${resource.type}/${resource.id}/${assetEndpoint}` : `/assets/${assetEndpoint}/${dataset2}`, | ||
headers: options.contentType ? { "Content-Type": options.contentType } : {}, | ||
@@ -1083,2 +1099,19 @@ query, | ||
} | ||
class ThrowingDatasetsClient extends DatasetsClient { | ||
constructor(client, httpRequest) { | ||
super(client, httpRequest); | ||
} | ||
create() { | ||
throw new Error("cannot create dataset with the current client configuration"); | ||
} | ||
edit() { | ||
throw new Error("cannot edit dataset with the current client configuration"); | ||
} | ||
delete() { | ||
throw new Error("cannot delete dataset with the current client configuration"); | ||
} | ||
list() { | ||
throw new Error("cannot list dataset with the current client configuration"); | ||
} | ||
} | ||
function _modify(client, httpRequest, method, name2, options) { | ||
@@ -1339,3 +1372,3 @@ return dataset(name2), _request(client, httpRequest, { | ||
constructor(httpRequest, config = defaultConfig) { | ||
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config); | ||
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = this.#clientConfig.experimental_resource ? new ThrowingDatasetsClient(this, this.#httpRequest) : new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config); | ||
} | ||
@@ -1516,3 +1549,3 @@ /** | ||
} | ||
var name = "@sanity/client", version = "6.27.3-canary.2"; | ||
var name = "@sanity/client", version = "6.28.0-resources.0"; | ||
const middleware = [ | ||
@@ -1519,0 +1552,0 @@ debug({ verbose: !0, namespace: "sanity:client" }), |
@@ -1,2 +0,2 @@ | ||
import { SanityClient, ObservableSanityClient, requester as requester$1, createClient as createClient$1 } from "@sanity/client"; | ||
import { requester as requester$1, createClient as createClient$1, SanityClient, ObservableSanityClient } from "@sanity/client"; | ||
export * from "@sanity/client"; | ||
@@ -3,0 +3,0 @@ import { encodeIntoResult, stegaEncodeSourceMap } from "./_chunks-es/stegaEncodeSourceMap.js"; |
@@ -1,2 +0,2 @@ | ||
import { SanityClient, ObservableSanityClient, requester as requester$1, createClient as createClient$1 } from "@sanity/client"; | ||
import { requester as requester$1, createClient as createClient$1, SanityClient, ObservableSanityClient } from "@sanity/client"; | ||
export * from "@sanity/client"; | ||
@@ -3,0 +3,0 @@ import { encodeIntoResult, stegaEncodeSourceMap } from "./_chunks-es/stegaEncodeSourceMap.js"; |
{ | ||
"name": "@sanity/client", | ||
"version": "6.27.3-canary.2", | ||
"version": "6.28.0-resources.0", | ||
"description": "Client for retrieving, creating and patching data from Sanity.io", | ||
@@ -129,3 +129,3 @@ "keywords": [ | ||
"@eslint/eslintrc": "^3.2.0", | ||
"@eslint/js": "^9.19.0", | ||
"@eslint/js": "^9.20.0", | ||
"@rollup/plugin-commonjs": "^28.0.2", | ||
@@ -137,7 +137,7 @@ "@rollup/plugin-node-resolve": "^16.0.0", | ||
"@types/node": "^22.9.0", | ||
"@typescript-eslint/eslint-plugin": "^8.22.0", | ||
"@typescript-eslint/parser": "^8.22.0", | ||
"@typescript-eslint/eslint-plugin": "^8.24.0", | ||
"@typescript-eslint/parser": "^8.24.0", | ||
"@vercel/stega": "0.1.2", | ||
"@vitest/coverage-v8": "3.0.4", | ||
"eslint": "^9.19.0", | ||
"@vitest/coverage-v8": "3.0.5", | ||
"eslint": "^9.20.0", | ||
"eslint-config-prettier": "^10.0.1", | ||
@@ -153,13 +153,12 @@ "eslint-formatter-compact": "^8.40.0", | ||
"msw": "^2.7.0", | ||
"next": "^15.1.6", | ||
"next": "^15.1.7", | ||
"nock": "^13.5.6", | ||
"prettier": "^3.4.2", | ||
"prettier": "^3.5.0", | ||
"prettier-plugin-packagejson": "^2.5.8", | ||
"rimraf": "^5.0.7", | ||
"rollup": "^4.32.1", | ||
"rollup": "^4.34.6", | ||
"sse-channel": "^4.0.0", | ||
"terser": "^5.37.0", | ||
"terser": "^5.38.2", | ||
"typescript": "5.7.3", | ||
"vitest": "3.0.4", | ||
"vitest-github-actions-reporter": "0.11.1" | ||
"vitest": "3.0.5" | ||
}, | ||
@@ -166,0 +165,0 @@ "packageManager": "npm@11.0.0", |
@@ -152,3 +152,5 @@ import {lastValueFrom, type Observable} from 'rxjs' | ||
const dataset = validators.hasDataset(client.config()) | ||
const config = client.config() | ||
const resource = config.experimental_resource | ||
const dataset = resource ? undefined : validators.hasDataset(config) | ||
const assetEndpoint = assetType === 'image' ? 'images' : 'files' | ||
@@ -174,3 +176,5 @@ const options = optionsFromFile(opts, body) | ||
timeout: options.timeout || 0, | ||
uri: `/assets/${assetEndpoint}/${dataset}`, | ||
uri: resource | ||
? `/assets/${resource.type}/${resource.id}/${assetEndpoint}` | ||
: `/assets/${assetEndpoint}/${dataset}`, | ||
headers: options.contentType ? {'Content-Type': options.contentType} : {}, | ||
@@ -177,0 +181,0 @@ query, |
@@ -81,2 +81,21 @@ import {generateHelpUrl} from './generateHelpUrl' | ||
} as InitializedClientConfig | ||
const projectId = newConfig.projectId | ||
//this "feature" is meant for internal Sanity use only. Do not use. | ||
if (projectId?.startsWith('resource.')) { | ||
const [, resourceType, resourceId] = projectId.split('.') | ||
if (resourceType && resourceId) { | ||
newConfig.experimental_resource = { | ||
type: resourceType, | ||
id: resourceId, | ||
} | ||
} | ||
} | ||
// resource oriented clients should not use project hostname in base url | ||
const experimentalResource = newConfig.experimental_resource | ||
if (experimentalResource) { | ||
newConfig.useProjectHostname = false | ||
} | ||
const projectBased = newConfig.useProjectHostname | ||
@@ -172,3 +191,9 @@ | ||
if (experimentalResource) { | ||
const resourceSuffix = `${experimentalResource.type}/${experimentalResource.id}` | ||
newConfig.url = `${newConfig.url}/${resourceSuffix}` | ||
newConfig.cdnUrl = `${newConfig.cdnUrl}/${resourceSuffix}` | ||
} | ||
return newConfig | ||
} |
@@ -15,2 +15,3 @@ import {from, type MonoTypeOperatorFunction, Observable} from 'rxjs' | ||
BaseMutationOptions, | ||
ClientConfig, | ||
FirstDocumentIdMutationOptions, | ||
@@ -37,3 +38,3 @@ FirstDocumentMutationOptions, | ||
import * as validators from '../validators' | ||
import {printCdnPreviewDraftsWarning} from '../warnings' | ||
import {printCdnPreviewDraftsWarning, printPreviewDraftsDeprecationWarning} from '../warnings' | ||
import {encodeQueryString} from './encodeQueryString' | ||
@@ -43,2 +44,4 @@ import {ObservablePatch, Patch} from './patch' | ||
type ExperimentalResourceConfig = Exclude<ClientConfig['experimental_resource'], undefined> | ||
const excludeFalsey = (param: Any, defValue: Any) => { | ||
@@ -373,2 +376,20 @@ const value = typeof param === 'undefined' ? defValue : param | ||
function _resourceBase(resource: ExperimentalResourceConfig) { | ||
return `/${resource.type}/${resource.id}` | ||
} | ||
function isDataRequestUri(uri: string, resource?: ExperimentalResourceConfig) { | ||
if (resource) { | ||
return uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 | ||
} | ||
return uri.indexOf('/data/') === 0 | ||
} | ||
function isDataQueryRequestUri(uri: string, resource?: ExperimentalResourceConfig) { | ||
if (resource) { | ||
return uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 | ||
} | ||
return uri.indexOf('/data/query') === 0 | ||
} | ||
/** | ||
@@ -389,3 +410,4 @@ * @internal | ||
typeof options.canUseCdn === 'undefined' | ||
? ['GET', 'HEAD'].indexOf(options.method || 'GET') >= 0 && uri.indexOf('/data/') === 0 | ||
? ['GET', 'HEAD'].indexOf(options.method || 'GET') >= 0 && | ||
isDataRequestUri(uri, config.experimental_resource) | ||
: options.canUseCdn | ||
@@ -407,3 +429,3 @@ | ||
['GET', 'HEAD', 'POST'].indexOf(options.method || 'GET') >= 0 && | ||
uri.indexOf('/data/query/') === 0 | ||
isDataQueryRequestUri(uri, config.experimental_resource) | ||
) { | ||
@@ -416,2 +438,5 @@ const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap | ||
if (typeof perspectiveOption !== 'undefined') { | ||
if (perspectiveOption === 'previewDrafts') { | ||
printPreviewDraftsDeprecationWarning() | ||
} | ||
validateApiPerspective(perspectiveOption) | ||
@@ -424,4 +449,10 @@ options.query = { | ||
} | ||
// If the perspective is set to `previewDrafts` we can't use the CDN, the API will throw | ||
if (perspectiveOption === 'previewDrafts' && useCdn) { | ||
// If the perspective is set to `drafts` or multiple perspectives we can't use the CDN, the API will throw | ||
if ( | ||
((Array.isArray(perspectiveOption) && perspectiveOption.length > 0) || | ||
// previewDrafts was renamed to drafts, but keep for backwards compat | ||
perspectiveOption === 'previewDrafts' || | ||
perspectiveOption === 'drafts') && | ||
useCdn | ||
) { | ||
useCdn = false | ||
@@ -484,2 +515,8 @@ printCdnPreviewDraftsWarning() | ||
const config = client.config() | ||
if (config.experimental_resource) { | ||
const baseUri = `/${operation}` | ||
const uri = path ? `${baseUri}/${path}` : baseUri | ||
return uri.replace(/\/($|\?)/, '$1') | ||
} | ||
const catalog = validators.hasDataset(config) | ||
@@ -499,4 +536,11 @@ const baseUri = `/${operation}/${catalog}` | ||
): string { | ||
const {url, cdnUrl} = client.config() | ||
const base = canUseCdn ? cdnUrl : url | ||
const {url, cdnUrl, experimental_resource} = client.config() | ||
let base = canUseCdn ? cdnUrl : url | ||
if (experimental_resource) { | ||
if (uri.indexOf('/users') !== -1 || uri.indexOf('/assets') !== -1) { | ||
base = base.replace(_resourceBase(experimental_resource), '') | ||
} | ||
} | ||
return `${base}/${uri.replace(/^\//, '')}` | ||
@@ -503,0 +547,0 @@ } |
@@ -109,2 +109,24 @@ import {lastValueFrom, type Observable} from 'rxjs' | ||
export class ThrowingDatasetsClient extends DatasetsClient { | ||
constructor(client: SanityClient, httpRequest: HttpRequest) { | ||
super(client, httpRequest) | ||
} | ||
create(): Promise<DatasetResponse> { | ||
throw new Error('cannot create dataset with the current client configuration') | ||
} | ||
edit(): Promise<DatasetResponse> { | ||
throw new Error('cannot edit dataset with the current client configuration') | ||
} | ||
delete(): Promise<{deleted: true}> { | ||
throw new Error('cannot delete dataset with the current client configuration') | ||
} | ||
list(): Promise<DatasetsResponse> { | ||
throw new Error('cannot list dataset with the current client configuration') | ||
} | ||
} | ||
function _modify<R = unknown>( | ||
@@ -111,0 +133,0 @@ client: SanityClient | ObservableSanityClient, |
@@ -10,3 +10,7 @@ import {lastValueFrom, Observable} from 'rxjs' | ||
import {ObservableTransaction, Transaction} from './data/transaction' | ||
import {DatasetsClient, ObservableDatasetsClient} from './datasets/DatasetsClient' | ||
import { | ||
DatasetsClient, | ||
ObservableDatasetsClient, | ||
ThrowingDatasetsClient, | ||
} from './datasets/DatasetsClient' | ||
import {ObservableProjectsClient, ProjectsClient} from './projects/ProjectsClient' | ||
@@ -760,3 +764,6 @@ import type { | ||
this.assets = new AssetsClient(this, this.#httpRequest) | ||
this.datasets = new DatasetsClient(this, this.#httpRequest) | ||
this.datasets = this.#clientConfig.experimental_resource | ||
? new ThrowingDatasetsClient(this, this.#httpRequest) | ||
: new DatasetsClient(this, this.#httpRequest) | ||
this.live = new LiveClient(this) | ||
@@ -763,0 +770,0 @@ this.projects = new ProjectsClient(this, this.#httpRequest) |
@@ -40,2 +40,7 @@ // deno-lint-ignore-file no-empty-interface | ||
/** | ||
* @deprecated use 'drafts' instead | ||
*/ | ||
type DeprecatedPreviewDrafts = 'previewDrafts' | ||
/** @public */ | ||
@@ -46,3 +51,3 @@ export type StackablePerspective = ('published' | 'drafts' | string) & {} | ||
export type ClientPerspective = | ||
| 'previewDrafts' | ||
| DeprecatedPreviewDrafts | ||
| 'published' | ||
@@ -115,2 +120,10 @@ | 'drafts' | ||
stega?: StegaConfig | boolean | ||
/** | ||
* @deprecated Don't use | ||
*/ | ||
experimental_resource?: { | ||
id: string | ||
type: string | ||
} | ||
} | ||
@@ -117,0 +130,0 @@ |
@@ -21,6 +21,10 @@ import {generateHelpUrl} from './generateHelpUrl' | ||
export const printCdnPreviewDraftsWarning = createWarningPrinter([ | ||
`The Sanity client is configured with the \`perspective\` set to \`previewDrafts\`, which doesn't support the API-CDN.`, | ||
`The Sanity client is configured with the \`perspective\` set to \`drafts\` or \`previewDrafts\`, which doesn't support the API-CDN.`, | ||
`The Live API will be used instead. Set \`useCdn: false\` in your configuration to hide this warning.`, | ||
]) | ||
export const printPreviewDraftsDeprecationWarning = createWarningPrinter([ | ||
`The \`previewDrafts\` perspective has been renamed to \`drafts\` and will be removed in a future API version`, | ||
]) | ||
export const printBrowserTokenWarning = createWarningPrinter([ | ||
@@ -27,0 +31,0 @@ 'You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.', |
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 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 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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2850438
35
34224
1958