@sanity/client 6.27.2-resources.2 → 6.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/config.cjs +2 -16
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +2 -16
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +11 -57
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +0 -7
- package/dist/index.browser.d.ts +0 -7
- package/dist/index.browser.js +11 -57
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +10 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/index.js +10 -42
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +0 -7
- package/dist/stega.browser.d.ts +0 -7
- package/dist/stega.d.cts +0 -7
- package/dist/stega.d.ts +0 -7
- package/package.json +1 -1
- package/src/SanityClient.ts +2 -9
- package/src/assets/AssetsClient.ts +2 -3
- package/src/config.ts +0 -23
- package/src/data/dataMethods.ts +4 -39
- package/src/data/eventsource.ts +0 -2
- package/src/datasets/DatasetsClient.ts +0 -22
- package/src/types.ts +0 -8
- package/umd/sanityClient.js +11 -57
- package/umd/sanityClient.min.js +2 -2
package/dist/stega.browser.d.cts
CHANGED
|
@@ -382,13 +382,6 @@ export declare interface ClientConfig {
|
|
|
382
382
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
383
383
|
*/
|
|
384
384
|
stega?: StegaConfig | boolean
|
|
385
|
-
/**
|
|
386
|
-
* @deprecated Don't use
|
|
387
|
-
*/
|
|
388
|
-
experimental_resource?: {
|
|
389
|
-
id: string
|
|
390
|
-
type: string
|
|
391
|
-
}
|
|
392
385
|
}
|
|
393
386
|
|
|
394
387
|
/** @public */
|
package/dist/stega.browser.d.ts
CHANGED
|
@@ -382,13 +382,6 @@ export declare interface ClientConfig {
|
|
|
382
382
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
383
383
|
*/
|
|
384
384
|
stega?: StegaConfig | boolean
|
|
385
|
-
/**
|
|
386
|
-
* @deprecated Don't use
|
|
387
|
-
*/
|
|
388
|
-
experimental_resource?: {
|
|
389
|
-
id: string
|
|
390
|
-
type: string
|
|
391
|
-
}
|
|
392
385
|
}
|
|
393
386
|
|
|
394
387
|
/** @public */
|
package/dist/stega.d.cts
CHANGED
|
@@ -382,13 +382,6 @@ export declare interface ClientConfig {
|
|
|
382
382
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
383
383
|
*/
|
|
384
384
|
stega?: StegaConfig | boolean
|
|
385
|
-
/**
|
|
386
|
-
* @deprecated Don't use
|
|
387
|
-
*/
|
|
388
|
-
experimental_resource?: {
|
|
389
|
-
id: string
|
|
390
|
-
type: string
|
|
391
|
-
}
|
|
392
385
|
}
|
|
393
386
|
|
|
394
387
|
/** @public */
|
package/dist/stega.d.ts
CHANGED
|
@@ -382,13 +382,6 @@ export declare interface ClientConfig {
|
|
|
382
382
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
383
383
|
*/
|
|
384
384
|
stega?: StegaConfig | boolean
|
|
385
|
-
/**
|
|
386
|
-
* @deprecated Don't use
|
|
387
|
-
*/
|
|
388
|
-
experimental_resource?: {
|
|
389
|
-
id: string
|
|
390
|
-
type: string
|
|
391
|
-
}
|
|
392
385
|
}
|
|
393
386
|
|
|
394
387
|
/** @public */
|
package/package.json
CHANGED
package/src/SanityClient.ts
CHANGED
|
@@ -7,11 +7,7 @@ import {_listen} from './data/listen'
|
|
|
7
7
|
import {LiveClient} from './data/live'
|
|
8
8
|
import {ObservablePatch, Patch} from './data/patch'
|
|
9
9
|
import {ObservableTransaction, Transaction} from './data/transaction'
|
|
10
|
-
import {
|
|
11
|
-
DatasetsClient,
|
|
12
|
-
ObservableDatasetsClient,
|
|
13
|
-
ThrowingDatasetsClient,
|
|
14
|
-
} from './datasets/DatasetsClient'
|
|
10
|
+
import {DatasetsClient, ObservableDatasetsClient} from './datasets/DatasetsClient'
|
|
15
11
|
import {ObservableProjectsClient, ProjectsClient} from './projects/ProjectsClient'
|
|
16
12
|
import type {
|
|
17
13
|
Action,
|
|
@@ -760,10 +756,7 @@ export class SanityClient {
|
|
|
760
756
|
this.#httpRequest = httpRequest
|
|
761
757
|
|
|
762
758
|
this.assets = new AssetsClient(this, this.#httpRequest)
|
|
763
|
-
this.datasets = this.#
|
|
764
|
-
? new ThrowingDatasetsClient(this, this.#httpRequest)
|
|
765
|
-
: new DatasetsClient(this, this.#httpRequest)
|
|
766
|
-
|
|
759
|
+
this.datasets = new DatasetsClient(this, this.#httpRequest)
|
|
767
760
|
this.live = new LiveClient(this)
|
|
768
761
|
this.projects = new ProjectsClient(this, this.#httpRequest)
|
|
769
762
|
this.users = new UsersClient(this, this.#httpRequest)
|
|
@@ -149,8 +149,7 @@ function _upload(
|
|
|
149
149
|
meta = ['none']
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
const
|
|
153
|
-
const dataset = config.experimental_resource ? undefined : validators.hasDataset(config)
|
|
152
|
+
const dataset = validators.hasDataset(client.config())
|
|
154
153
|
const assetEndpoint = assetType === 'image' ? 'images' : 'files'
|
|
155
154
|
const options = optionsFromFile(opts, body)
|
|
156
155
|
const {tag, label, title, description, creditLine, filename, source} = options
|
|
@@ -171,7 +170,7 @@ function _upload(
|
|
|
171
170
|
tag,
|
|
172
171
|
method: 'POST',
|
|
173
172
|
timeout: options.timeout || 0,
|
|
174
|
-
uri:
|
|
173
|
+
uri: `/assets/${assetEndpoint}/${dataset}`,
|
|
175
174
|
headers: options.contentType ? {'Content-Type': options.contentType} : {},
|
|
176
175
|
query,
|
|
177
176
|
body,
|
package/src/config.ts
CHANGED
|
@@ -90,23 +90,6 @@ export const initConfig = (
|
|
|
90
90
|
...defaultConfig,
|
|
91
91
|
...specifiedConfig,
|
|
92
92
|
} as InitializedClientConfig
|
|
93
|
-
|
|
94
|
-
const projectId = newConfig.projectId
|
|
95
|
-
if (projectId?.startsWith('resource.')) {
|
|
96
|
-
const [, resourceType, resourceId] = projectId.split('.')
|
|
97
|
-
if (resourceType && resourceId) {
|
|
98
|
-
newConfig.experimental_resource = {
|
|
99
|
-
type: resourceType,
|
|
100
|
-
id: resourceId,
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// resource oriented clients should not use project hostname in base url
|
|
105
|
-
const experimentalResource = newConfig.experimental_resource
|
|
106
|
-
if (experimentalResource) {
|
|
107
|
-
newConfig.useProjectHostname = false
|
|
108
|
-
}
|
|
109
|
-
|
|
110
93
|
const projectBased = newConfig.useProjectHostname
|
|
111
94
|
|
|
112
95
|
if (typeof Promise === 'undefined') {
|
|
@@ -197,11 +180,5 @@ export const initConfig = (
|
|
|
197
180
|
newConfig.cdnUrl = newConfig.url
|
|
198
181
|
}
|
|
199
182
|
|
|
200
|
-
if (experimentalResource) {
|
|
201
|
-
const resourceSuffix = `${experimentalResource.type}/${experimentalResource.id}`
|
|
202
|
-
newConfig.url = `${newConfig.url}/${resourceSuffix}`
|
|
203
|
-
newConfig.cdnUrl = `${newConfig.cdnUrl}/${resourceSuffix}`
|
|
204
|
-
}
|
|
205
|
-
|
|
206
183
|
return newConfig
|
|
207
184
|
}
|
package/src/data/dataMethods.ts
CHANGED
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
Any,
|
|
13
13
|
BaseActionOptions,
|
|
14
14
|
BaseMutationOptions,
|
|
15
|
-
ClientConfig,
|
|
16
15
|
FirstDocumentIdMutationOptions,
|
|
17
16
|
FirstDocumentMutationOptions,
|
|
18
17
|
HttpRequest,
|
|
@@ -39,8 +38,6 @@ import {encodeQueryString} from './encodeQueryString'
|
|
|
39
38
|
import {ObservablePatch, Patch} from './patch'
|
|
40
39
|
import {ObservableTransaction, Transaction} from './transaction'
|
|
41
40
|
|
|
42
|
-
type ExperimentalResourceConfig = Exclude<ClientConfig['experimental_resource'], undefined>
|
|
43
|
-
|
|
44
41
|
const excludeFalsey = (param: Any, defValue: Any) => {
|
|
45
42
|
const value = typeof param === 'undefined' ? defValue : param
|
|
46
43
|
return param === false ? undefined : value
|
|
@@ -370,24 +367,6 @@ export function _create<R extends Record<string, Any>>(
|
|
|
370
367
|
return _dataRequest(client, httpRequest, 'mutate', {mutations: [mutation]}, opts)
|
|
371
368
|
}
|
|
372
369
|
|
|
373
|
-
function _resourceBase(resource: ExperimentalResourceConfig) {
|
|
374
|
-
return `/${resource.type}/${resource.id}`
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function isDataRequestUri(uri: string, resource?: ExperimentalResourceConfig) {
|
|
378
|
-
if (resource) {
|
|
379
|
-
return uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0
|
|
380
|
-
}
|
|
381
|
-
return uri.indexOf('/data/') === 0
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function isDataQueryRequestUri(uri: string, resource?: ExperimentalResourceConfig) {
|
|
385
|
-
if (resource) {
|
|
386
|
-
return uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0
|
|
387
|
-
}
|
|
388
|
-
return uri.indexOf('/data/query') === 0
|
|
389
|
-
}
|
|
390
|
-
|
|
391
370
|
/**
|
|
392
371
|
* @internal
|
|
393
372
|
*/
|
|
@@ -403,8 +382,7 @@ export function _requestObservable<R>(
|
|
|
403
382
|
// Only the /data endpoint is currently available through API-CDN.
|
|
404
383
|
const canUseCdn =
|
|
405
384
|
typeof options.canUseCdn === 'undefined'
|
|
406
|
-
? ['GET', 'HEAD'].indexOf(options.method || 'GET') >= 0 &&
|
|
407
|
-
isDataRequestUri(uri, config.experimental_resource)
|
|
385
|
+
? ['GET', 'HEAD'].indexOf(options.method || 'GET') >= 0 && uri.indexOf('/data/') === 0
|
|
408
386
|
: options.canUseCdn
|
|
409
387
|
|
|
410
388
|
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn
|
|
@@ -421,7 +399,7 @@ export function _requestObservable<R>(
|
|
|
421
399
|
// GROQ query-only parameters
|
|
422
400
|
if (
|
|
423
401
|
['GET', 'HEAD', 'POST'].indexOf(options.method || 'GET') >= 0 &&
|
|
424
|
-
|
|
402
|
+
uri.indexOf('/data/query/') === 0
|
|
425
403
|
) {
|
|
426
404
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap
|
|
427
405
|
if (resultSourceMap !== undefined && resultSourceMap !== false) {
|
|
@@ -495,12 +473,6 @@ export function _getDataUrl(
|
|
|
495
473
|
path?: string,
|
|
496
474
|
): string {
|
|
497
475
|
const config = client.config()
|
|
498
|
-
|
|
499
|
-
if (config.experimental_resource) {
|
|
500
|
-
const baseUri = `/${operation}`
|
|
501
|
-
const uri = path ? `${baseUri}/${path}` : baseUri
|
|
502
|
-
return uri.replace(/\/($|\?)/, '$1')
|
|
503
|
-
}
|
|
504
476
|
const catalog = validators.hasDataset(config)
|
|
505
477
|
const baseUri = `/${operation}/${catalog}`
|
|
506
478
|
const uri = path ? `${baseUri}/${path}` : baseUri
|
|
@@ -515,15 +487,8 @@ export function _getUrl(
|
|
|
515
487
|
uri: string,
|
|
516
488
|
canUseCdn = false,
|
|
517
489
|
): string {
|
|
518
|
-
const {url, cdnUrl
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if (experimental_resource) {
|
|
522
|
-
if (uri.indexOf('/users') !== -1) {
|
|
523
|
-
base = base.replace(_resourceBase(experimental_resource), '')
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
490
|
+
const {url, cdnUrl} = client.config()
|
|
491
|
+
const base = canUseCdn ? cdnUrl : url
|
|
527
492
|
return `${base}/${uri.replace(/^\//, '')}`
|
|
528
493
|
}
|
|
529
494
|
|
package/src/data/eventsource.ts
CHANGED
|
@@ -131,8 +131,6 @@ function connectWithESInstance<EventTypeName extends string>(
|
|
|
131
131
|
// EventSource will emit a regular Event if it fails to connect, however the API may also emit an `error` MessageEvent
|
|
132
132
|
// So we need to handle both cases
|
|
133
133
|
function onError(evt: MessageEvent | Event) {
|
|
134
|
-
// eslint-disable-next-line no-console
|
|
135
|
-
console.log('Eventsource onError', evt, es.url)
|
|
136
134
|
// If the event has a `data` property, then it`s a MessageEvent emitted by the API and we should forward the error
|
|
137
135
|
if ('data' in evt) {
|
|
138
136
|
const [parseError, event] = parseEvent(evt as MessageEvent)
|
|
@@ -106,28 +106,6 @@ export class DatasetsClient {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export class ThrowingDatasetsClient extends DatasetsClient {
|
|
110
|
-
constructor(client: SanityClient, httpRequest: HttpRequest) {
|
|
111
|
-
super(client, httpRequest)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
create(): Promise<DatasetResponse> {
|
|
115
|
-
throw new Error('cannot create dataset with the current client configuration')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
edit(): Promise<DatasetResponse> {
|
|
119
|
-
throw new Error('cannot edit dataset with the current client configuration')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
delete(): Promise<{deleted: true}> {
|
|
123
|
-
throw new Error('cannot delete dataset with the current client configuration')
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
list(): Promise<DatasetsResponse> {
|
|
127
|
-
throw new Error('cannot list dataset with the current client configuration')
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
109
|
function _modify<R = unknown>(
|
|
132
110
|
client: SanityClient | ObservableSanityClient,
|
|
133
111
|
httpRequest: HttpRequest,
|
package/src/types.ts
CHANGED
|
@@ -104,14 +104,6 @@ export interface ClientConfig {
|
|
|
104
104
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
105
105
|
*/
|
|
106
106
|
stega?: StegaConfig | boolean
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @deprecated Don't use
|
|
110
|
-
*/
|
|
111
|
-
experimental_resource?: {
|
|
112
|
-
id: string
|
|
113
|
-
type: string
|
|
114
|
-
}
|
|
115
107
|
}
|
|
116
108
|
|
|
117
109
|
/** @public */
|
package/umd/sanityClient.js
CHANGED
|
@@ -2073,17 +2073,7 @@
|
|
|
2073
2073
|
const newConfig = {
|
|
2074
2074
|
...defaultConfig,
|
|
2075
2075
|
...specifiedConfig
|
|
2076
|
-
},
|
|
2077
|
-
if (projectId$1?.startsWith("resource.")) {
|
|
2078
|
-
const [, resourceType, resourceId] = projectId$1.split(".");
|
|
2079
|
-
resourceType && resourceId && (newConfig.experimental_resource = {
|
|
2080
|
-
type: resourceType,
|
|
2081
|
-
id: resourceId
|
|
2082
|
-
});
|
|
2083
|
-
}
|
|
2084
|
-
const experimentalResource = newConfig.experimental_resource;
|
|
2085
|
-
experimentalResource && (newConfig.useProjectHostname = false);
|
|
2086
|
-
const projectBased = newConfig.useProjectHostname;
|
|
2076
|
+
}, projectBased = newConfig.useProjectHostname;
|
|
2087
2077
|
if (typeof Promise > "u") {
|
|
2088
2078
|
const helpUrl = generateHelpUrl("js-client-promise-polyfill");
|
|
2089
2079
|
throw new Error(`No native Promise-implementation found, polyfill needed - see ${helpUrl}`);
|
|
@@ -2109,11 +2099,7 @@
|
|
|
2109
2099
|
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
|
|
2110
2100
|
isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : undefined), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn === true && newConfig.withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
2111
2101
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
2112
|
-
|
|
2113
|
-
const resourceSuffix = `${experimentalResource.type}/${experimentalResource.id}`;
|
|
2114
|
-
newConfig.url = `${newConfig.url}/${resourceSuffix}`, newConfig.cdnUrl = `${newConfig.cdnUrl}/${resourceSuffix}`;
|
|
2115
|
-
}
|
|
2116
|
-
return newConfig;
|
|
2102
|
+
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;
|
|
2117
2103
|
};
|
|
2118
2104
|
class ConnectionFailedError extends Error {
|
|
2119
2105
|
name = "ConnectionFailedError";
|
|
@@ -2153,7 +2139,7 @@
|
|
|
2153
2139
|
return new Observable((observer) => {
|
|
2154
2140
|
const emitOpen = events.includes("open"), emitReconnect = events.includes("reconnect");
|
|
2155
2141
|
function onError(evt) {
|
|
2156
|
-
if (
|
|
2142
|
+
if ("data" in evt) {
|
|
2157
2143
|
const [parseError, event] = parseEvent(evt);
|
|
2158
2144
|
observer.error(
|
|
2159
2145
|
parseError ? new MessageParseError("Unable to parse EventSource error message", { cause: event }) : new MessageError((event?.data).message, event)
|
|
@@ -2724,20 +2710,11 @@ ${selectionOpts}`);
|
|
|
2724
2710
|
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
|
|
2725
2711
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
2726
2712
|
}
|
|
2727
|
-
function _resourceBase(resource) {
|
|
2728
|
-
return `/${resource.type}/${resource.id}`;
|
|
2729
|
-
}
|
|
2730
|
-
function isDataRequestUri(uri, resource) {
|
|
2731
|
-
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
|
|
2732
|
-
}
|
|
2733
|
-
function isDataQueryRequestUri(uri, resource) {
|
|
2734
|
-
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0;
|
|
2735
|
-
}
|
|
2736
2713
|
function _requestObservable(client, httpRequest, options) {
|
|
2737
|
-
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 &&
|
|
2714
|
+
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;
|
|
2738
2715
|
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
|
|
2739
2716
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
2740
|
-
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 &&
|
|
2717
|
+
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) {
|
|
2741
2718
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
2742
2719
|
resultSourceMap !== undefined && resultSourceMap !== false && (options.query = { resultSourceMap, ...options.query });
|
|
2743
2720
|
const perspectiveOption = options.perspective || config.perspective;
|
|
@@ -2763,18 +2740,12 @@ ${selectionOpts}`);
|
|
|
2763
2740
|
);
|
|
2764
2741
|
}
|
|
2765
2742
|
function _getDataUrl(client, operation, path) {
|
|
2766
|
-
const config = client.config()
|
|
2767
|
-
if (config.experimental_resource) {
|
|
2768
|
-
const baseUri2 = `/${operation}`;
|
|
2769
|
-
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
|
|
2770
|
-
}
|
|
2771
|
-
const catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
2743
|
+
const config = client.config(), catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
2772
2744
|
return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
|
|
2773
2745
|
}
|
|
2774
2746
|
function _getUrl(client, uri, canUseCdn = false) {
|
|
2775
|
-
const { url, cdnUrl
|
|
2776
|
-
|
|
2777
|
-
return experimental_resource && uri.indexOf("/users") !== -1 && (base = base.replace(_resourceBase(experimental_resource), "")), `${base}/${uri.replace(/^\//, "")}`;
|
|
2747
|
+
const { url, cdnUrl } = client.config();
|
|
2748
|
+
return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
|
|
2778
2749
|
}
|
|
2779
2750
|
function _withAbortSignal(signal) {
|
|
2780
2751
|
return (input) => new Observable((observer) => {
|
|
@@ -2828,7 +2799,7 @@ ${selectionOpts}`);
|
|
|
2828
2799
|
validateAssetType(assetType);
|
|
2829
2800
|
let meta = opts.extract || undefined;
|
|
2830
2801
|
meta && !meta.length && (meta = ["none"]);
|
|
2831
|
-
const
|
|
2802
|
+
const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
|
|
2832
2803
|
label,
|
|
2833
2804
|
title,
|
|
2834
2805
|
description,
|
|
@@ -2840,7 +2811,7 @@ ${selectionOpts}`);
|
|
|
2840
2811
|
tag,
|
|
2841
2812
|
method: "POST",
|
|
2842
2813
|
timeout: options.timeout || 0,
|
|
2843
|
-
uri:
|
|
2814
|
+
uri: `/assets/${assetEndpoint}/${dataset2}`,
|
|
2844
2815
|
headers: options.contentType ? { "Content-Type": options.contentType } : {},
|
|
2845
2816
|
query,
|
|
2846
2817
|
body
|
|
@@ -3063,23 +3034,6 @@ ${selectionOpts}`);
|
|
|
3063
3034
|
);
|
|
3064
3035
|
}
|
|
3065
3036
|
}
|
|
3066
|
-
class ThrowingDatasetsClient extends DatasetsClient {
|
|
3067
|
-
constructor(client, httpRequest) {
|
|
3068
|
-
super(client, httpRequest);
|
|
3069
|
-
}
|
|
3070
|
-
create() {
|
|
3071
|
-
throw new Error("cannot create dataset with the current client configuration");
|
|
3072
|
-
}
|
|
3073
|
-
edit() {
|
|
3074
|
-
throw new Error("cannot edit dataset with the current client configuration");
|
|
3075
|
-
}
|
|
3076
|
-
delete() {
|
|
3077
|
-
throw new Error("cannot delete dataset with the current client configuration");
|
|
3078
|
-
}
|
|
3079
|
-
list() {
|
|
3080
|
-
throw new Error("cannot list dataset with the current client configuration");
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
3037
|
function _modify(client, httpRequest, method, name, options) {
|
|
3084
3038
|
return dataset(name), _request(client, httpRequest, {
|
|
3085
3039
|
method,
|
|
@@ -3335,7 +3289,7 @@ ${selectionOpts}`);
|
|
|
3335
3289
|
*/
|
|
3336
3290
|
listen = _listen;
|
|
3337
3291
|
constructor(httpRequest, config = defaultConfig) {
|
|
3338
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets =
|
|
3292
|
+
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);
|
|
3339
3293
|
}
|
|
3340
3294
|
/**
|
|
3341
3295
|
* Clone the client - returns a new instance
|