@sanity/client 8.7.0 → 8.9.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
@@ -2684,7 +2684,7 @@ const reply = await client.collaboration.comments.create({
2684
2684
  })
2685
2685
  ```
2686
2686
 
2687
- 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:
2687
+ Field comments pass a `path`. Inline comments also pass an `anchor` (`type: 'portable-text'` with block `_key` + character offset). An optional `fieldValue` on the anchor is Portable Text covering that selection (a slice or the full field); when set, the selection is resolved from those blocks instead of from the live document:
2688
2688
 
2689
2689
  ```js
2690
2690
  await client.collaboration.comments.create({
@@ -2693,7 +2693,8 @@ await client.collaboration.comments.create({
2693
2693
  documentId: 'doc-1',
2694
2694
  documentType: 'article',
2695
2695
  path: 'body',
2696
- range: {
2696
+ anchor: {
2697
+ type: 'portable-text',
2697
2698
  start: {_key: 'block-1', offset: 6},
2698
2699
  end: {_key: 'block-1', offset: 11},
2699
2700
  },
@@ -2701,20 +2702,28 @@ await client.collaboration.comments.create({
2701
2702
  })
2702
2703
  ```
2703
2704
 
2704
- When querying, the field is stored as `target.path.field`, so filter with `target.path.field == "body"`, not `target.path == "body"`. The `range` itself is not stored: the API resolves it into a selection (and content snapshot) when the comment is written.
2705
+ Deprecated `range` + top-level `fieldValue` are still accepted and converted to a `portable-text` `anchor` before the request is sent.
2706
+
2707
+ When querying, the field is stored as `target.path.field`, so filter with `target.path.field == "body"`, not `target.path == "body"`. The `anchor` itself is not stored: the API resolves it into a selection (and content snapshot) when the comment is written.
2705
2708
 
2706
2709
  #### Updating and deleting comments
2707
2710
 
2708
- `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`):
2711
+ `update()` can change `message`, `status`, and/or `anchor`. Status changes cascade to replies. An `anchor` 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 sit on a `portable-text` anchor for the same purpose as on create:
2709
2712
 
2710
2713
  ```js
2711
2714
  await client.collaboration.comments.update('comment-1', {status: 'resolved'})
2712
2715
  await client.collaboration.comments.update('comment-1', {
2713
- range: {start: {_key: 'block-1', offset: 0}, end: {_key: 'block-1', offset: 12}},
2716
+ anchor: {
2717
+ type: 'portable-text',
2718
+ start: {_key: 'block-1', offset: 0},
2719
+ end: {_key: 'block-1', offset: 12},
2720
+ },
2714
2721
  })
2715
- await client.collaboration.comments.update('comment-1', {range: null})
2722
+ await client.collaboration.comments.update('comment-1', {anchor: null})
2716
2723
  ```
2717
2724
 
2725
+ Deprecated `range` / `range: null` remain accepted and are converted the same way as on create.
2726
+
2718
2727
  `delete()` also deletes replies. The returned `documentIds` covers the comment and every deleted reply:
2719
2728
 
2720
2729
  ```js
@@ -2766,6 +2775,15 @@ const draftComments = await client.collaboration.comments.fetch(
2766
2775
  )
2767
2776
  ```
2768
2777
 
2778
+ The same ref can be built without a client, from a resource and a document id. Use `getCommentTargetDocumentRef()` where the resource is at hand and no client should be created or looked up, such as in a state selector:
2779
+
2780
+ ```js
2781
+ import {getCommentTargetDocumentRef} from '@sanity/client/collaboration'
2782
+
2783
+ getCommentTargetDocumentRef({type: 'dataset', id: 'your-project-id.production'}, 'drafts.doc-1')
2784
+ // 'dataset:your-project-id.production:doc-1'
2785
+ ```
2786
+
2769
2787
  Pass a type parameter when you know the result shape:
2770
2788
 
2771
2789
  ```ts
@@ -0,0 +1,33 @@
1
+ import { ni as CollaborationCommentDocument, v as ClientConfig } from "./types-KoKIKv8Z.js";
2
+ /**
3
+ * The resource comments are stored against: one of the client's resource configurations.
4
+ *
5
+ * @internal
6
+ */
7
+ type CommentResource = NonNullable<ClientConfig['resource']>;
8
+ /**
9
+ * Build the global document reference a comment stores in `target.document._ref`,
10
+ * without a client.
11
+ *
12
+ * `client.collaboration.comments.getTargetDocumentRef` reads the resource off the
13
+ * client's configuration and calls this. Use this directly when the resource is
14
+ * already at hand and no client should be involved, for example inside a state
15
+ * selector that has to stay free of side effects.
16
+ *
17
+ * The reference always names the published document: a draft or version ID is
18
+ * reduced to its published form first.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * getCommentTargetDocumentRef({type: 'dataset', id: 'abc123.production'}, 'drafts.doc-1')
23
+ * // 'dataset:abc123.production:doc-1'
24
+ * ```
25
+ *
26
+ * @param resource - The resource the comments are stored against, as `ClientConfig['resource']` takes it
27
+ * @param documentId - Document ID, in published, draft or version form
28
+ * @returns Global document reference, of the form `resourceType:resourceId:documentId`
29
+ * @alpha
30
+ */
31
+ declare function getCommentTargetDocumentRef(resource: CommentResource, documentId: string): CollaborationCommentDocument['target']['document']['_ref'];
32
+ export { getCommentTargetDocumentRef };
33
+ //# sourceMappingURL=collaboration.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { t as getCommentTargetDocumentRef } from "./getCommentTargetDocumentRef-B8NuiBjG.js";
2
+ export { getCommentTargetDocumentRef };
@@ -0,0 +1,31 @@
1
+ import { getPublishedId } from "@sanity/client/csm";
2
+ /**
3
+ * Build the global document reference a comment stores in `target.document._ref`,
4
+ * without a client.
5
+ *
6
+ * `client.collaboration.comments.getTargetDocumentRef` reads the resource off the
7
+ * client's configuration and calls this. Use this directly when the resource is
8
+ * already at hand and no client should be involved, for example inside a state
9
+ * selector that has to stay free of side effects.
10
+ *
11
+ * The reference always names the published document: a draft or version ID is
12
+ * reduced to its published form first.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * getCommentTargetDocumentRef({type: 'dataset', id: 'abc123.production'}, 'drafts.doc-1')
17
+ * // 'dataset:abc123.production:doc-1'
18
+ * ```
19
+ *
20
+ * @param resource - The resource the comments are stored against, as `ClientConfig['resource']` takes it
21
+ * @param documentId - Document ID, in published, draft or version form
22
+ * @returns Global document reference, of the form `resourceType:resourceId:documentId`
23
+ * @alpha
24
+ */
25
+ function getCommentTargetDocumentRef(resource, documentId) {
26
+ if (!documentId) throw Error("Document ID must be provided");
27
+ return `${resource.type}:${resource.id}:${getPublishedId(documentId)}`;
28
+ }
29
+ export { getCommentTargetDocumentRef as t };
30
+
31
+ //# sourceMappingURL=getCommentTargetDocumentRef-B8NuiBjG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCommentTargetDocumentRef-B8NuiBjG.js","names":[],"sources":["../src/collaboration/getCommentTargetDocumentRef.ts"],"sourcesContent":["import {getPublishedId} from '@sanity/client/csm'\n\nimport type {ClientConfig} from '../types'\nimport type {CollaborationCommentDocument} from './types'\n\n/**\n * The resource comments are stored against: one of the client's resource configurations.\n *\n * @internal\n */\nexport type CommentResource = NonNullable<ClientConfig['resource']>\n\n/**\n * Build the global document reference a comment stores in `target.document._ref`,\n * without a client.\n *\n * `client.collaboration.comments.getTargetDocumentRef` reads the resource off the\n * client's configuration and calls this. Use this directly when the resource is\n * already at hand and no client should be involved, for example inside a state\n * selector that has to stay free of side effects.\n *\n * The reference always names the published document: a draft or version ID is\n * reduced to its published form first.\n *\n * @example\n * ```ts\n * getCommentTargetDocumentRef({type: 'dataset', id: 'abc123.production'}, 'drafts.doc-1')\n * // 'dataset:abc123.production:doc-1'\n * ```\n *\n * @param resource - The resource the comments are stored against, as `ClientConfig['resource']` takes it\n * @param documentId - Document ID, in published, draft or version form\n * @returns Global document reference, of the form `resourceType:resourceId:documentId`\n * @alpha\n */\nexport function getCommentTargetDocumentRef(\n resource: CommentResource,\n documentId: string,\n): CollaborationCommentDocument['target']['document']['_ref'] {\n if (!documentId) {\n throw new Error('Document ID must be provided')\n }\n\n return `${resource.type}:${resource.id}:${getPublishedId(documentId)}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,4BACd,UACA,YAC4D;CAC5D,IAAI,CAAC,YACH,MAAU,MAAM,8BAA8B;CAGhD,OAAO,GAAG,SAAS,KAAK,GAAG,SAAS,GAAG,GAAG,eAAe,UAAU;AACrE"}
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 UnpublishVersionAction, $r as ObservableCollaborationCommentsClient, $t as QueryWithoutParams, A as ContentSourceMapMappings, Ai as AgentActionParam, An as SanityQueries, Ar as SanityClient, At as MediaLibraryAssetVersion, B as CreateVersionAction, Bn as StoryboardTransformOptions, Br as DatasetsClient, Bt as MutationSelection, C as ContentSourceMap, Ci as TransformTarget, Cn as SanityDocument, Cr as WelcomeEvent, Ct as LiveEventGoAway, D as ContentSourceMapDocuments, Di as PatchDocument, Dn as SanityProject, Dr as GenerateTargetDocument, Dt as LiveEventWelcome, E as ContentSourceMapDocumentValueSource, Ei as PromptRequest, En as SanityImagePalette, Er as GenerateTarget, Et as LiveEventRestart, F as ContentSourceMapValueMapping, Fi as ConstantAgentActionParam, Fn as ScheduleReleaseAction, Fr as MediaLibraryVideoClient, Ft as Mutation, G as DatasetResponse, Gn as TransactionFirstDocumentIdMutationOptions, Gr as PatchBuilder, Gt as PatchOperations, H as DatasetAclMode, Hn as ThumbnailTransformOptions, Hr as BaseTransaction, Ht as OpenEvent, I as CreateAction, Ii as DocumentAgentActionParam, In as SingleActionResult, Ir as ObservableMediaLibraryVideoClient, It as MutationError, J as DeleteReleaseAction, Jn as UnarchiveReleaseAction, Jr as ObservablePatch, Jt as PublishReleaseAction, K as DatasetsResponse, Kn as TransactionFirstDocumentMutationOptions, Kr as Transaction, Kt as PatchSelection, L as CreateReleaseAction, Li as FieldAgentActionParam, Ln as SingleMutationResult, Lr as InvokeFunctionEvent, Lt as MutationErrorItem, M as ContentSourceMapRemoteDocument, Mi as AgentActionPath, Mn as SanityReference, Mr as UsersClient, Mt as MediaLibraryVideoPlaybackTransformations, N as ContentSourceMapSource, Ni as AgentActionPathSegment, Nn as SanitySchemasByResource, Nr as ObservableProjectsClient, Nt as MultipleActionResult, O as ContentSourceMapLiteralSource, Oi as PatchOperation, On as SanityProjectMember, Or as GenerateTargetInclude, Ot as MediaLibraryAssetDocument, P as ContentSourceMapUnknownSource, Pi as AgentActionTarget, Pn as SanityUser, Pr as ProjectsClient, Pt as MultipleMutationResult, Q as DiscardVersionAction, Qn as UnpublishVariantAction, Qr as CollaborationCommentsClient, Qt as QueryParseError, R as CreateVariantAction, Ri as GroqAgentActionParam, Rn as StackablePerspective, Rr as InvokeFunctionOptions, Rt as MutationEvent, S as ClientVariantConditions, Si as TransformOperation, Sn as SanityAssetDocument, Sr as WelcomeBackEvent, St as LiveEvent, T as ContentSourceMapDocumentBase, Ti as TransformTargetInclude, Tn as SanityImageAssetDocument, Tr as GenerateOperation, Tt as LiveEventReconnect, U as DatasetCreateOptions, Un as TransactionAllDocumentIdsMutationOptions, Ur as ObservablePatchBuilder, Ut as PartialExcept, V as CurrentSanityUser, Vn as SyncTag, Vr as ObservableDatasetsClient, Vt as MutationSelectionQueryParams, W as DatasetEditOptions, Wn as TransactionAllDocumentsMutationOptions, Wr as ObservableTransaction, Wt as PatchMutationOperation, X as DeleteVariantDefinitionAction, Xn as UnfilteredResponseWithoutQuery, Xr as LiveClient, Xt as QueryOptions, Y as DeleteVariantAction, Yn as UnfilteredResponseQueryOptions, Yr as Patch, Yt as PublishVariantAction, Z as DiscardAction, Zn as UnpublishAction, Zr as types_d_exports, Zt as QueryParams, _ as ChannelErrorEvent, _i as TranslateDocument, _n as Requester, _r as VideoRenditionInfoPublic, _t as InsertPatch, a as AllDocumentsMutationOptions, ai as CollaborationCommentRange, an as ReleaseCardinality, ar as UploadResponseEvent, at as EditableReleaseDocument, b as ClientReturn, bi as ImageDescriptionOperation, bn as ResumableListenEventNames, br as VideoSubtitleInfoPublic, bt as ListenOptions, c as Any, ci as CollaborationCommentStatus, cn as ReleaseState, cr as VersionAction, ct as ErrorProps, d as AssetMetadataType, di as CollaborationCommentsListenOptions, dn as ReplaceVersionAction, dr as VideoPlaybackInfoItemPublic, dt as FirstDocumentMutationOptions, ei as CollaborationCommentCreate, en as RawQueryResponse, er as UnscheduleReleaseAction, et as EXPERIMENTAL_API_WARNING, f as AttributeSet, fi as CollaborationCommentsRequestOptions, fn as RequestHandler, fr as VideoPlaybackInfoItemSigned, ft as FitMode, g as BaseMutationOptions, gi as ObservableAssetsClient, gn as RequestUrlOptions, gr as VideoRenditionInfo, gt as InitializedClientConfig, h as BaseActionOptions, hi as AssetsClient, hn as RequestOptions, hr as VideoPlaybackTokens, ht as ImportReleaseAction, i as AllDocumentIdsMutationOptions, ii as CollaborationCommentPortableTextBlock, in as ReleaseAction, ir as UploadProgressEvent, it as EditVariantDefinitionAction, j as ContentSourceMapPaths, ji as AgentActionParams, jn as SanityQueriesByResource, jr as ObservableUsersClient, jt as MediaLibraryPlaybackInfoOptions, k as ContentSourceMapMapping, ki as PatchTarget, kn as SanityProjectionsByResource, kr as ObservableSanityClient, kt as MediaLibraryAssetInstanceIdentifier, l as ApiError, li as CollaborationCommentTarget, ln as ReleaseType, lr as VideoPlaybackInfo, lt as FilteredResponseQueryOptions, m as AuthProviderResponse, mi as _listen, mn as RequestObservableOptions, mr as VideoPlaybackInfoSigned, mt as IdentifiedSanityDocumentStub, n as ActionError, ni as CollaborationCommentFieldValue, nn as RawRequestOptions, nr as UploadClientConfig, nt as EditReleaseAction, o as AnimatedImageFormat, oi as CollaborationCommentReactionShortName, on as ReleaseDocument, or as VariantAction, ot as EmbeddingsSettings, p as AuthProvider, pi as CollaborationCommentsWriteOptions, pn as RequestHandlerOptions, pr as VideoPlaybackInfoPublic, pt as HttpRequest, q as DeleteAction, qn as TransactionMutationOptions, qr as BasePatch, qt as PublishAction, r as ActionErrorItem, ri as CollaborationCommentMessage, rn as ReconnectEvent, rr as UploadEvent, rt as EditVariantAction, s as AnimatedTransformOptions, si as CollaborationCommentSelection, sn as ReleaseId, sr as VariantDefinitionAction, st as EmbeddingsSettingsBody, t as Action, ti as CollaborationCommentDocument, tn as RawQuerylessQueryResponse, tr as UploadBody, tt as EditAction, u as ArchiveReleaseAction, ui as CollaborationCommentUpdate, un as ReplaceDraftAction, ur as VideoPlaybackInfoItem, ut as FirstDocumentIdMutationOptions, v as ClientConfig, vi as TranslateTarget, vn as ResetEvent, vr as VideoRenditionInfoSigned, vt as ListenEvent, w as ContentSourceMapDocument, wi as TransformTargetDocument, wn as SanityDocumentStub, wr as GenerateInstruction, wt as LiveEventMessage, x as ClientVariant, xi as TransformDocument, xn as ResumableListenOptions, xr as VideoSubtitleInfoSigned, xt as ListenParams, y as ClientPerspective, yi as TranslateTargetInclude, yn as ResponseQueryOptions, yr as VideoSubtitleInfo, yt as ListenEventName, z as CreateVariantDefinitionAction, zn as StillImageFormat, zr as InvokeFunctionRequest, zt as MutationOperation } from "./types-Do7-A3K9.js";
2
+ import { $ as DisconnectEvent, $n as UnpublishVersionAction, $r as ObservableCollaborationCommentsClient, $t as QueryWithoutParams, A as ContentSourceMapMappings, Ai as PatchTarget, An as SanityQueries, Ar as SanityClient, At as MediaLibraryAssetVersion, B as CreateVersionAction, Bn as StoryboardTransformOptions, Br as DatasetsClient, Bt as MutationSelection, C as ContentSourceMap, Ci as TransformOperation, Cn as SanityDocument, Cr as WelcomeEvent, Ct as LiveEventGoAway, D as ContentSourceMapDocuments, Di as PromptRequest, Dn as SanityProject, Dr as GenerateTargetDocument, Dt as LiveEventWelcome, E as ContentSourceMapDocumentValueSource, Ei as TransformTargetInclude, En as SanityImagePalette, Er as GenerateTarget, Et as LiveEventRestart, F as ContentSourceMapValueMapping, Fi as AgentActionTarget, Fn as ScheduleReleaseAction, Fr as MediaLibraryVideoClient, Ft as Mutation, G as DatasetResponse, Gn as TransactionFirstDocumentIdMutationOptions, Gr as PatchBuilder, Gt as PatchOperations, H as DatasetAclMode, Hn as ThumbnailTransformOptions, Hr as BaseTransaction, Ht as OpenEvent, I as CreateAction, Ii as ConstantAgentActionParam, In as SingleActionResult, Ir as ObservableMediaLibraryVideoClient, It as MutationError, J as DeleteReleaseAction, Jn as UnarchiveReleaseAction, Jr as ObservablePatch, Jt as PublishReleaseAction, K as DatasetsResponse, Kn as TransactionFirstDocumentMutationOptions, Kr as Transaction, Kt as PatchSelection, L as CreateReleaseAction, Li as DocumentAgentActionParam, Ln as SingleMutationResult, Lr as InvokeFunctionEvent, Lt as MutationErrorItem, M as ContentSourceMapRemoteDocument, Mi as AgentActionParams, Mn as SanityReference, Mr as UsersClient, Mt as MediaLibraryVideoPlaybackTransformations, N as ContentSourceMapSource, Ni as AgentActionPath, Nn as SanitySchemasByResource, Nr as ObservableProjectsClient, Nt as MultipleActionResult, O as ContentSourceMapLiteralSource, Oi as PatchDocument, On as SanityProjectMember, Or as GenerateTargetInclude, Ot as MediaLibraryAssetDocument, P as ContentSourceMapUnknownSource, Pi as AgentActionPathSegment, Pn as SanityUser, Pr as ProjectsClient, Pt as MultipleMutationResult, Q as DiscardVersionAction, Qn as UnpublishVariantAction, Qr as CollaborationCommentsClient, Qt as QueryParseError, R as CreateVariantAction, Ri as FieldAgentActionParam, Rn as StackablePerspective, Rr as InvokeFunctionOptions, Rt as MutationEvent, S as ClientVariantConditions, Si as TransformDocument, Sn as SanityAssetDocument, Sr as WelcomeBackEvent, St as LiveEvent, T as ContentSourceMapDocumentBase, Ti as TransformTargetDocument, Tn as SanityImageAssetDocument, Tr as GenerateOperation, Tt as LiveEventReconnect, U as DatasetCreateOptions, Un as TransactionAllDocumentIdsMutationOptions, Ur as ObservablePatchBuilder, Ut as PartialExcept, V as CurrentSanityUser, Vn as SyncTag, Vr as ObservableDatasetsClient, Vt as MutationSelectionQueryParams, W as DatasetEditOptions, Wn as TransactionAllDocumentsMutationOptions, Wr as ObservableTransaction, Wt as PatchMutationOperation, X as DeleteVariantDefinitionAction, Xn as UnfilteredResponseWithoutQuery, Xr as LiveClient, Xt as QueryOptions, Y as DeleteVariantAction, Yn as UnfilteredResponseQueryOptions, Yr as Patch, Yt as PublishVariantAction, Z as DiscardAction, Zn as UnpublishAction, Zr as types_d_exports, Zt as QueryParams, _ as ChannelErrorEvent, _i as ObservableAssetsClient, _n as Requester, _r as VideoRenditionInfoPublic, _t as InsertPatch, a as AllDocumentsMutationOptions, ai as CollaborationCommentPortableTextBlock, an as ReleaseCardinality, ar as UploadResponseEvent, at as EditableReleaseDocument, b as ClientReturn, bi as TranslateTargetInclude, bn as ResumableListenEventNames, br as VideoSubtitleInfoPublic, bt as ListenOptions, c as Any, ci as CollaborationCommentSelection, cn as ReleaseState, cr as VersionAction, ct as ErrorProps, d as AssetMetadataType, di as CollaborationCommentUpdate, dn as ReplaceVersionAction, dr as VideoPlaybackInfoItemPublic, dt as FirstDocumentMutationOptions, ei as CollaborationCommentAnchor, en as RawQueryResponse, er as UnscheduleReleaseAction, et as EXPERIMENTAL_API_WARNING, f as AttributeSet, fi as CollaborationCommentsListenOptions, fn as RequestHandler, fr as VideoPlaybackInfoItemSigned, ft as FitMode, g as BaseMutationOptions, gi as AssetsClient, gn as RequestUrlOptions, gr as VideoRenditionInfo, gt as InitializedClientConfig, h as BaseActionOptions, hi as _listen, hn as RequestOptions, hr as VideoPlaybackTokens, ht as ImportReleaseAction, i as AllDocumentIdsMutationOptions, ii as CollaborationCommentMessage, in as ReleaseAction, ir as UploadProgressEvent, it as EditVariantDefinitionAction, j as ContentSourceMapPaths, ji as AgentActionParam, jn as SanityQueriesByResource, jr as ObservableUsersClient, jt as MediaLibraryPlaybackInfoOptions, k as ContentSourceMapMapping, ki as PatchOperation, kn as SanityProjectionsByResource, kr as ObservableSanityClient, kt as MediaLibraryAssetInstanceIdentifier, l as ApiError, li as CollaborationCommentStatus, ln as ReleaseType, lr as VideoPlaybackInfo, lt as FilteredResponseQueryOptions, m as AuthProviderResponse, mi as CollaborationCommentsWriteOptions, mn as RequestObservableOptions, mr as VideoPlaybackInfoSigned, mt as IdentifiedSanityDocumentStub, n as ActionError, ni as CollaborationCommentDocument, nn as RawRequestOptions, nr as UploadClientConfig, nt as EditReleaseAction, o as AnimatedImageFormat, oi as CollaborationCommentRange, on as ReleaseDocument, or as VariantAction, ot as EmbeddingsSettings, p as AuthProvider, pi as CollaborationCommentsRequestOptions, pn as RequestHandlerOptions, pr as VideoPlaybackInfoPublic, pt as HttpRequest, q as DeleteAction, qn as TransactionMutationOptions, qr as BasePatch, qt as PublishAction, r as ActionErrorItem, ri as CollaborationCommentFieldValue, rn as ReconnectEvent, rr as UploadEvent, rt as EditVariantAction, s as AnimatedTransformOptions, si as CollaborationCommentReactionShortName, sn as ReleaseId, sr as VariantDefinitionAction, st as EmbeddingsSettingsBody, t as Action, ti as CollaborationCommentCreate, tn as RawQuerylessQueryResponse, tr as UploadBody, tt as EditAction, u as ArchiveReleaseAction, ui as CollaborationCommentTarget, un as ReplaceDraftAction, ur as VideoPlaybackInfoItem, ut as FirstDocumentIdMutationOptions, v as ClientConfig, vi as TranslateDocument, vn as ResetEvent, vr as VideoRenditionInfoSigned, vt as ListenEvent, w as ContentSourceMapDocument, wi as TransformTarget, wn as SanityDocumentStub, wr as GenerateInstruction, wt as LiveEventMessage, x as ClientVariant, xi as ImageDescriptionOperation, xn as ResumableListenOptions, xr as VideoSubtitleInfoSigned, xt as ListenParams, y as ClientPerspective, yi as TranslateTarget, yn as ResponseQueryOptions, yr as VideoSubtitleInfo, yt as ListenEventName, z as CreateVariantDefinitionAction, zi as GroqAgentActionParam, zn as StillImageFormat, zr as InvokeFunctionRequest, zt as MutationOperation } from "./types-KoKIKv8Z.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 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, types_d_exports as Context, 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, SanityProjectionsByResource, SanityQueries, SanityQueriesByResource, SanityReference, SanitySchemasByResource, 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 CollaborationCommentAnchor, 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, types_d_exports as Context, 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, SanityProjectionsByResource, SanityQueries, SanityQueriesByResource, SanityReference, SanitySchemasByResource, 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
@@ -3,6 +3,7 @@ import { a as ServerError, c as isHttpError, i as CorsOriginError, l as isQueryP
3
3
  import { t as isRecord } from "./isRecord-Kfmt-nk-.js";
4
4
  import { _ as validateDocumentId, a as printCreateVersionWithBaseIdWarning, b as validateVersionIdMatch, c as printPreviewDraftsDeprecationWarning, d as requestTag, f as requireDocumentId, g as validateAssetType, h as resourceGuard, i as printCdnPreviewDraftsWarning, l as dataset, m as resourceConfig, n as initConfig, o as printDeprecatedUriOptionWarning, p as requireDocumentType, r as validateApiPerspective, s as printNoDefaultExport, t as defaultConfig, u as hasDataset, v as validateInsert, y as validateObject } from "./config-CgJ16jET.js";
5
5
  import { t as stegaClean } from "./stegaClean-YZRATV86.js";
6
+ import { t as getCommentTargetDocumentRef } from "./getCommentTargetDocumentRef-B8NuiBjG.js";
6
7
  import { isTimeoutError } from "get-it";
7
8
  import { anySignal } from "get-it/any-signal";
8
9
  import { Observable, catchError, concat, defer, finalize, isObservable, lastValueFrom, map, merge, mergeMap, of, share, tap, throwError, timer } from "rxjs";
@@ -1408,7 +1409,7 @@ function optionsFromFile(opts, file) {
1408
1409
  contentType: file.type
1409
1410
  }, opts);
1410
1411
  }
1411
- var defaults_default = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = obj[prop] === void 0 ? defaults[prop] : obj[prop], target), {});
1412
+ var version = "8.9.0", defaults_default = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = obj[prop] === void 0 ? defaults[prop] : obj[prop], target), {});
1412
1413
  const pick = (obj, props) => props.reduce((selection, prop) => (obj[prop] === void 0 || (selection[prop] = obj[prop]), selection), {}), RETRYABLE_STATUSES = /* @__PURE__ */ new Set([408, 429]);
1413
1414
  /**
1414
1415
  * Note: connection failure is not the same as network disconnect which may happen more frequent.
@@ -1544,8 +1545,7 @@ function resourceQuery(client) {
1544
1545
  /** @internal */
1545
1546
  function _getTargetDocumentRef(client, documentId) {
1546
1547
  if (!documentId) throw Error("Document ID must be provided");
1547
- let resource = resolveCommentResource(client);
1548
- return `${resource.type}:${resource.id}:${getPublishedId(documentId)}`;
1548
+ return getCommentTargetDocumentRef(resolveCommentResource(client), documentId);
1549
1549
  }
1550
1550
  function write(client, httpRequest, method, url, body, options = {}) {
1551
1551
  return _requestObservable(client, httpRequest, {
@@ -1554,6 +1554,7 @@ function write(client, httpRequest, method, url, body, options = {}) {
1554
1554
  body,
1555
1555
  query: {
1556
1556
  ...resourceQuery(client),
1557
+ clientVersion: version,
1557
1558
  ...options.transactionId ? { transactionId: options.transactionId } : {}
1558
1559
  },
1559
1560
  ...pick(options, possibleRequestOptions)
@@ -1579,13 +1580,35 @@ function writeMutationResult(...args) {
1579
1580
  results
1580
1581
  })));
1581
1582
  }
1583
+ /**
1584
+ * Moves the deprecated `range` + `fieldValue` onto a `portable-text` `anchor`.
1585
+ * Anything else passes through unchanged, and invalid combinations are left
1586
+ * for the API to reject.
1587
+ */
1588
+ function withAnchor(input) {
1589
+ let { range, fieldValue, ...rest } = input;
1590
+ return range === void 0 || input.anchor !== void 0 ? input : range === null ? fieldValue ? input : {
1591
+ ...rest,
1592
+ anchor: null
1593
+ } : {
1594
+ ...rest,
1595
+ anchor: {
1596
+ type: "portable-text",
1597
+ ...range,
1598
+ ...fieldValue && { fieldValue }
1599
+ }
1600
+ };
1601
+ }
1582
1602
  /** @internal */
1583
1603
  function _create(client, httpRequest, body, options) {
1584
- return writeDocument(body._id, client, httpRequest, "POST", "/collaboration/comments", body, options);
1604
+ return writeDocument(body._id, client, httpRequest, "POST", "/collaboration/comments", body.target ? {
1605
+ ...body,
1606
+ target: withAnchor(body.target)
1607
+ } : body, options);
1585
1608
  }
1586
1609
  /** @internal */
1587
1610
  function _update(client, httpRequest, id, body, options) {
1588
- return writeDocument(id, client, httpRequest, "PATCH", commentUrl(id), body, options);
1611
+ return writeDocument(id, client, httpRequest, "PATCH", commentUrl(id), withAnchor(body), options);
1589
1612
  }
1590
1613
  /** @internal */
1591
1614
  function _delete(client, httpRequest, id, options) {