@sanity/client 8.2.0 → 8.3.0

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/README.md CHANGED
@@ -2604,7 +2604,7 @@ const reply = await client.collaboration.comments.create({
2604
2604
  })
2605
2605
  ```
2606
2606
 
2607
- Field comments pass a `path`. Inline comments also pass a `range` (block `_key` + character offset):
2607
+ Field comments pass a `path`. Inline comments also pass a `range` (block `_key` + character offset). An optional `fieldValue` is Portable Text covering that `range` (a slice or the full field); when set with `range`, the `range` is resolved from those blocks instead of from the live document:
2608
2608
 
2609
2609
  ```js
2610
2610
  await client.collaboration.comments.create({
@@ -2625,7 +2625,7 @@ When querying, the field is stored as `target.path.field`, so filter with `targe
2625
2625
 
2626
2626
  #### Updating and deleting comments
2627
2627
 
2628
- `update()` can change `message`, `status`, and/or `range`. Status changes cascade to replies. A `range` re-anchors an inline comment within the field and source document it already targets; pass `null` to clear the selection:
2628
+ `update()` can change `message`, `status`, and/or `range`. Status changes cascade to replies. A `range` re-anchors an inline comment within the field it already targets; pass `null` to turn a text-level comment into a field-level one. An optional `fieldValue` may be passed with a non-null `range` for the same purpose as on create (not alone or with `range: null`):
2629
2629
 
2630
2630
  ```js
2631
2631
  await client.collaboration.comments.update('comment-1', {status: 'resolved'})
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { d as ResolveStudioUrl, f as StegaConfig, g as StudioUrl, h as StudioBaseUrl, i as ContentSourceMapParsedPathKeyedSegment, l as InitializedStegaConfig, m as StudioBaseRoute, p as StegaConfigRequiredKeys, r as ContentSourceMapParsedPath, s as FilterDefault, u as Logger } from "./types-CfGzbXrl.js";
2
- import { $ as DisconnectEvent, $n as UploadClientConfig, $r as CollaborationCommentRange, $t as QueryWithoutParams, A as ContentSourceMapMappings, Ai as DocumentAgentActionParam, An as SanityReference, Ar as ObservableProjectsClient, At as MediaLibraryAssetVersion, B as CreateVersionAction, Bn as TransactionAllDocumentIdsMutationOptions, Br as ObservableTransaction, Bt as MutationSelection, C as ContentSourceMap, Ci as PatchTarget, Cn as SanityDocument, Cr as GenerateTarget, Ct as LiveEventGoAway, D as ContentSourceMapDocuments, Di as AgentActionPathSegment, Dn as SanityProject, Dr as SanityClient, Dt as LiveEventWelcome, E as ContentSourceMapDocumentValueSource, Ei as AgentActionPath, En as SanityImagePalette, Er as ObservableSanityClient, Et as LiveEventRestart, F as ContentSourceMapValueMapping, Fn as StackablePerspective, Fr as InvokeFunctionRequest, Ft as Mutation, G as DatasetResponse, Gn as UnarchiveReleaseAction, Gr as Patch, Gt as PatchOperations, H as DatasetAclMode, Hn as TransactionFirstDocumentIdMutationOptions, Hr as Transaction, Ht as OpenEvent, I as CreateAction, In as StillImageFormat, Ir as DatasetsClient, It as MutationError, J as DeleteReleaseAction, Jn as UnpublishAction, Jr as ObservableCollaborationCommentsClient, Jt as PublishReleaseAction, K as DatasetsResponse, Kn as UnfilteredResponseQueryOptions, Kr as LiveClient, Kt as PatchSelection, L as CreateReleaseAction, Ln as StoryboardTransformOptions, Lr as ObservableDatasetsClient, Lt as MutationErrorItem, M as ContentSourceMapRemoteDocument, Mi as GroqAgentActionParam, Mn as ScheduleReleaseAction, Mr as MediaLibraryVideoClient, Mt as MediaLibraryVideoPlaybackTransformations, N as ContentSourceMapSource, Nn as SingleActionResult, Nr as ObservableMediaLibraryVideoClient, Nt as MultipleActionResult, O as ContentSourceMapLiteralSource, Oi as AgentActionTarget, On as SanityProjectMember, Or as ObservableUsersClient, Ot as MediaLibraryAssetDocument, P as ContentSourceMapUnknownSource, Pn as SingleMutationResult, Pr as InvokeFunctionEvent, Pt as MultipleMutationResult, Q as DiscardVersionAction, Qn as UploadBody, Qr as CollaborationCommentPortableTextBlock, Qt as QueryParseError, R as CreateVariantAction, Rn as SyncTag, Rr as BaseTransaction, Rt as MutationEvent, S as ClientVariantConditions, Si as PatchOperation, Sn as SanityAssetDocument, Sr as GenerateOperation, St as LiveEvent, T as ContentSourceMapDocumentBase, Ti as AgentActionParams, Tn as SanityImageAssetDocument, Tr as GenerateTargetInclude, Tt as LiveEventReconnect, U as DatasetCreateOptions, Un as TransactionFirstDocumentMutationOptions, Ur as BasePatch, Ut as PartialExcept, V as CurrentSanityUser, Vn as TransactionAllDocumentsMutationOptions, Vr as PatchBuilder, Vt as MutationSelectionQueryParams, W as DatasetEditOptions, Wn as TransactionMutationOptions, Wr as ObservablePatch, Wt as PatchMutationOperation, X as DeleteVariantDefinitionAction, Xn as UnpublishVersionAction, Xr as CollaborationCommentDocument, Xt as QueryOptions, Y as DeleteVariantAction, Yn as UnpublishVariantAction, Yr as CollaborationCommentCreate, Yt as PublishVariantAction, Z as DiscardAction, Zn as UnscheduleReleaseAction, Zr as CollaborationCommentMessage, Zt as QueryParams, _ as ChannelErrorEvent, _i as TransformTarget, _n as Requester, _r as VideoSubtitleInfoPublic, _t as InsertPatch, a as AllDocumentsMutationOptions, ai as CollaborationCommentsListenOptions, an as ReleaseCardinality, ar as VersionAction, at as EditableReleaseDocument, b as ClientReturn, bi as PromptRequest, bn as ResumableListenEventNames, br as WelcomeEvent, bt as ListenOptions, c as Any, ci as _listen, cn as ReleaseState, cr as VideoPlaybackInfoItemPublic, ct as ErrorProps, d as AssetMetadataType, di as TranslateDocument, dn as ReplaceVersionAction, dr as VideoPlaybackInfoSigned, dt as FirstDocumentMutationOptions, ei as CollaborationCommentReactionShortName, en as RawQueryResponse, er as UploadEvent, et as EXPERIMENTAL_API_WARNING, f as AttributeSet, fi as TranslateTarget, fn as RequestHandler, fr as VideoPlaybackTokens, ft as FitMode, g as BaseMutationOptions, gi as TransformOperation, gn as RequestUrlOptions, gr as VideoSubtitleInfo, gt as InitializedClientConfig, h as BaseActionOptions, hi as TransformDocument, hn as RequestOptions, hr as VideoRenditionInfoSigned, ht as ImportReleaseAction, i as AllDocumentIdsMutationOptions, ii as CollaborationCommentUpdate, in as ReleaseAction, ir as VariantDefinitionAction, it as EditVariantDefinitionAction, j as ContentSourceMapPaths, ji as FieldAgentActionParam, jn as SanityUser, jr as ProjectsClient, jt as MediaLibraryPlaybackInfoOptions, k as ContentSourceMapMapping, ki as ConstantAgentActionParam, kn as SanityQueries, kr as UsersClient, kt as MediaLibraryAssetInstanceIdentifier, l as ApiError, li as AssetsClient, ln as ReleaseType, lr as VideoPlaybackInfoItemSigned, lt as FilteredResponseQueryOptions, m as AuthProviderResponse, mi as ImageDescriptionOperation, mn as RequestObservableOptions, mr as VideoRenditionInfoPublic, mt as IdentifiedSanityDocumentStub, n as ActionError, ni as CollaborationCommentStatus, nn as RawRequestOptions, nr as UploadResponseEvent, nt as EditReleaseAction, o as AnimatedImageFormat, oi as CollaborationCommentsRequestOptions, on as ReleaseDocument, or as VideoPlaybackInfo, ot as EmbeddingsSettings, p as AuthProvider, pi as TranslateTargetInclude, pn as RequestHandlerOptions, pr as VideoRenditionInfo, pt as HttpRequest, q as DeleteAction, qn as UnfilteredResponseWithoutQuery, qr as CollaborationCommentsClient, qt as PublishAction, r as ActionErrorItem, ri as CollaborationCommentTarget, rn as ReconnectEvent, rr as VariantAction, rt as EditVariantAction, s as AnimatedTransformOptions, si as CollaborationCommentsWriteOptions, sn as ReleaseId, sr as VideoPlaybackInfoItem, st as EmbeddingsSettingsBody, t as Action, ti as CollaborationCommentSelection, tn as RawQuerylessQueryResponse, tr as UploadProgressEvent, tt as EditAction, u as ArchiveReleaseAction, ui as ObservableAssetsClient, un as ReplaceDraftAction, ur as VideoPlaybackInfoPublic, ut as FirstDocumentIdMutationOptions, v as ClientConfig, vi as TransformTargetDocument, vn as ResetEvent, vr as VideoSubtitleInfoSigned, vt as ListenEvent, w as ContentSourceMapDocument, wi as AgentActionParam, wn as SanityDocumentStub, wr as GenerateTargetDocument, wt as LiveEventMessage, x as ClientVariant, xi as PatchDocument, xn as ResumableListenOptions, xr as GenerateInstruction, xt as ListenParams, y as ClientPerspective, yi as TransformTargetInclude, yn as ResponseQueryOptions, yr as WelcomeBackEvent, yt as ListenEventName, z as CreateVariantDefinitionAction, zn as ThumbnailTransformOptions, zr as ObservablePatchBuilder, zt as MutationOperation } from "./types-nJhm5Nyq.js";
2
+ import { $ as DisconnectEvent, $n as UploadClientConfig, $r as CollaborationCommentMessage, $t as QueryWithoutParams, A as ContentSourceMapMappings, Ai as AgentActionTarget, An as SanityReference, Ar as ObservableProjectsClient, At as MediaLibraryAssetVersion, B as CreateVersionAction, Bn as TransactionAllDocumentIdsMutationOptions, Br as ObservablePatchBuilder, Bt as MutationSelection, C as ContentSourceMap, Ci as PatchDocument, Cn as SanityDocument, Cr as GenerateTarget, Ct as LiveEventGoAway, D as ContentSourceMapDocuments, Di as AgentActionParams, Dn as SanityProject, Dr as SanityClient, Dt as LiveEventWelcome, E as ContentSourceMapDocumentValueSource, Ei as AgentActionParam, En as SanityImagePalette, Er as ObservableSanityClient, Et as LiveEventRestart, F as ContentSourceMapValueMapping, Fn as StackablePerspective, Fr as InvokeFunctionOptions, Ft as Mutation, G as DatasetResponse, Gn as UnarchiveReleaseAction, Gr as ObservablePatch, Gt as PatchOperations, H as DatasetAclMode, Hn as TransactionFirstDocumentIdMutationOptions, Hr as PatchBuilder, Ht as OpenEvent, I as CreateAction, In as StillImageFormat, Ir as InvokeFunctionRequest, It as MutationError, J as DeleteReleaseAction, Jn as UnpublishAction, Jr as CollaborationCommentsClient, Jt as PublishReleaseAction, K as DatasetsResponse, Kn as UnfilteredResponseQueryOptions, Kr as Patch, Kt as PatchSelection, L as CreateReleaseAction, Ln as StoryboardTransformOptions, Lr as DatasetsClient, Lt as MutationErrorItem, M as ContentSourceMapRemoteDocument, Mi as DocumentAgentActionParam, Mn as ScheduleReleaseAction, Mr as MediaLibraryVideoClient, Mt as MediaLibraryVideoPlaybackTransformations, N as ContentSourceMapSource, Ni as FieldAgentActionParam, Nn as SingleActionResult, Nr as ObservableMediaLibraryVideoClient, Nt as MultipleActionResult, O as ContentSourceMapLiteralSource, Oi as AgentActionPath, On as SanityProjectMember, Or as ObservableUsersClient, Ot as MediaLibraryAssetDocument, P as ContentSourceMapUnknownSource, Pi as GroqAgentActionParam, Pn as SingleMutationResult, Pr as InvokeFunctionEvent, Pt as MultipleMutationResult, Q as DiscardVersionAction, Qn as UploadBody, Qr as CollaborationCommentFieldValue, Qt as QueryParseError, R as CreateVariantAction, Rn as SyncTag, Rr as ObservableDatasetsClient, Rt as MutationEvent, S as ClientVariantConditions, Si as PromptRequest, Sn as SanityAssetDocument, Sr as GenerateOperation, St as LiveEvent, T as ContentSourceMapDocumentBase, Ti as PatchTarget, Tn as SanityImageAssetDocument, Tr as GenerateTargetInclude, Tt as LiveEventReconnect, U as DatasetCreateOptions, Un as TransactionFirstDocumentMutationOptions, Ur as Transaction, Ut as PartialExcept, V as CurrentSanityUser, Vn as TransactionAllDocumentsMutationOptions, Vr as ObservableTransaction, Vt as MutationSelectionQueryParams, W as DatasetEditOptions, Wn as TransactionMutationOptions, Wr as BasePatch, Wt as PatchMutationOperation, X as DeleteVariantDefinitionAction, Xn as UnpublishVersionAction, Xr as CollaborationCommentCreate, Xt as QueryOptions, Y as DeleteVariantAction, Yn as UnpublishVariantAction, Yr as ObservableCollaborationCommentsClient, Yt as PublishVariantAction, Z as DiscardAction, Zn as UnscheduleReleaseAction, Zr as CollaborationCommentDocument, Zt as QueryParams, _ as ChannelErrorEvent, _i as TransformDocument, _n as Requester, _r as VideoSubtitleInfoPublic, _t as InsertPatch, a as AllDocumentsMutationOptions, ai as CollaborationCommentTarget, an as ReleaseCardinality, ar as VersionAction, at as EditableReleaseDocument, b as ClientReturn, bi as TransformTargetDocument, bn as ResumableListenEventNames, br as WelcomeEvent, bt as ListenOptions, c as Any, ci as CollaborationCommentsRequestOptions, cn as ReleaseState, cr as VideoPlaybackInfoItemPublic, ct as ErrorProps, d as AssetMetadataType, di as AssetsClient, dn as ReplaceVersionAction, dr as VideoPlaybackInfoSigned, dt as FirstDocumentMutationOptions, ei as CollaborationCommentPortableTextBlock, en as RawQueryResponse, er as UploadEvent, et as EXPERIMENTAL_API_WARNING, f as AttributeSet, fi as ObservableAssetsClient, fn as RequestHandler, fr as VideoPlaybackTokens, ft as FitMode, g as BaseMutationOptions, gi as ImageDescriptionOperation, gn as RequestUrlOptions, gr as VideoSubtitleInfo, gt as InitializedClientConfig, h as BaseActionOptions, hi as TranslateTargetInclude, hn as RequestOptions, hr as VideoRenditionInfoSigned, ht as ImportReleaseAction, i as AllDocumentIdsMutationOptions, ii as CollaborationCommentStatus, in as ReleaseAction, ir as VariantDefinitionAction, it as EditVariantDefinitionAction, j as ContentSourceMapPaths, ji as ConstantAgentActionParam, jn as SanityUser, jr as ProjectsClient, jt as MediaLibraryPlaybackInfoOptions, k as ContentSourceMapMapping, ki as AgentActionPathSegment, kn as SanityQueries, kr as UsersClient, kt as MediaLibraryAssetInstanceIdentifier, l as ApiError, li as CollaborationCommentsWriteOptions, ln as ReleaseType, lr as VideoPlaybackInfoItemSigned, lt as FilteredResponseQueryOptions, m as AuthProviderResponse, mi as TranslateTarget, mn as RequestObservableOptions, mr as VideoRenditionInfoPublic, mt as IdentifiedSanityDocumentStub, n as ActionError, ni as CollaborationCommentReactionShortName, nn as RawRequestOptions, nr as UploadResponseEvent, nt as EditReleaseAction, o as AnimatedImageFormat, oi as CollaborationCommentUpdate, on as ReleaseDocument, or as VideoPlaybackInfo, ot as EmbeddingsSettings, p as AuthProvider, pi as TranslateDocument, pn as RequestHandlerOptions, pr as VideoRenditionInfo, pt as HttpRequest, q as DeleteAction, qn as UnfilteredResponseWithoutQuery, qr as LiveClient, qt as PublishAction, r as ActionErrorItem, ri as CollaborationCommentSelection, rn as ReconnectEvent, rr as VariantAction, rt as EditVariantAction, s as AnimatedTransformOptions, si as CollaborationCommentsListenOptions, sn as ReleaseId, sr as VideoPlaybackInfoItem, st as EmbeddingsSettingsBody, t as Action, ti as CollaborationCommentRange, tn as RawQuerylessQueryResponse, tr as UploadProgressEvent, tt as EditAction, u as ArchiveReleaseAction, ui as _listen, un as ReplaceDraftAction, ur as VideoPlaybackInfoPublic, ut as FirstDocumentIdMutationOptions, v as ClientConfig, vi as TransformOperation, vn as ResetEvent, vr as VideoSubtitleInfoSigned, vt as ListenEvent, w as ContentSourceMapDocument, wi as PatchOperation, wn as SanityDocumentStub, wr as GenerateTargetDocument, wt as LiveEventMessage, x as ClientVariant, xi as TransformTargetInclude, xn as ResumableListenOptions, xr as GenerateInstruction, xt as ListenParams, y as ClientPerspective, yi as TransformTarget, yn as ResponseQueryOptions, yr as WelcomeBackEvent, yt as ListenEventName, z as CreateVariantDefinitionAction, zn as ThumbnailTransformOptions, zr as BaseTransaction, zt as MutationOperation } from "./types-0x2hPfhJ.js";
3
3
  import { FetchFunction, RequestOptions as RequestOptions$1, TimeoutErrorLike, isTimeoutError } from "get-it";
4
4
  import { Observable } from "rxjs";
5
5
  import { EventSourceConstructor } from "eventsource";
@@ -181,5 +181,5 @@ declare const createClient: (config: ClientConfig) => SanityClient;
181
181
  * @deprecated Use the named export `createClient` instead of the `default` export
182
182
  */
183
183
  declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient;
184
- export { Action, ActionError, ActionErrorItem, type AgentActionParam, type AgentActionParams, type AgentActionPath, type AgentActionPathSegment, type AgentActionTarget, AllDocumentIdsMutationOptions, AllDocumentsMutationOptions, AnimatedImageFormat, AnimatedTransformOptions, Any, ApiError, ArchiveReleaseAction, AssetMetadataType, type AssetsClient, AttributeSet, AuthProvider, AuthProviderResponse, BaseActionOptions, BaseMutationOptions, BasePatch, BaseTransaction, ChannelError, ChannelErrorEvent, ClientConfig, ClientError, ClientPerspective, ClientReturn, ClientVariant, ClientVariantConditions, type CollaborationCommentCreate, type CollaborationCommentDocument, type CollaborationCommentMessage, type CollaborationCommentPortableTextBlock, type CollaborationCommentRange, type CollaborationCommentReactionShortName, type CollaborationCommentSelection, type CollaborationCommentStatus, type CollaborationCommentTarget, type CollaborationCommentUpdate, type CollaborationCommentsClient, type CollaborationCommentsListenOptions, type CollaborationCommentsRequestOptions, type CollaborationCommentsWriteOptions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantAction, EditVariantDefinitionAction, EditableReleaseDocument, EmbeddingsSettings, EmbeddingsSettingsBody, ErrorProps, type EventSourceEvent, type EventSourceInstance, type FieldAgentActionParam, type FilterDefault, FilteredResponseQueryOptions, FirstDocumentIdMutationOptions, FirstDocumentMutationOptions, FitMode, type GenerateInstruction, type GenerateOperation, type GenerateTarget, type GenerateTargetDocument, type GenerateTargetInclude, type GroqAgentActionParam, type HttpError, HttpRequest, IdentifiedSanityDocumentStub, type ImageDescriptionOperation, ImportReleaseAction, InitializedClientConfig, type InitializedStegaConfig, InsertPatch, type InvokeFunctionEvent, type InvokeFunctionRequest, ListenEvent, ListenEventName, ListenOptions, ListenParams, type LiveClient, LiveEvent, LiveEventGoAway, LiveEventMessage, LiveEventReconnect, LiveEventRestart, LiveEventWelcome, type Logger, MediaLibraryAssetDocument, MediaLibraryAssetInstanceIdentifier, MediaLibraryAssetVersion, MediaLibraryPlaybackInfoOptions, type MediaLibraryVideoClient, MediaLibraryVideoPlaybackTransformations, MessageError, MessageParseError, MultipleActionResult, MultipleMutationResult, Mutation, MutationError, MutationErrorItem, MutationEvent, MutationOperation, MutationSelection, MutationSelectionQueryParams, type ObservableAssetsClient, type ObservableCollaborationCommentsClient, type ObservableDatasetsClient, type ObservableMediaLibraryVideoClient, ObservablePatch, ObservablePatchBuilder, type ObservableProjectsClient, ObservableSanityClient, ObservableTransaction, type ObservableUsersClient, OpenEvent, PartialExcept, Patch, PatchBuilder, type PatchDocument, PatchMutationOperation, type PatchOperation, PatchOperations, PatchSelection, type PatchTarget, type ProjectsClient, type PromptRequest, PublishAction, PublishReleaseAction, PublishVariantAction, QueryOptions, QueryParams, QueryParseError, QueryWithoutParams, RawQueryResponse, RawQuerylessQueryResponse, RawRequestOptions, ReconnectEvent, ReleaseAction, ReleaseCardinality, ReleaseDocument, ReleaseId, ReleaseState, ReleaseType, ReplaceDraftAction, ReplaceVersionAction, RequestHandler, RequestHandlerOptions, RequestObservableOptions, RequestOptions, RequestUrlOptions, Requester, ResetEvent, type ResolveStudioUrl, ResponseQueryOptions, ResumableListenEventNames, ResumableListenOptions, SanityAssetDocument, SanityClient, SanityDocument, SanityDocumentStub, SanityImageAssetDocument, SanityImagePalette, SanityProject, SanityProjectMember, SanityQueries, SanityReference, SanityUser, ScheduleReleaseAction, ServerError, type ServerSentEvent, SingleActionResult, SingleMutationResult, StackablePerspective, type StegaConfig, type StegaConfigRequiredKeys, StillImageFormat, StoryboardTransformOptions, type StudioBaseRoute, type StudioBaseUrl, type StudioUrl, SyncTag, ThumbnailTransformOptions, type TimeoutErrorLike, Transaction, TransactionAllDocumentIdsMutationOptions, TransactionAllDocumentsMutationOptions, TransactionFirstDocumentIdMutationOptions, TransactionFirstDocumentMutationOptions, TransactionMutationOptions, type TransformDocument, type TransformOperation, type TransformTarget, type TransformTargetDocument, type TransformTargetInclude, type TranslateDocument, type TranslateTarget, type TranslateTargetInclude, UnarchiveReleaseAction, UnfilteredResponseQueryOptions, UnfilteredResponseWithoutQuery, UnpublishAction, UnpublishVariantAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantAction, VariantDefinitionAction, VersionAction, VideoPlaybackInfo, VideoPlaybackInfoItem, VideoPlaybackInfoItemPublic, VideoPlaybackInfoItemSigned, VideoPlaybackInfoPublic, VideoPlaybackInfoSigned, VideoPlaybackTokens, VideoRenditionInfo, VideoRenditionInfoPublic, VideoRenditionInfoSigned, VideoSubtitleInfo, VideoSubtitleInfoPublic, VideoSubtitleInfoSigned, WelcomeBackEvent, WelcomeEvent, type _listen, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, isTimeoutError, requester, validateApiPerspective };
184
+ export { Action, ActionError, ActionErrorItem, type AgentActionParam, type AgentActionParams, type AgentActionPath, type AgentActionPathSegment, type AgentActionTarget, AllDocumentIdsMutationOptions, AllDocumentsMutationOptions, AnimatedImageFormat, AnimatedTransformOptions, Any, ApiError, ArchiveReleaseAction, AssetMetadataType, type AssetsClient, AttributeSet, AuthProvider, AuthProviderResponse, BaseActionOptions, BaseMutationOptions, BasePatch, BaseTransaction, ChannelError, ChannelErrorEvent, ClientConfig, ClientError, ClientPerspective, ClientReturn, ClientVariant, ClientVariantConditions, type CollaborationCommentCreate, type CollaborationCommentDocument, type CollaborationCommentFieldValue, type CollaborationCommentMessage, type CollaborationCommentPortableTextBlock, type CollaborationCommentRange, type CollaborationCommentReactionShortName, type CollaborationCommentSelection, type CollaborationCommentStatus, type CollaborationCommentTarget, type CollaborationCommentUpdate, type CollaborationCommentsClient, type CollaborationCommentsListenOptions, type CollaborationCommentsRequestOptions, type CollaborationCommentsWriteOptions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantAction, EditVariantDefinitionAction, EditableReleaseDocument, EmbeddingsSettings, EmbeddingsSettingsBody, ErrorProps, type EventSourceEvent, type EventSourceInstance, type FieldAgentActionParam, type FilterDefault, FilteredResponseQueryOptions, FirstDocumentIdMutationOptions, FirstDocumentMutationOptions, FitMode, type GenerateInstruction, type GenerateOperation, type GenerateTarget, type GenerateTargetDocument, type GenerateTargetInclude, type GroqAgentActionParam, type HttpError, HttpRequest, IdentifiedSanityDocumentStub, type ImageDescriptionOperation, ImportReleaseAction, InitializedClientConfig, type InitializedStegaConfig, InsertPatch, type InvokeFunctionEvent, type InvokeFunctionOptions, type InvokeFunctionRequest, ListenEvent, ListenEventName, ListenOptions, ListenParams, type LiveClient, LiveEvent, LiveEventGoAway, LiveEventMessage, LiveEventReconnect, LiveEventRestart, LiveEventWelcome, type Logger, MediaLibraryAssetDocument, MediaLibraryAssetInstanceIdentifier, MediaLibraryAssetVersion, MediaLibraryPlaybackInfoOptions, type MediaLibraryVideoClient, MediaLibraryVideoPlaybackTransformations, MessageError, MessageParseError, MultipleActionResult, MultipleMutationResult, Mutation, MutationError, MutationErrorItem, MutationEvent, MutationOperation, MutationSelection, MutationSelectionQueryParams, type ObservableAssetsClient, type ObservableCollaborationCommentsClient, type ObservableDatasetsClient, type ObservableMediaLibraryVideoClient, ObservablePatch, ObservablePatchBuilder, type ObservableProjectsClient, ObservableSanityClient, ObservableTransaction, type ObservableUsersClient, OpenEvent, PartialExcept, Patch, PatchBuilder, type PatchDocument, PatchMutationOperation, type PatchOperation, PatchOperations, PatchSelection, type PatchTarget, type ProjectsClient, type PromptRequest, PublishAction, PublishReleaseAction, PublishVariantAction, QueryOptions, QueryParams, QueryParseError, QueryWithoutParams, RawQueryResponse, RawQuerylessQueryResponse, RawRequestOptions, ReconnectEvent, ReleaseAction, ReleaseCardinality, ReleaseDocument, ReleaseId, ReleaseState, ReleaseType, ReplaceDraftAction, ReplaceVersionAction, RequestHandler, RequestHandlerOptions, RequestObservableOptions, RequestOptions, RequestUrlOptions, Requester, ResetEvent, type ResolveStudioUrl, ResponseQueryOptions, ResumableListenEventNames, ResumableListenOptions, SanityAssetDocument, SanityClient, SanityDocument, SanityDocumentStub, SanityImageAssetDocument, SanityImagePalette, SanityProject, SanityProjectMember, SanityQueries, SanityReference, SanityUser, ScheduleReleaseAction, ServerError, type ServerSentEvent, SingleActionResult, SingleMutationResult, StackablePerspective, type StegaConfig, type StegaConfigRequiredKeys, StillImageFormat, StoryboardTransformOptions, type StudioBaseRoute, type StudioBaseUrl, type StudioUrl, SyncTag, ThumbnailTransformOptions, type TimeoutErrorLike, Transaction, TransactionAllDocumentIdsMutationOptions, TransactionAllDocumentsMutationOptions, TransactionFirstDocumentIdMutationOptions, TransactionFirstDocumentMutationOptions, TransactionMutationOptions, type TransformDocument, type TransformOperation, type TransformTarget, type TransformTargetDocument, type TransformTargetInclude, type TranslateDocument, type TranslateTarget, type TranslateTargetInclude, UnarchiveReleaseAction, UnfilteredResponseQueryOptions, UnfilteredResponseWithoutQuery, UnpublishAction, UnpublishVariantAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantAction, VariantDefinitionAction, VersionAction, VideoPlaybackInfo, VideoPlaybackInfoItem, VideoPlaybackInfoItemPublic, VideoPlaybackInfoItemSigned, VideoPlaybackInfoPublic, VideoPlaybackInfoSigned, VideoPlaybackTokens, VideoRenditionInfo, VideoRenditionInfoPublic, VideoRenditionInfoSigned, VideoSubtitleInfo, VideoSubtitleInfoPublic, VideoSubtitleInfoSigned, WelcomeBackEvent, WelcomeEvent, type _listen, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, isTimeoutError, requester, validateApiPerspective };
185
185
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ import { Observable, catchError, concat, defer, finalize, isObservable, lastValu
7
7
  import { getDraftId, getPublishedId, getVersionFromId, getVersionId, isDraftId, isVersionId } from "@sanity/client/csm";
8
8
  import { filter, finalize as finalize$1, map as map$1, mergeAll } from "rxjs/operators";
9
9
  import { EventSource } from "eventsource";
10
- import { customAlphabet } from "nanoid";
11
10
  /**
12
11
  * A string constant containing the experimental API version warning message.
13
12
  * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
@@ -2142,7 +2141,11 @@ function _modify(client, httpRequest, method, name, options) {
2142
2141
  });
2143
2142
  }
2144
2143
  /** Function resource types in a blueprint are namespaced under this prefix. */
2145
- const scopeHeaders = (config, request) => {
2144
+ const SYNC_INVOCABLE_FUNCTION_TYPES = ["sanity.function.pubsub"], ASYNC_INVOCABLE_FUNCTION_TYPES = [
2145
+ "sanity.function.durable",
2146
+ "sanity.function.pubsub",
2147
+ "sanity.function.queue"
2148
+ ], INVOCABLE_FUNCTION_TYPES = [.../* @__PURE__ */ new Set([...SYNC_INVOCABLE_FUNCTION_TYPES, ...ASYNC_INVOCABLE_FUNCTION_TYPES])], scopeHeaders = (config, request) => {
2146
2149
  let organizationId = request?.organizationId || config.organizationId;
2147
2150
  if (organizationId) return {
2148
2151
  "X-Sanity-Scope-Type": "organization",
@@ -2166,7 +2169,7 @@ const scopeHeaders = (config, request) => {
2166
2169
  *
2167
2170
  * @internal
2168
2171
  */
2169
- function _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request) {
2172
+ function _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request, sync) {
2170
2173
  return _requestObservable(client, httpRequest, {
2171
2174
  method: "GET",
2172
2175
  url: `/blueprints/stacks/${stackId}`,
@@ -2176,17 +2179,19 @@ function _resolveFunctionId(client, httpRequest, functionName, stackId, headers,
2176
2179
  let match = (stack?.resources || []).find((resource) => resource.type?.startsWith("sanity.function.") && resource.name === functionName);
2177
2180
  if (!match) throw Error(`Function "${functionName}" not found in stack "${stackId}"`);
2178
2181
  if (!match.externalId) throw Error(`Function "${functionName}" is declared in stack "${stackId}" but is not deployed`);
2179
- if (match.type !== "sanity.function.pubsub") throw Error(`Function invocation is not supported for ${match.type}`);
2182
+ if (!INVOCABLE_FUNCTION_TYPES.includes(match.type)) throw Error(`Function invocation is not supported for ${match.type}`);
2183
+ if (sync && !SYNC_INVOCABLE_FUNCTION_TYPES.includes(match.type)) throw Error(`Synchronous function invocation is not supported for ${match.type}`);
2184
+ if (!sync && !ASYNC_INVOCABLE_FUNCTION_TYPES.includes(match.type)) throw Error(`Asynchronous function invocation is not supported for ${match.type}`);
2180
2185
  return match.externalId;
2181
2186
  }));
2182
2187
  }
2183
2188
  /** @internal */
2184
- function _invoke(client, httpRequest, functionName, request) {
2189
+ function _invoke(client, httpRequest, functionName, request, options) {
2185
2190
  return defer(() => {
2186
- let config = client.config(), headers = scopeHeaders(config, request);
2187
- return _resolveFunctionId(client, httpRequest, functionName, resolveStackId(config, request), headers, request).pipe(mergeMap((functionId) => _requestObservable(client, httpRequest, {
2191
+ let config = client.config(), headers = scopeHeaders(config, request), stackId = resolveStackId(config, request), sync = options?.sync ?? !1;
2192
+ return _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request, sync).pipe(mergeMap((functionId) => _requestObservable(client, httpRequest, {
2188
2193
  method: "POST",
2189
- url: `/functions/${functionId}/invoke`,
2194
+ url: `/functions/${functionId}/invoke${sync ? "?sync=true" : ""}`,
2190
2195
  headers,
2191
2196
  body: { event: { data: request?.event?.data ?? {} } },
2192
2197
  timeout: request?.timeout,
@@ -2198,42 +2203,15 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
2198
2203
  constructor(client, httpRequest) {
2199
2204
  _classPrivateFieldInitSpec(this, _client$4, void 0), _classPrivateFieldInitSpec(this, _httpRequest$5, void 0), _classPrivateFieldSet2(_client$4, this, client), _classPrivateFieldSet2(_httpRequest$5, this, httpRequest);
2200
2205
  }
2201
- /**
2202
- * Invoke a deployed function by its blueprint name.
2203
- *
2204
- * The name is resolved within the stack given by `stackId` on the request or
2205
- * the client config. Passes the function's return value once it finishes.
2206
- *
2207
- * @param functionName - name of the function, as declared in the blueprint
2208
- * @param request - payload and request options
2209
- */
2210
- invoke(functionName, request) {
2211
- return _invoke(_classPrivateFieldGet2(_client$4, this), _classPrivateFieldGet2(_httpRequest$5, this), functionName, request);
2206
+ invoke(functionName, request, options) {
2207
+ return _invoke(_classPrivateFieldGet2(_client$4, this), _classPrivateFieldGet2(_httpRequest$5, this), functionName, request, options);
2212
2208
  }
2213
2209
  }, _client2$4 = /* @__PURE__ */ new WeakMap(), _httpRequest2$5 = /* @__PURE__ */ new WeakMap(), FunctionsClient = class {
2214
2210
  constructor(client, httpRequest) {
2215
2211
  _classPrivateFieldInitSpec(this, _client2$4, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$5, void 0), _classPrivateFieldSet2(_client2$4, this, client), _classPrivateFieldSet2(_httpRequest2$5, this, httpRequest);
2216
2212
  }
2217
- /**
2218
- * Invoke a deployed function by its blueprint name.
2219
- *
2220
- * The name is resolved within the stack given by `stackId` on the request or
2221
- * the client config, which costs one extra request per call. Rejects if the
2222
- * stack has no function by that name, or if the name resolves to anything
2223
- * other than a `sanity.function.pubsub` function.
2224
- *
2225
- * The lookup is scoped to `projectId`, or to `organizationId` when one is set
2226
- * for a stack deployed at organization scope.
2227
- *
2228
- * The request stays open until the function finishes, and resolves with its
2229
- * return value, or `undefined` if it returns nothing. Long-running functions
2230
- * may need an explicit `timeout`.
2231
- *
2232
- * @param functionName - name of the function, as declared in the blueprint
2233
- * @param request - payload and request options
2234
- */
2235
- invoke(functionName, request) {
2236
- return lastValueFrom(_invoke(_classPrivateFieldGet2(_client2$4, this), _classPrivateFieldGet2(_httpRequest2$5, this), functionName, request));
2213
+ invoke(functionName, request, options) {
2214
+ return lastValueFrom(_invoke(_classPrivateFieldGet2(_client2$4, this), _classPrivateFieldGet2(_httpRequest2$5, this), functionName, request, options));
2237
2215
  }
2238
2216
  }, _client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap(), ObservableMediaLibraryVideoClient = class {
2239
2217
  constructor(client, httpRequest) {
@@ -2372,7 +2350,19 @@ var _client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */
2372
2350
  *
2373
2351
  * ~24 years (or 7.54e+8 seconds) needed, in order to have a 1% probability of at least one collision if 10 ID's are generated every hour.
2374
2352
  */
2375
- const generateReleaseId = customAlphabet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 8), getDocumentVersionId = (publishedId, releaseId) => releaseId ? getVersionId(publishedId, releaseId) : getDraftId(publishedId);
2353
+ function generateReleaseId() {
2354
+ let id = "";
2355
+ for (; id.length < 8;) {
2356
+ let bytes = crypto.getRandomValues(new Uint8Array(8 - id.length));
2357
+ for (let byte of bytes) {
2358
+ let index = byte & 63;
2359
+ index < 62 && (id += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[index]);
2360
+ }
2361
+ }
2362
+ return id;
2363
+ }
2364
+ /** @internal */
2365
+ const getDocumentVersionId = (publishedId, releaseId) => releaseId ? getVersionId(publishedId, releaseId) : getDraftId(publishedId);
2376
2366
  /** @internal */
2377
2367
  function deriveDocumentVersionId(op, { releaseId, publishedId, document }) {
2378
2368
  if (publishedId && document._id) {