@sanity/client 7.26.1 → 7.27.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.
Files changed (46) hide show
  1. package/README.md +48 -1
  2. package/dist/_chunks-cjs/resolveEditInfo.cjs +4 -4
  3. package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
  4. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +3 -3
  5. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
  6. package/dist/_chunks-es/resolveEditInfo.js +4 -4
  7. package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
  8. package/dist/_chunks-es/stegaEncodeSourceMap.js +3 -3
  9. package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
  10. package/dist/csm.cjs.map +1 -1
  11. package/dist/csm.d.cts +5 -17
  12. package/dist/csm.d.ts +5 -17
  13. package/dist/csm.js.map +1 -1
  14. package/dist/index.browser.cjs +1 -1
  15. package/dist/index.browser.cjs.map +1 -1
  16. package/dist/index.browser.d.cts +70 -65
  17. package/dist/index.browser.d.ts +70 -65
  18. package/dist/index.browser.js +1 -1
  19. package/dist/index.browser.js.map +1 -1
  20. package/dist/index.cjs +3 -4
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +69 -60
  23. package/dist/index.d.ts +69 -60
  24. package/dist/index.js +3 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/media-library.d.cts +24 -0
  27. package/dist/media-library.d.ts +24 -0
  28. package/dist/stega.browser.d.cts +49 -71
  29. package/dist/stega.browser.d.ts +69 -71
  30. package/dist/stega.d.cts +49 -71
  31. package/dist/stega.d.ts +69 -71
  32. package/package.json +36 -33
  33. package/src/agent/actions/commonTypes.ts +1 -2
  34. package/src/agent/actions/generate.ts +3 -6
  35. package/src/agent/actions/patch.ts +3 -6
  36. package/src/agent/actions/prompt.ts +1 -2
  37. package/src/agent/actions/transform.ts +1 -2
  38. package/src/agent/actions/translate.ts +1 -2
  39. package/src/csm/applySourceDocuments.ts +1 -3
  40. package/src/csm/types.ts +1 -3
  41. package/src/data/listen.ts +1 -2
  42. package/src/releases/ReleasesClient.ts +2 -4
  43. package/src/stega/types.ts +1 -2
  44. package/src/types.ts +50 -40
  45. package/umd/sanityClient.js +21 -14
  46. package/umd/sanityClient.min.js +2 -2
package/dist/index.d.cts CHANGED
@@ -424,14 +424,7 @@ export declare interface ArchiveReleaseAction {
424
424
 
425
425
  /** @public */
426
426
  export declare type AssetMetadataType =
427
- | 'location'
428
- | 'exif'
429
- | 'image'
430
- | 'palette'
431
- | 'lqip'
432
- | 'blurhash'
433
- | 'thumbhash'
434
- | 'none'
427
+ 'location' | 'exif' | 'image' | 'palette' | 'lqip' | 'blurhash' | 'thumbhash' | 'none'
435
428
 
436
429
  /** @internal */
437
430
  export declare class AssetsClient {
@@ -873,17 +866,13 @@ export declare class ClientError extends Error {
873
866
 
874
867
  /** @public */
875
868
  export declare type ClientPerspective =
876
- | DeprecatedPreviewDrafts
877
- | 'published'
878
- | 'drafts'
879
- | 'raw'
880
- | StackablePerspective[]
869
+ DeprecatedPreviewDrafts | 'published' | 'drafts' | 'raw' | StackablePerspective[]
881
870
 
882
871
  /** @public */
883
872
  export declare type ClientReturn<
884
873
  GroqString extends string,
885
874
  Fallback = Any,
886
- > = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
875
+ > = GroqString extends keyof SanityQueries_2 ? SanityQueries_2[GroqString] : Fallback
887
876
 
888
877
  /**
889
878
  * @public
@@ -1003,8 +992,7 @@ export declare interface ContentSourceMapDocumentBase {
1003
992
 
1004
993
  /** @public */
1005
994
  export declare type ContentSourceMapDocuments = (
1006
- | ContentSourceMapDocument
1007
- | ContentSourceMapRemoteDocument
995
+ ContentSourceMapDocument | ContentSourceMapRemoteDocument
1008
996
  )[]
1009
997
 
1010
998
  /**
@@ -1600,8 +1588,7 @@ export declare function formatQueryParseError(
1600
1588
 
1601
1589
  /** @beta */
1602
1590
  declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1603
- | GenerateExistingDocumentRequest
1604
- | GenerateTargetDocumentRequest<T>
1591
+ GenerateExistingDocumentRequest | GenerateTargetDocumentRequest<T>
1605
1592
  ) &
1606
1593
  GenerateRequestBase &
1607
1594
  AgentActionAsync
@@ -1620,8 +1607,7 @@ declare interface GenerateExistingDocumentRequest {
1620
1607
 
1621
1608
  /** @beta */
1622
1609
  export declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =
1623
- | GenerateSyncInstruction<T>
1624
- | GenerateAsyncInstruction<T>
1610
+ GenerateSyncInstruction<T> | GenerateAsyncInstruction<T>
1625
1611
 
1626
1612
  /** @beta */
1627
1613
  export declare type GenerateOperation = 'set' | 'append' | 'mixed'
@@ -1752,8 +1738,7 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1752
1738
 
1753
1739
  /** @beta */
1754
1740
  declare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1755
- | GenerateExistingDocumentRequest
1756
- | GenerateTargetDocumentRequest<T>
1741
+ GenerateExistingDocumentRequest | GenerateTargetDocumentRequest<T>
1757
1742
  ) &
1758
1743
  GenerateRequestBase &
1759
1744
  AgentActionSync
@@ -2090,12 +2075,7 @@ export declare function _listen<
2090
2075
 
2091
2076
  /** @public */
2092
2077
  export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
2093
- | MutationEvent<R>
2094
- | ReconnectEvent
2095
- | WelcomeBackEvent
2096
- | ResetEvent
2097
- | WelcomeEvent
2098
- | OpenEvent
2078
+ MutationEvent<R> | ReconnectEvent | WelcomeBackEvent | ResetEvent | WelcomeEvent | OpenEvent
2099
2079
 
2100
2080
  /**
2101
2081
  * Maps a ListenOptions object and returns the Listen events opted for, e.g:
@@ -2235,11 +2215,7 @@ export declare class LiveClient {
2235
2215
 
2236
2216
  /** @public */
2237
2217
  export declare type LiveEvent =
2238
- | LiveEventRestart
2239
- | LiveEventReconnect
2240
- | LiveEventMessage
2241
- | LiveEventWelcome
2242
- | LiveEventGoAway
2218
+ LiveEventRestart | LiveEventReconnect | LiveEventMessage | LiveEventWelcome | LiveEventGoAway
2243
2219
 
2244
2220
  /**
2245
2221
  * The `id` field is the position at which the connection was rejected or closed.
@@ -2294,8 +2270,7 @@ export declare type Logger =
2294
2270
  declare type MapListenEventNamesToListenEvents<
2295
2271
  R extends Record<string, Any> = Record<string, Any>,
2296
2272
  Events extends (ResumableListenEventNames | ListenEventName)[] = (
2297
- | ResumableListenEventNames
2298
- | ListenEventName
2273
+ ResumableListenEventNames | ListenEventName
2299
2274
  )[],
2300
2275
  > = Events extends (infer E)[]
2301
2276
  ? E extends 'welcome'
@@ -4016,21 +3991,18 @@ export declare type PatchBuilder = (patch: Patch) => Patch
4016
3991
 
4017
3992
  /** @beta */
4018
3993
  export declare type PatchDocument<T extends Record<string, Any> = Record<string, Any>> =
4019
- | PatchDocumentSync<T>
4020
- | PatchDocumentAsync<T>
3994
+ PatchDocumentSync<T> | PatchDocumentAsync<T>
4021
3995
 
4022
3996
  /** @beta */
4023
3997
  declare type PatchDocumentAsync<T extends Record<string, Any> = Record<string, Any>> = (
4024
- | PatchExistingDocumentRequest
4025
- | PatchTargetDocumentRequest<T>
3998
+ PatchExistingDocumentRequest | PatchTargetDocumentRequest<T>
4026
3999
  ) &
4027
4000
  PatchRequestBase &
4028
4001
  AgentActionAsync
4029
4002
 
4030
4003
  /** @beta */
4031
4004
  declare type PatchDocumentSync<T extends Record<string, Any> = Record<string, Any>> = (
4032
- | PatchExistingDocumentRequest
4033
- | PatchTargetDocumentRequest<T>
4005
+ PatchExistingDocumentRequest | PatchTargetDocumentRequest<T>
4034
4006
  ) &
4035
4007
  PatchRequestBase &
4036
4008
  AgentActionSync
@@ -4196,8 +4168,7 @@ declare interface PromptJsonResponse<T extends Record<string, Any> = Record<stri
4196
4168
 
4197
4169
  /** @beta */
4198
4170
  export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
4199
- | PromptTextResponse
4200
- | PromptJsonResponse<T>
4171
+ PromptTextResponse | PromptJsonResponse<T>
4201
4172
  ) &
4202
4173
  PromptRequestBase
4203
4174
 
@@ -4342,9 +4313,7 @@ export declare interface PublishReleaseAction {
4342
4313
 
4343
4314
  /** @public */
4344
4315
  export declare type QueryOptions =
4345
- | FilteredResponseQueryOptions
4346
- | UnfilteredResponseQueryOptions
4347
- | UnfilteredResponseWithoutQuery
4316
+ FilteredResponseQueryOptions | UnfilteredResponseQueryOptions | UnfilteredResponseWithoutQuery
4348
4317
 
4349
4318
  /** @public */
4350
4319
  export declare interface QueryParams {
@@ -4981,8 +4950,10 @@ export declare type ResumableListenEventNames =
4981
4950
  | 'reset'
4982
4951
 
4983
4952
  /** @public */
4984
- export declare interface ResumableListenOptions
4985
- extends Omit<ListenOptions, 'events' | 'enableResume'> {
4953
+ export declare interface ResumableListenOptions extends Omit<
4954
+ ListenOptions,
4955
+ 'events' | 'enableResume'
4956
+ > {
4986
4957
  /**
4987
4958
  * If this is enabled, the client will normally resume events upon reconnect
4988
4959
  * Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
@@ -5908,8 +5879,28 @@ export declare interface SanityProjectMember {
5908
5879
  isCurrentUser: boolean
5909
5880
  }
5910
5881
 
5911
- /** @public */
5912
- export declare interface SanityQueries {}
5882
+ /**
5883
+ * The query registry as seen from `@sanity/client`. Inherits every query registered on the global
5884
+ * `SanityQueries` interface, and still accepts the older module augmentation form:
5885
+ * ```ts
5886
+ * declare module '@sanity/client' {
5887
+ * interface SanityQueries {
5888
+ * '*[_type == "post"]': PostsQueryResult
5889
+ * }
5890
+ * }
5891
+ * ```
5892
+ * `@sanity/client` releases that predate the global registry only read this interface, so a
5893
+ * generated file that registers queries globally can bridge them with an augmentation that adds
5894
+ * the global as a base type. It is harmless on releases that already inherit it:
5895
+ * ```ts
5896
+ * declare module '@sanity/client' {
5897
+ * interface SanityQueries extends globalThis.SanityQueries {}
5898
+ * }
5899
+ * ```
5900
+ * @public
5901
+ */
5902
+ declare interface SanityQueries_2 extends globalThis.SanityQueries {}
5903
+ export {SanityQueries_2 as SanityQueries}
5913
5904
 
5914
5905
  /** @internal */
5915
5906
  export declare interface SanityReference {
@@ -6151,8 +6142,7 @@ export declare type TransactionMutationOptions =
6151
6142
 
6152
6143
  /** @beta */
6153
6144
  export declare type TransformDocument<T extends Record<string, Any> = Record<string, Any>> =
6154
- | TransformDocumentSync<T>
6155
- | TransformDocumentAsync
6145
+ TransformDocumentSync<T> | TransformDocumentAsync
6156
6146
 
6157
6147
  /** @beta */
6158
6148
  declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
@@ -6416,8 +6406,7 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
6416
6406
 
6417
6407
  /** @beta */
6418
6408
  export declare type TranslateDocument<T extends Record<string, Any> = Record<string, Any>> =
6419
- | TranslateDocumentSync<T>
6420
- | TranslateDocumentAsync
6409
+ TranslateDocumentSync<T> | TranslateDocumentAsync
6421
6410
 
6422
6411
  /** @beta */
6423
6412
  declare type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync
@@ -6694,10 +6683,7 @@ export declare function validateApiPerspective(
6694
6683
 
6695
6684
  /** @public */
6696
6685
  export declare type VersionAction =
6697
- | CreateVersionAction
6698
- | DiscardVersionAction
6699
- | ReplaceVersionAction
6700
- | UnpublishVersionAction
6686
+ CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction
6701
6687
 
6702
6688
  /** @public */
6703
6689
  export declare interface VideoPlaybackInfo<
@@ -6722,8 +6708,7 @@ export declare interface VideoPlaybackInfo<
6722
6708
 
6723
6709
  /** @public */
6724
6710
  export declare type VideoPlaybackInfoItem =
6725
- | VideoPlaybackInfoItemPublic
6726
- | VideoPlaybackInfoItemSigned
6711
+ VideoPlaybackInfoItemPublic | VideoPlaybackInfoItemSigned
6727
6712
 
6728
6713
  /** @public */
6729
6714
  export declare interface VideoPlaybackInfoItemPublic {
@@ -6828,3 +6813,27 @@ export declare type WelcomeEvent = {
6828
6813
  }
6829
6814
 
6830
6815
  export {}
6816
+
6817
+ declare global {
6818
+ interface File {}
6819
+ }
6820
+
6821
+ declare global {
6822
+ /**
6823
+ * Query result types, keyed by GROQ query string. Empty by default, `sanity typegen` registers
6824
+ * the queries it finds:
6825
+ * ```ts
6826
+ * declare global {
6827
+ * interface SanityQueries {
6828
+ * '*[_type == "post"]': PostsQueryResult
6829
+ * }
6830
+ * }
6831
+ * ```
6832
+ * `client.fetch(query)` and `ClientReturn<typeof query>` then resolve to the registered type.
6833
+ *
6834
+ * The registry is a global rather than a module augmentation of `@sanity/client` so that it
6835
+ * does not depend on module resolution: it resolves the same whether `@sanity/client` is a
6836
+ * direct dependency, how many copies of it are installed, and from every subpath export.
6837
+ */
6838
+ interface SanityQueries {}
6839
+ }
package/dist/index.d.ts CHANGED
@@ -424,14 +424,7 @@ export declare interface ArchiveReleaseAction {
424
424
 
425
425
  /** @public */
426
426
  export declare type AssetMetadataType =
427
- | 'location'
428
- | 'exif'
429
- | 'image'
430
- | 'palette'
431
- | 'lqip'
432
- | 'blurhash'
433
- | 'thumbhash'
434
- | 'none'
427
+ 'location' | 'exif' | 'image' | 'palette' | 'lqip' | 'blurhash' | 'thumbhash' | 'none'
435
428
 
436
429
  /** @internal */
437
430
  export declare class AssetsClient {
@@ -873,17 +866,13 @@ export declare class ClientError extends Error {
873
866
 
874
867
  /** @public */
875
868
  export declare type ClientPerspective =
876
- | DeprecatedPreviewDrafts
877
- | 'published'
878
- | 'drafts'
879
- | 'raw'
880
- | StackablePerspective[]
869
+ DeprecatedPreviewDrafts | 'published' | 'drafts' | 'raw' | StackablePerspective[]
881
870
 
882
871
  /** @public */
883
872
  export declare type ClientReturn<
884
873
  GroqString extends string,
885
874
  Fallback = Any,
886
- > = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
875
+ > = GroqString extends keyof SanityQueries_2 ? SanityQueries_2[GroqString] : Fallback
887
876
 
888
877
  /**
889
878
  * @public
@@ -1003,8 +992,7 @@ export declare interface ContentSourceMapDocumentBase {
1003
992
 
1004
993
  /** @public */
1005
994
  export declare type ContentSourceMapDocuments = (
1006
- | ContentSourceMapDocument
1007
- | ContentSourceMapRemoteDocument
995
+ ContentSourceMapDocument | ContentSourceMapRemoteDocument
1008
996
  )[]
1009
997
 
1010
998
  /**
@@ -1600,8 +1588,7 @@ export declare function formatQueryParseError(
1600
1588
 
1601
1589
  /** @beta */
1602
1590
  declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1603
- | GenerateExistingDocumentRequest
1604
- | GenerateTargetDocumentRequest<T>
1591
+ GenerateExistingDocumentRequest | GenerateTargetDocumentRequest<T>
1605
1592
  ) &
1606
1593
  GenerateRequestBase &
1607
1594
  AgentActionAsync
@@ -1620,8 +1607,7 @@ declare interface GenerateExistingDocumentRequest {
1620
1607
 
1621
1608
  /** @beta */
1622
1609
  export declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =
1623
- | GenerateSyncInstruction<T>
1624
- | GenerateAsyncInstruction<T>
1610
+ GenerateSyncInstruction<T> | GenerateAsyncInstruction<T>
1625
1611
 
1626
1612
  /** @beta */
1627
1613
  export declare type GenerateOperation = 'set' | 'append' | 'mixed'
@@ -1752,8 +1738,7 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1752
1738
 
1753
1739
  /** @beta */
1754
1740
  declare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1755
- | GenerateExistingDocumentRequest
1756
- | GenerateTargetDocumentRequest<T>
1741
+ GenerateExistingDocumentRequest | GenerateTargetDocumentRequest<T>
1757
1742
  ) &
1758
1743
  GenerateRequestBase &
1759
1744
  AgentActionSync
@@ -2090,12 +2075,7 @@ export declare function _listen<
2090
2075
 
2091
2076
  /** @public */
2092
2077
  export declare type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
2093
- | MutationEvent<R>
2094
- | ReconnectEvent
2095
- | WelcomeBackEvent
2096
- | ResetEvent
2097
- | WelcomeEvent
2098
- | OpenEvent
2078
+ MutationEvent<R> | ReconnectEvent | WelcomeBackEvent | ResetEvent | WelcomeEvent | OpenEvent
2099
2079
 
2100
2080
  /**
2101
2081
  * Maps a ListenOptions object and returns the Listen events opted for, e.g:
@@ -2235,11 +2215,7 @@ export declare class LiveClient {
2235
2215
 
2236
2216
  /** @public */
2237
2217
  export declare type LiveEvent =
2238
- | LiveEventRestart
2239
- | LiveEventReconnect
2240
- | LiveEventMessage
2241
- | LiveEventWelcome
2242
- | LiveEventGoAway
2218
+ LiveEventRestart | LiveEventReconnect | LiveEventMessage | LiveEventWelcome | LiveEventGoAway
2243
2219
 
2244
2220
  /**
2245
2221
  * The `id` field is the position at which the connection was rejected or closed.
@@ -2294,8 +2270,7 @@ export declare type Logger =
2294
2270
  declare type MapListenEventNamesToListenEvents<
2295
2271
  R extends Record<string, Any> = Record<string, Any>,
2296
2272
  Events extends (ResumableListenEventNames | ListenEventName)[] = (
2297
- | ResumableListenEventNames
2298
- | ListenEventName
2273
+ ResumableListenEventNames | ListenEventName
2299
2274
  )[],
2300
2275
  > = Events extends (infer E)[]
2301
2276
  ? E extends 'welcome'
@@ -4016,21 +3991,18 @@ export declare type PatchBuilder = (patch: Patch) => Patch
4016
3991
 
4017
3992
  /** @beta */
4018
3993
  export declare type PatchDocument<T extends Record<string, Any> = Record<string, Any>> =
4019
- | PatchDocumentSync<T>
4020
- | PatchDocumentAsync<T>
3994
+ PatchDocumentSync<T> | PatchDocumentAsync<T>
4021
3995
 
4022
3996
  /** @beta */
4023
3997
  declare type PatchDocumentAsync<T extends Record<string, Any> = Record<string, Any>> = (
4024
- | PatchExistingDocumentRequest
4025
- | PatchTargetDocumentRequest<T>
3998
+ PatchExistingDocumentRequest | PatchTargetDocumentRequest<T>
4026
3999
  ) &
4027
4000
  PatchRequestBase &
4028
4001
  AgentActionAsync
4029
4002
 
4030
4003
  /** @beta */
4031
4004
  declare type PatchDocumentSync<T extends Record<string, Any> = Record<string, Any>> = (
4032
- | PatchExistingDocumentRequest
4033
- | PatchTargetDocumentRequest<T>
4005
+ PatchExistingDocumentRequest | PatchTargetDocumentRequest<T>
4034
4006
  ) &
4035
4007
  PatchRequestBase &
4036
4008
  AgentActionSync
@@ -4196,8 +4168,7 @@ declare interface PromptJsonResponse<T extends Record<string, Any> = Record<stri
4196
4168
 
4197
4169
  /** @beta */
4198
4170
  export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
4199
- | PromptTextResponse
4200
- | PromptJsonResponse<T>
4171
+ PromptTextResponse | PromptJsonResponse<T>
4201
4172
  ) &
4202
4173
  PromptRequestBase
4203
4174
 
@@ -4342,9 +4313,7 @@ export declare interface PublishReleaseAction {
4342
4313
 
4343
4314
  /** @public */
4344
4315
  export declare type QueryOptions =
4345
- | FilteredResponseQueryOptions
4346
- | UnfilteredResponseQueryOptions
4347
- | UnfilteredResponseWithoutQuery
4316
+ FilteredResponseQueryOptions | UnfilteredResponseQueryOptions | UnfilteredResponseWithoutQuery
4348
4317
 
4349
4318
  /** @public */
4350
4319
  export declare interface QueryParams {
@@ -4981,8 +4950,10 @@ export declare type ResumableListenEventNames =
4981
4950
  | 'reset'
4982
4951
 
4983
4952
  /** @public */
4984
- export declare interface ResumableListenOptions
4985
- extends Omit<ListenOptions, 'events' | 'enableResume'> {
4953
+ export declare interface ResumableListenOptions extends Omit<
4954
+ ListenOptions,
4955
+ 'events' | 'enableResume'
4956
+ > {
4986
4957
  /**
4987
4958
  * If this is enabled, the client will normally resume events upon reconnect
4988
4959
  * Note that you should also subscribe to `reset`-events and handle the case where the backend is unable to resume
@@ -5908,8 +5879,28 @@ export declare interface SanityProjectMember {
5908
5879
  isCurrentUser: boolean
5909
5880
  }
5910
5881
 
5911
- /** @public */
5912
- export declare interface SanityQueries {}
5882
+ /**
5883
+ * The query registry as seen from `@sanity/client`. Inherits every query registered on the global
5884
+ * `SanityQueries` interface, and still accepts the older module augmentation form:
5885
+ * ```ts
5886
+ * declare module '@sanity/client' {
5887
+ * interface SanityQueries {
5888
+ * '*[_type == "post"]': PostsQueryResult
5889
+ * }
5890
+ * }
5891
+ * ```
5892
+ * `@sanity/client` releases that predate the global registry only read this interface, so a
5893
+ * generated file that registers queries globally can bridge them with an augmentation that adds
5894
+ * the global as a base type. It is harmless on releases that already inherit it:
5895
+ * ```ts
5896
+ * declare module '@sanity/client' {
5897
+ * interface SanityQueries extends globalThis.SanityQueries {}
5898
+ * }
5899
+ * ```
5900
+ * @public
5901
+ */
5902
+ declare interface SanityQueries_2 extends globalThis.SanityQueries {}
5903
+ export {SanityQueries_2 as SanityQueries}
5913
5904
 
5914
5905
  /** @internal */
5915
5906
  export declare interface SanityReference {
@@ -6151,8 +6142,7 @@ export declare type TransactionMutationOptions =
6151
6142
 
6152
6143
  /** @beta */
6153
6144
  export declare type TransformDocument<T extends Record<string, Any> = Record<string, Any>> =
6154
- | TransformDocumentSync<T>
6155
- | TransformDocumentAsync
6145
+ TransformDocumentSync<T> | TransformDocumentAsync
6156
6146
 
6157
6147
  /** @beta */
6158
6148
  declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
@@ -6416,8 +6406,7 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
6416
6406
 
6417
6407
  /** @beta */
6418
6408
  export declare type TranslateDocument<T extends Record<string, Any> = Record<string, Any>> =
6419
- | TranslateDocumentSync<T>
6420
- | TranslateDocumentAsync
6409
+ TranslateDocumentSync<T> | TranslateDocumentAsync
6421
6410
 
6422
6411
  /** @beta */
6423
6412
  declare type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync
@@ -6694,10 +6683,7 @@ export declare function validateApiPerspective(
6694
6683
 
6695
6684
  /** @public */
6696
6685
  export declare type VersionAction =
6697
- | CreateVersionAction
6698
- | DiscardVersionAction
6699
- | ReplaceVersionAction
6700
- | UnpublishVersionAction
6686
+ CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction
6701
6687
 
6702
6688
  /** @public */
6703
6689
  export declare interface VideoPlaybackInfo<
@@ -6722,8 +6708,7 @@ export declare interface VideoPlaybackInfo<
6722
6708
 
6723
6709
  /** @public */
6724
6710
  export declare type VideoPlaybackInfoItem =
6725
- | VideoPlaybackInfoItemPublic
6726
- | VideoPlaybackInfoItemSigned
6711
+ VideoPlaybackInfoItemPublic | VideoPlaybackInfoItemSigned
6727
6712
 
6728
6713
  /** @public */
6729
6714
  export declare interface VideoPlaybackInfoItemPublic {
@@ -6828,3 +6813,27 @@ export declare type WelcomeEvent = {
6828
6813
  }
6829
6814
 
6830
6815
  export {}
6816
+
6817
+ declare global {
6818
+ interface File {}
6819
+ }
6820
+
6821
+ declare global {
6822
+ /**
6823
+ * Query result types, keyed by GROQ query string. Empty by default, `sanity typegen` registers
6824
+ * the queries it finds:
6825
+ * ```ts
6826
+ * declare global {
6827
+ * interface SanityQueries {
6828
+ * '*[_type == "post"]': PostsQueryResult
6829
+ * }
6830
+ * }
6831
+ * ```
6832
+ * `client.fetch(query)` and `ClientReturn<typeof query>` then resolve to the registered type.
6833
+ *
6834
+ * The registry is a global rather than a module augmentation of `@sanity/client` so that it
6835
+ * does not depend on module resolution: it resolves the same whether `@sanity/client` is a
6836
+ * direct dependency, how many copies of it are installed, and from every subpath export.
6837
+ */
6838
+ interface SanityQueries {}
6839
+ }
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { combineLatestWith, map, filter, concatMap, reduce, finalize as finalize
8
8
  import { getVersionFromId, isDraftId, getVersionId, getDraftId, isVersionId, getPublishedId } from "@sanity/client/csm";
9
9
  import { customAlphabet } from "nanoid";
10
10
  import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requireDocumentType, printCreateVersionWithBaseIdWarning, resourceConfig, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, resourceGuard, dataset, validateVersionIdMatch, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
11
- const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
11
+ const EXPERIMENTAL_API_WARNING = "This is an experimental API version", NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
12
12
  function codeFrame(query, location2, message) {
13
13
  const lines = query.split(NEWLINE), loc = {
14
14
  start: columnToLine(location2.start, lines),
@@ -220,7 +220,6 @@ function shouldRetry(err, attempt, options) {
220
220
  const isSafe = options.method === "GET" || options.method === "HEAD", isQuery2 = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
221
221
  return (isSafe || isQuery2) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
222
222
  }
223
- const EXPERIMENTAL_API_WARNING = "This is an experimental API version";
224
223
  class ConnectionFailedError extends Error {
225
224
  name = "ConnectionFailedError";
226
225
  /**
@@ -688,7 +687,7 @@ function requestOptions(config, overrides = {}) {
688
687
  const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
689
688
  return Object.assign({}, overrides, {
690
689
  headers: Object.assign({}, headers2, overrides.headers || {}),
691
- timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
690
+ timeout: typeof timeout > "u" ? 300 * 1e3 : timeout,
692
691
  proxy: overrides.proxy || config.proxy,
693
692
  json: !0,
694
693
  withCredentials,
@@ -2866,7 +2865,7 @@ function defineDeprecatedCreateClient(createClient2) {
2866
2865
  return printNoDefaultExport(), createClient2(config);
2867
2866
  };
2868
2867
  }
2869
- var name = "@sanity/client", version = "7.26.1";
2868
+ var name = "@sanity/client", version = "7.27.0";
2870
2869
  const middleware = [
2871
2870
  debug({ verbose: !0, namespace: "sanity:client" }),
2872
2871
  headers({ "User-Agent": `${name} ${version}` }),