@sanity/client
Advanced tools
+1
-1
| { | ||
| "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()) |
+27
-0
@@ -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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
4951716
0.81%58383
0.88%