🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@sanity/client

Package Overview
Dependencies
Maintainers
113
Versions
1151
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
7.15.0
to
7.16.0
+1
-1
package.json
{
"name": "@sanity/client",
"version": "7.15.0",
"version": "7.16.0",
"description": "Client for retrieving, creating and patching data from Sanity.io",

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

@@ -5,3 +5,11 @@ import {lastValueFrom, type Observable} from 'rxjs'

import type {ObservableSanityClient, SanityClient} from '../SanityClient'
import type {DatasetAclMode, DatasetResponse, DatasetsResponse, HttpRequest} from '../types'
import type {
DatasetCreateOptions,
DatasetEditOptions,
DatasetResponse,
DatasetsResponse,
EmbeddingsSettings,
EmbeddingsSettingsBody,
HttpRequest,
} from '../types'
import * as validate from '../validators'

@@ -22,5 +30,5 @@

* @param name - Name of the dataset to create
* @param options - Options for the dataset
* @param options - Options for the dataset, including optional embeddings configuration
*/
create(name: string, options?: {aclMode?: DatasetAclMode}): Observable<DatasetResponse> {
create(name: string, options?: DatasetCreateOptions): Observable<DatasetResponse> {
return _modify<DatasetResponse>(this.#client, this.#httpRequest, 'PUT', name, options)

@@ -35,3 +43,3 @@ }

*/
edit(name: string, options?: {aclMode?: DatasetAclMode}): Observable<DatasetResponse> {
edit(name: string, options?: DatasetEditOptions): Observable<DatasetResponse> {
return _modify<DatasetResponse>(this.#client, this.#httpRequest, 'PATCH', name, options)

@@ -66,2 +74,33 @@ }

}
/**
* Get embeddings settings for a dataset
*
* @param name - Name of the dataset
*/
getEmbeddingsSettings(name: string): Observable<EmbeddingsSettings> {
validate.resourceGuard('dataset', this.#client.config())
validate.dataset(name)
return _request<EmbeddingsSettings>(this.#client, this.#httpRequest, {
uri: _embeddingsSettingsUri(this.#client, name),
tag: null,
})
}
/**
* Edit embeddings settings for a dataset
*
* @param name - Name of the dataset
* @param settings - Embeddings settings to apply
*/
editEmbeddingsSettings(name: string, settings: EmbeddingsSettingsBody): Observable<void> {
validate.resourceGuard('dataset', this.#client.config())
validate.dataset(name)
return _request<void>(this.#client, this.#httpRequest, {
method: 'PUT',
uri: _embeddingsSettingsUri(this.#client, name),
body: settings,
tag: null,
})
}
}

@@ -82,5 +121,5 @@

* @param name - Name of the dataset to create
* @param options - Options for the dataset
* @param options - Options for the dataset, including optional embeddings configuration
*/
create(name: string, options?: {aclMode?: DatasetAclMode}): Promise<DatasetResponse> {
create(name: string, options?: DatasetCreateOptions): Promise<DatasetResponse> {
validate.resourceGuard('dataset', this.#client.config())

@@ -98,3 +137,3 @@ return lastValueFrom(

*/
edit(name: string, options?: {aclMode?: DatasetAclMode}): Promise<DatasetResponse> {
edit(name: string, options?: DatasetEditOptions): Promise<DatasetResponse> {
validate.resourceGuard('dataset', this.#client.config())

@@ -132,4 +171,50 @@ return lastValueFrom(

}
/**
* Get embeddings settings for a dataset
*
* @param name - Name of the dataset
*/
getEmbeddingsSettings(name: string): Promise<EmbeddingsSettings> {
validate.resourceGuard('dataset', this.#client.config())
validate.dataset(name)
return lastValueFrom(
_request<EmbeddingsSettings>(this.#client, this.#httpRequest, {
uri: _embeddingsSettingsUri(this.#client, name),
tag: null,
}),
)
}
/**
* Edit embeddings settings for a dataset
*
* @param name - Name of the dataset
* @param settings - Embeddings settings to apply
*/
editEmbeddingsSettings(name: string, settings: EmbeddingsSettingsBody): Promise<void> {
validate.resourceGuard('dataset', this.#client.config())
validate.dataset(name)
return lastValueFrom(
_request<void>(this.#client, this.#httpRequest, {
method: 'PUT',
uri: _embeddingsSettingsUri(this.#client, name),
body: settings,
tag: null,
}),
)
}
}
function _embeddingsSettingsUri(
client: SanityClient | ObservableSanityClient,
name: string,
): string {
const config = client.config()
if (config.useProjectHostname === false) {
return `/projects/${config.projectId}/datasets/${name}/settings/embeddings`
}
return `/datasets/${name}/settings/embeddings`
}
function _modify<R = unknown>(

@@ -140,3 +225,3 @@ client: SanityClient | ObservableSanityClient,

name: string,
options?: {aclMode?: DatasetAclMode},
options?: DatasetCreateOptions | DatasetEditOptions,
) {

@@ -143,0 +228,0 @@ validate.resourceGuard('dataset', client.config())

@@ -467,2 +467,29 @@ // deno-lint-ignore-file no-empty-interface

/** @public */
export type DatasetCreateOptions = {
aclMode?: DatasetAclMode
embeddings?: {
enabled: boolean
projection?: string
}
}
/** @public */
export type DatasetEditOptions = {
aclMode?: DatasetAclMode
}
/** @public */
export type EmbeddingsSettings = {
enabled: boolean
projection?: string
status: string
}
/** @public */
export type EmbeddingsSettingsBody = {
enabled: boolean
projection?: string
}
/** @public */
export type DatasetResponse = {datasetName: string; aclMode: DatasetAclMode}

@@ -469,0 +496,0 @@ /** @public */

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

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

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

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

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

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