@sanity/client
Advanced tools
Comparing version 6.11.4-canary.2 to 6.11.4-canary.3
@@ -1,3 +0,3 @@ | ||
import { printNoDefaultExport, defineCreateClientExports, SanityClient, envMiddleware } from './_chunks/browserMiddleware-nSeu_Rmf.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/browserMiddleware-nSeu_Rmf.js'; | ||
import { printNoDefaultExport, defineCreateClientExports, SanityClient, envMiddleware } from './_chunks/browserMiddleware-YHi9NZoW.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/browserMiddleware-YHi9NZoW.js'; | ||
export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it'; | ||
@@ -4,0 +4,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { printNoDefaultExport, defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-s6SiVm6L.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-s6SiVm6L.js'; | ||
import { printNoDefaultExport, defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-faRZtx-m.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-faRZtx-m.js'; | ||
export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it'; | ||
@@ -4,0 +4,0 @@ |
@@ -1,5 +0,5 @@ | ||
import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-nSeu_Rmf.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-nSeu_Rmf.js'; | ||
import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-YHi9NZoW.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-YHi9NZoW.js'; | ||
export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it'; | ||
export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-SOgem38i.js'; | ||
export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-wX9ZIHBe.js'; | ||
@@ -6,0 +6,0 @@ class SanityStegaClient extends SanityClient { |
@@ -1,5 +0,5 @@ | ||
import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-s6SiVm6L.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-s6SiVm6L.js'; | ||
import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-faRZtx-m.js'; | ||
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-faRZtx-m.js'; | ||
export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it'; | ||
export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-UaelbYZx.js'; | ||
export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-A2-7iucZ.js'; | ||
@@ -6,0 +6,0 @@ class SanityStegaClient extends SanityClient { |
{ | ||
"name": "@sanity/client", | ||
"version": "6.11.4-canary.2", | ||
"version": "6.11.4-canary.3", | ||
"description": "Client for retrieving, creating and patching data from Sanity.io", | ||
@@ -105,2 +105,3 @@ "keywords": [ | ||
"build": "pkg build --strict && pkg --strict && npm run rollup && npm run minify", | ||
"postbuild": "node ./scripts/fix-dts.mjs", | ||
"clean": "npx rimraf dist coverage umd/*.js", | ||
@@ -107,0 +108,0 @@ "coverage": "vitest run --coverage", |
@@ -18,12 +18,9 @@ import {lastValueFrom, type Observable} from 'rxjs' | ||
const clientSymbol = Symbol('#client') | ||
const httpRequestSymbol = Symbol('#httpRequest') | ||
/** @internal */ | ||
export class ObservableAssetsClient { | ||
private [clientSymbol]: ObservableSanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: ObservableSanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -73,3 +70,3 @@ | ||
): Observable<HttpRequestEvent<{document: SanityAssetDocument | SanityImageAssetDocument}>> { | ||
return _upload(this[clientSymbol], this[httpRequestSymbol], assetType, body, options) | ||
return _upload(this.#client, this.#httpRequest, assetType, body, options) | ||
} | ||
@@ -80,7 +77,7 @@ } | ||
export class AssetsClient { | ||
private [clientSymbol]: SanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: SanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: SanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -129,9 +126,3 @@ | ||
): Promise<SanityAssetDocument | SanityImageAssetDocument> { | ||
const observable = _upload( | ||
this[clientSymbol], | ||
this[httpRequestSymbol], | ||
assetType, | ||
body, | ||
options, | ||
) | ||
const observable = _upload(this.#client, this.#httpRequest, assetType, body, options) | ||
return lastValueFrom( | ||
@@ -138,0 +129,0 @@ observable.pipe( |
@@ -22,4 +22,2 @@ import {type Observable} from 'rxjs' | ||
const clientSymbol = Symbol('#client') | ||
/** @internal */ | ||
@@ -199,3 +197,3 @@ export class BasePatch { | ||
export class ObservablePatch extends BasePatch { | ||
private [clientSymbol]?: ObservableSanityClient | ||
#client?: ObservableSanityClient | ||
@@ -208,3 +206,3 @@ constructor( | ||
super(selection, operations) | ||
this[clientSymbol] = client | ||
this.#client = client | ||
} | ||
@@ -216,3 +214,3 @@ | ||
clone(): ObservablePatch { | ||
return new ObservablePatch(this.selection, {...this.operations}, this[clientSymbol]) | ||
return new ObservablePatch(this.selection, {...this.operations}, this.#client) | ||
} | ||
@@ -266,3 +264,3 @@ | ||
> { | ||
if (!this[clientSymbol]) { | ||
if (!this.#client) { | ||
throw new Error( | ||
@@ -276,3 +274,3 @@ 'No `client` passed to patch, either provide one or pass the ' + | ||
const opts = Object.assign({returnFirst, returnDocuments: true}, options) | ||
return this[clientSymbol].mutate<R>({patch: this.serialize()} as Any, opts) | ||
return this.#client.mutate<R>({patch: this.serialize()} as Any, opts) | ||
} | ||
@@ -283,6 +281,6 @@ } | ||
export class Patch extends BasePatch { | ||
private [clientSymbol]?: SanityClient | ||
#client?: SanityClient | ||
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient) { | ||
super(selection, operations) | ||
this[clientSymbol] = client | ||
this.#client = client | ||
} | ||
@@ -294,3 +292,3 @@ | ||
clone(): Patch { | ||
return new Patch(this.selection, {...this.operations}, this[clientSymbol]) | ||
return new Patch(this.selection, {...this.operations}, this.#client) | ||
} | ||
@@ -344,3 +342,3 @@ | ||
> { | ||
if (!this[clientSymbol]) { | ||
if (!this.#client) { | ||
throw new Error( | ||
@@ -354,4 +352,4 @@ 'No `client` passed to patch, either provide one or pass the ' + | ||
const opts = Object.assign({returnFirst, returnDocuments: true}, options) | ||
return this[clientSymbol].mutate<R>({patch: this.serialize()} as Any, opts) | ||
return this.#client.mutate<R>({patch: this.serialize()} as Any, opts) | ||
} | ||
} |
@@ -28,3 +28,2 @@ import type {Observable} from 'rxjs' | ||
const defaultMutateOptions = {returnDocuments: false} | ||
const clientSymbol = Symbol('#client') | ||
@@ -140,6 +139,6 @@ /** @internal */ | ||
export class Transaction extends BaseTransaction { | ||
private [clientSymbol]?: SanityClient | ||
#client?: SanityClient | ||
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string) { | ||
super(operations, transactionId) | ||
this[clientSymbol] = client | ||
this.#client = client | ||
} | ||
@@ -151,3 +150,3 @@ | ||
clone(): Transaction { | ||
return new Transaction([...this.operations], this[clientSymbol], this.trxId) | ||
return new Transaction([...this.operations], this.#client, this.trxId) | ||
} | ||
@@ -199,3 +198,3 @@ | ||
> { | ||
if (!this[clientSymbol]) { | ||
if (!this.#client) { | ||
throw new Error( | ||
@@ -207,3 +206,3 @@ 'No `client` passed to transaction, either provide one or pass the ' + | ||
return this[clientSymbol].mutate<R>( | ||
return this.#client.mutate<R>( | ||
this.serialize() as Any, | ||
@@ -240,3 +239,3 @@ Object.assign({transactionId: this.trxId}, defaultMutateOptions, options || {}), | ||
if (isBuilder) { | ||
const patch = patchOps(new Patch(patchOrDocumentId, {}, this[clientSymbol])) | ||
const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client)) | ||
if (!(patch instanceof Patch)) { | ||
@@ -255,6 +254,6 @@ throw new Error('function passed to `patch()` must return the patch') | ||
export class ObservableTransaction extends BaseTransaction { | ||
private [clientSymbol]?: ObservableSanityClient | ||
#client?: ObservableSanityClient | ||
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string) { | ||
super(operations, transactionId) | ||
this[clientSymbol] = client | ||
this.#client = client | ||
} | ||
@@ -266,3 +265,3 @@ | ||
clone(): ObservableTransaction { | ||
return new ObservableTransaction([...this.operations], this[clientSymbol], this.trxId) | ||
return new ObservableTransaction([...this.operations], this.#client, this.trxId) | ||
} | ||
@@ -314,3 +313,3 @@ | ||
> { | ||
if (!this[clientSymbol]) { | ||
if (!this.#client) { | ||
throw new Error( | ||
@@ -322,3 +321,3 @@ 'No `client` passed to transaction, either provide one or pass the ' + | ||
return this[clientSymbol].mutate<R>( | ||
return this.#client.mutate<R>( | ||
this.serialize() as Any, | ||
@@ -359,3 +358,3 @@ Object.assign({transactionId: this.trxId}, defaultMutateOptions, options || {}), | ||
if (isBuilder) { | ||
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this[clientSymbol])) | ||
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this.#client)) | ||
if (!(patch instanceof ObservablePatch)) { | ||
@@ -362,0 +361,0 @@ throw new Error('function passed to `patch()` must return the patch') |
@@ -8,12 +8,9 @@ import {lastValueFrom, type Observable} from 'rxjs' | ||
const clientSymbol = Symbol('#client') | ||
const httpRequestSymbol = Symbol('#httpRequest') | ||
/** @internal */ | ||
export class ObservableDatasetsClient { | ||
private [clientSymbol]: ObservableSanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: ObservableSanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -28,9 +25,3 @@ | ||
create(name: string, options?: {aclMode?: DatasetAclMode}): Observable<DatasetResponse> { | ||
return _modify<DatasetResponse>( | ||
this[clientSymbol], | ||
this[httpRequestSymbol], | ||
'PUT', | ||
name, | ||
options, | ||
) | ||
return _modify<DatasetResponse>(this.#client, this.#httpRequest, 'PUT', name, options) | ||
} | ||
@@ -45,9 +36,3 @@ | ||
edit(name: string, options?: {aclMode?: DatasetAclMode}): Observable<DatasetResponse> { | ||
return _modify<DatasetResponse>( | ||
this[clientSymbol], | ||
this[httpRequestSymbol], | ||
'PATCH', | ||
name, | ||
options, | ||
) | ||
return _modify<DatasetResponse>(this.#client, this.#httpRequest, 'PATCH', name, options) | ||
} | ||
@@ -61,3 +46,3 @@ | ||
delete(name: string): Observable<{deleted: true}> { | ||
return _modify<{deleted: true}>(this[clientSymbol], this[httpRequestSymbol], 'DELETE', name) | ||
return _modify<{deleted: true}>(this.#client, this.#httpRequest, 'DELETE', name) | ||
} | ||
@@ -69,3 +54,3 @@ | ||
list(): Observable<DatasetsResponse> { | ||
return _request<DatasetsResponse>(this[clientSymbol], this[httpRequestSymbol], { | ||
return _request<DatasetsResponse>(this.#client, this.#httpRequest, { | ||
uri: '/datasets', | ||
@@ -79,7 +64,7 @@ tag: null, | ||
export class DatasetsClient { | ||
private [clientSymbol]: SanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: SanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: SanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -95,3 +80,3 @@ | ||
return lastValueFrom( | ||
_modify<DatasetResponse>(this[clientSymbol], this[httpRequestSymbol], 'PUT', name, options), | ||
_modify<DatasetResponse>(this.#client, this.#httpRequest, 'PUT', name, options), | ||
) | ||
@@ -108,3 +93,3 @@ } | ||
return lastValueFrom( | ||
_modify<DatasetResponse>(this[clientSymbol], this[httpRequestSymbol], 'PATCH', name, options), | ||
_modify<DatasetResponse>(this.#client, this.#httpRequest, 'PATCH', name, options), | ||
) | ||
@@ -119,5 +104,3 @@ } | ||
delete(name: string): Promise<{deleted: true}> { | ||
return lastValueFrom( | ||
_modify<{deleted: true}>(this[clientSymbol], this[httpRequestSymbol], 'DELETE', name), | ||
) | ||
return lastValueFrom(_modify<{deleted: true}>(this.#client, this.#httpRequest, 'DELETE', name)) | ||
} | ||
@@ -130,6 +113,3 @@ | ||
return lastValueFrom( | ||
_request<DatasetsResponse>(this[clientSymbol], this[httpRequestSymbol], { | ||
uri: '/datasets', | ||
tag: null, | ||
}), | ||
_request<DatasetsResponse>(this.#client, this.#httpRequest, {uri: '/datasets', tag: null}), | ||
) | ||
@@ -136,0 +116,0 @@ } |
@@ -7,12 +7,9 @@ import {lastValueFrom, type Observable} from 'rxjs' | ||
const clientSymbol = Symbol('#client') | ||
const httpRequestSymbol = Symbol('#httpRequest') | ||
/** @internal */ | ||
export class ObservableProjectsClient { | ||
private [clientSymbol]: ObservableSanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: ObservableSanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -32,3 +29,3 @@ | ||
const uri = options?.includeMembers === false ? '/projects?includeMembers=false' : '/projects' | ||
return _request<SanityProject[]>(this[clientSymbol], this[httpRequestSymbol], {uri}) | ||
return _request<SanityProject[]>(this.#client, this.#httpRequest, {uri}) | ||
} | ||
@@ -42,5 +39,3 @@ | ||
getById(projectId: string): Observable<SanityProject> { | ||
return _request<SanityProject>(this[clientSymbol], this[httpRequestSymbol], { | ||
uri: `/projects/${projectId}`, | ||
}) | ||
return _request<SanityProject>(this.#client, this.#httpRequest, {uri: `/projects/${projectId}`}) | ||
} | ||
@@ -51,7 +46,7 @@ } | ||
export class ProjectsClient { | ||
private [clientSymbol]: SanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: SanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: SanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -69,5 +64,3 @@ | ||
const uri = options?.includeMembers === false ? '/projects?includeMembers=false' : '/projects' | ||
return lastValueFrom( | ||
_request<SanityProject[]>(this[clientSymbol], this[httpRequestSymbol], {uri}), | ||
) | ||
return lastValueFrom(_request<SanityProject[]>(this.#client, this.#httpRequest, {uri})) | ||
} | ||
@@ -82,7 +75,5 @@ | ||
return lastValueFrom( | ||
_request<SanityProject>(this[clientSymbol], this[httpRequestSymbol], { | ||
uri: `/projects/${projectId}`, | ||
}), | ||
_request<SanityProject>(this.#client, this.#httpRequest, {uri: `/projects/${projectId}`}), | ||
) | ||
} | ||
} |
@@ -54,5 +54,2 @@ import {lastValueFrom, Observable} from 'rxjs' | ||
const clientConfigSymbol = Symbol('#clientConfig') | ||
const httpRequestSymbol = Symbol('#httpRequest') | ||
/** @public */ | ||
@@ -68,4 +65,4 @@ export class ObservableSanityClient { | ||
*/ | ||
private [clientConfigSymbol]: InitializedClientConfig | ||
private [httpRequestSymbol]: HttpRequest | ||
#clientConfig: InitializedClientConfig | ||
#httpRequest: HttpRequest | ||
@@ -80,8 +77,8 @@ /** | ||
this[httpRequestSymbol] = httpRequest | ||
this.#httpRequest = httpRequest | ||
this.assets = new ObservableAssetsClient(this, this[httpRequestSymbol]) | ||
this.datasets = new ObservableDatasetsClient(this, this[httpRequestSymbol]) | ||
this.projects = new ObservableProjectsClient(this, this[httpRequestSymbol]) | ||
this.users = new ObservableUsersClient(this, this[httpRequestSymbol]) | ||
this.assets = new ObservableAssetsClient(this, this.#httpRequest) | ||
this.datasets = new ObservableDatasetsClient(this, this.#httpRequest) | ||
this.projects = new ObservableProjectsClient(this, this.#httpRequest) | ||
this.users = new ObservableUsersClient(this, this.#httpRequest) | ||
} | ||
@@ -93,3 +90,3 @@ | ||
clone(): ObservableSanityClient { | ||
return new ObservableSanityClient(this[httpRequestSymbol], this.config()) | ||
return new ObservableSanityClient(this.#httpRequest, this.config()) | ||
} | ||
@@ -107,6 +104,6 @@ | ||
if (newConfig === undefined) { | ||
return {...this[clientConfigSymbol]} | ||
return {...this.#clientConfig} | ||
} | ||
if (this[clientConfigSymbol] && this[clientConfigSymbol].allowReconfigure === false) { | ||
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) { | ||
throw new Error( | ||
@@ -117,3 +114,3 @@ 'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client', | ||
this[clientConfigSymbol] = initConfig(newConfig, this[clientConfigSymbol] || {}) | ||
this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}) | ||
return this | ||
@@ -129,3 +126,3 @@ } | ||
const thisConfig = this.config() | ||
return new ObservableSanityClient(this[httpRequestSymbol], { | ||
return new ObservableSanityClient(this.#httpRequest, { | ||
...thisConfig, | ||
@@ -202,4 +199,4 @@ ...newConfig, | ||
this, | ||
this[httpRequestSymbol], | ||
this[clientConfigSymbol].stega, | ||
this.#httpRequest, | ||
this.#clientConfig.stega, | ||
query, | ||
@@ -221,3 +218,3 @@ params, | ||
): Observable<SanityDocument<R> | undefined> { | ||
return dataMethods._getDocument<R>(this, this[httpRequestSymbol], id, options) | ||
return dataMethods._getDocument<R>(this, this.#httpRequest, id, options) | ||
} | ||
@@ -238,3 +235,3 @@ | ||
): Observable<(SanityDocument<R> | null)[]> { | ||
return dataMethods._getDocuments<R>(this, this[httpRequestSymbol], ids, options) | ||
return dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options) | ||
} | ||
@@ -308,3 +305,3 @@ | ||
> { | ||
return dataMethods._create<R>(this, this[httpRequestSymbol], document, 'create', options) | ||
return dataMethods._create<R>(this, this.#httpRequest, document, 'create', options) | ||
} | ||
@@ -378,3 +375,3 @@ | ||
> { | ||
return dataMethods._createIfNotExists<R>(this, this[httpRequestSymbol], document, options) | ||
return dataMethods._createIfNotExists<R>(this, this.#httpRequest, document, options) | ||
} | ||
@@ -448,3 +445,3 @@ | ||
> { | ||
return dataMethods._createOrReplace<R>(this, this[httpRequestSymbol], document, options) | ||
return dataMethods._createOrReplace<R>(this, this.#httpRequest, document, options) | ||
} | ||
@@ -567,3 +564,3 @@ | ||
> { | ||
return dataMethods._delete<R>(this, this[httpRequestSymbol], selection, options) | ||
return dataMethods._delete<R>(this, this.#httpRequest, selection, options) | ||
} | ||
@@ -637,3 +634,3 @@ | ||
> { | ||
return dataMethods._mutate<R>(this, this[httpRequestSymbol], operations, options) | ||
return dataMethods._mutate<R>(this, this.#httpRequest, operations, options) | ||
} | ||
@@ -696,3 +693,3 @@ | ||
request<R = Any>(options: RawRequestOptions): Observable<R> { | ||
return dataMethods._request(this, this[httpRequestSymbol], options) | ||
return dataMethods._request(this, this.#httpRequest, options) | ||
} | ||
@@ -736,4 +733,4 @@ | ||
*/ | ||
private [clientConfigSymbol]: InitializedClientConfig | ||
private [httpRequestSymbol]: HttpRequest | ||
#clientConfig: InitializedClientConfig | ||
#httpRequest: HttpRequest | ||
@@ -748,8 +745,8 @@ /** | ||
this[httpRequestSymbol] = httpRequest | ||
this.#httpRequest = httpRequest | ||
this.assets = new AssetsClient(this, this[httpRequestSymbol]) | ||
this.datasets = new DatasetsClient(this, this[httpRequestSymbol]) | ||
this.projects = new ProjectsClient(this, this[httpRequestSymbol]) | ||
this.users = new UsersClient(this, this[httpRequestSymbol]) | ||
this.assets = new AssetsClient(this, this.#httpRequest) | ||
this.datasets = new DatasetsClient(this, this.#httpRequest) | ||
this.projects = new ProjectsClient(this, this.#httpRequest) | ||
this.users = new UsersClient(this, this.#httpRequest) | ||
@@ -763,3 +760,3 @@ this.observable = new ObservableSanityClient(httpRequest, config) | ||
clone(): SanityClient { | ||
return new SanityClient(this[httpRequestSymbol], this.config()) | ||
return new SanityClient(this.#httpRequest, this.config()) | ||
} | ||
@@ -777,6 +774,6 @@ | ||
if (newConfig === undefined) { | ||
return {...this[clientConfigSymbol]} | ||
return {...this.#clientConfig} | ||
} | ||
if (this[clientConfigSymbol] && this[clientConfigSymbol].allowReconfigure === false) { | ||
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) { | ||
throw new Error( | ||
@@ -791,3 +788,3 @@ 'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client', | ||
this[clientConfigSymbol] = initConfig(newConfig, this[clientConfigSymbol] || {}) | ||
this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}) | ||
return this | ||
@@ -803,3 +800,3 @@ } | ||
const thisConfig = this.config() | ||
return new SanityClient(this[httpRequestSymbol], { | ||
return new SanityClient(this.#httpRequest, { | ||
...thisConfig, | ||
@@ -877,4 +874,4 @@ ...newConfig, | ||
this, | ||
this[httpRequestSymbol], | ||
this[clientConfigSymbol].stega, | ||
this.#httpRequest, | ||
this.#clientConfig.stega, | ||
query, | ||
@@ -897,3 +894,3 @@ params, | ||
): Promise<SanityDocument<R> | undefined> { | ||
return lastValueFrom(dataMethods._getDocument<R>(this, this[httpRequestSymbol], id, options)) | ||
return lastValueFrom(dataMethods._getDocument<R>(this, this.#httpRequest, id, options)) | ||
} | ||
@@ -914,3 +911,3 @@ | ||
): Promise<(SanityDocument<R> | null)[]> { | ||
return lastValueFrom(dataMethods._getDocuments<R>(this, this[httpRequestSymbol], ids, options)) | ||
return lastValueFrom(dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options)) | ||
} | ||
@@ -985,3 +982,3 @@ | ||
return lastValueFrom( | ||
dataMethods._create<R>(this, this[httpRequestSymbol], document, 'create', options), | ||
dataMethods._create<R>(this, this.#httpRequest, document, 'create', options), | ||
) | ||
@@ -1057,3 +1054,3 @@ } | ||
return lastValueFrom( | ||
dataMethods._createIfNotExists<R>(this, this[httpRequestSymbol], document, options), | ||
dataMethods._createIfNotExists<R>(this, this.#httpRequest, document, options), | ||
) | ||
@@ -1129,3 +1126,3 @@ } | ||
return lastValueFrom( | ||
dataMethods._createOrReplace<R>(this, this[httpRequestSymbol], document, options), | ||
dataMethods._createOrReplace<R>(this, this.#httpRequest, document, options), | ||
) | ||
@@ -1249,3 +1246,3 @@ } | ||
> { | ||
return lastValueFrom(dataMethods._delete<R>(this, this[httpRequestSymbol], selection, options)) | ||
return lastValueFrom(dataMethods._delete<R>(this, this.#httpRequest, selection, options)) | ||
} | ||
@@ -1319,3 +1316,3 @@ | ||
> { | ||
return lastValueFrom(dataMethods._mutate<R>(this, this[httpRequestSymbol], operations, options)) | ||
return lastValueFrom(dataMethods._mutate<R>(this, this.#httpRequest, operations, options)) | ||
} | ||
@@ -1380,3 +1377,3 @@ | ||
request<R = Any>(options: RawRequestOptions): Promise<R> { | ||
return lastValueFrom(dataMethods._request<R>(this, this[httpRequestSymbol], options)) | ||
return lastValueFrom(dataMethods._request<R>(this, this.#httpRequest, options)) | ||
} | ||
@@ -1395,5 +1392,3 @@ | ||
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any> { | ||
return lastValueFrom( | ||
dataMethods._dataRequest(this, this[httpRequestSymbol], endpoint, body, options), | ||
) | ||
return lastValueFrom(dataMethods._dataRequest(this, this.#httpRequest, endpoint, body, options)) | ||
} | ||
@@ -1400,0 +1395,0 @@ |
@@ -7,12 +7,9 @@ import {lastValueFrom, type Observable} from 'rxjs' | ||
const clientSymbol = Symbol('#client') | ||
const httpRequestSymbol = Symbol('#httpRequest') | ||
/** @public */ | ||
export class ObservableUsersClient { | ||
private [clientSymbol]: ObservableSanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: ObservableSanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -29,4 +26,4 @@ | ||
return _request<T extends 'me' ? CurrentSanityUser : SanityUser>( | ||
this[clientSymbol], | ||
this[httpRequestSymbol], | ||
this.#client, | ||
this.#httpRequest, | ||
{uri: `/users/${id}`}, | ||
@@ -39,7 +36,7 @@ ) | ||
export class UsersClient { | ||
private [clientSymbol]: SanityClient | ||
private [httpRequestSymbol]: HttpRequest | ||
#client: SanityClient | ||
#httpRequest: HttpRequest | ||
constructor(client: SanityClient, httpRequest: HttpRequest) { | ||
this[clientSymbol] = client | ||
this[httpRequestSymbol] = httpRequest | ||
this.#client = client | ||
this.#httpRequest = httpRequest | ||
} | ||
@@ -56,11 +53,7 @@ | ||
return lastValueFrom( | ||
_request<T extends 'me' ? CurrentSanityUser : SanityUser>( | ||
this[clientSymbol], | ||
this[httpRequestSymbol], | ||
{ | ||
uri: `/users/${id}`, | ||
}, | ||
), | ||
_request<T extends 'me' ? CurrentSanityUser : SanityUser>(this.#client, this.#httpRequest, { | ||
uri: `/users/${id}`, | ||
}), | ||
) | ||
} | ||
} |
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 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
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
2138550
27607