@sanity/client 5.4.1 → 5.4.2-dev.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/dist/index.d.ts CHANGED
@@ -297,6 +297,7 @@ export declare interface ClientConfig {
297
297
  * @deprecated Don't use
298
298
  */
299
299
  requester?: Requester
300
+ resultSourceMap?: boolean
300
301
  }
301
302
 
302
303
  /** @public */
@@ -308,6 +309,13 @@ export declare class ClientError extends Error {
308
309
  constructor(res: Any)
309
310
  }
310
311
 
312
+ /** @internal */
313
+ export declare type ContentSourceMapping = {
314
+ mappings: Record<string, Mapping>
315
+ documents: Array<SanityDocument>
316
+ paths: Array<string>
317
+ }
318
+
311
319
  /** @public */
312
320
  export declare const createClient: (config: ClientConfig) => SanityClient
313
321
 
@@ -390,6 +398,16 @@ export declare type DisconnectEvent = {
390
398
  reason: string
391
399
  }
392
400
 
401
+ /**
402
+ * DocumentValueSource is a path to a value within a document
403
+ * @internal
404
+ */
405
+ export declare type DocumentValueSource = {
406
+ type: 'documentValue'
407
+ document: number
408
+ path: number
409
+ }
410
+
393
411
  /** @public */
394
412
  export declare interface ErrorProps {
395
413
  message: string
@@ -519,6 +537,17 @@ export declare interface ListenOptions {
519
537
  tag?: string
520
538
  }
521
539
 
540
+ /**
541
+ * When a value is not from a source, its a literal
542
+ * @internal
543
+ */
544
+ export declare type LiteralSource = {
545
+ type: 'literal'
546
+ }
547
+
548
+ /** @internal */
549
+ export declare type Mapping = ValueMapping
550
+
522
551
  /** @internal */
523
552
  export declare interface MultipleMutationResult {
524
553
  transactionId: string
@@ -1408,6 +1437,7 @@ export declare interface RawQueryResponse<R> {
1408
1437
  q: string
1409
1438
  ms: number
1410
1439
  result: R
1440
+ resultSourceMap: ContentSourceMapping
1411
1441
  }
1412
1442
 
1413
1443
  /** @internal */
@@ -2079,6 +2109,9 @@ export declare interface SingleMutationResult {
2079
2109
  }[]
2080
2110
  }
2081
2111
 
2112
+ /** @internal */
2113
+ export declare type Source = DocumentValueSource | LiteralSource | UnknownSource
2114
+
2082
2115
  /** @public */
2083
2116
  export declare class Transaction extends BaseTransaction {
2084
2117
  #private
@@ -2174,6 +2207,14 @@ export declare type UnfilteredResponseQueryOptions = RequestOptions & {
2174
2207
  filterResponse: false
2175
2208
  }
2176
2209
 
2210
+ /**
2211
+ * When a field source is unknown
2212
+ * @internal
2213
+ */
2214
+ export declare type UnknownSource = {
2215
+ type: 'unknown'
2216
+ }
2217
+
2177
2218
  export {unstable__adapter}
2178
2219
 
2179
2220
  export {unstable__environment}
@@ -2254,6 +2295,16 @@ export declare class UsersClient {
2254
2295
  getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
2255
2296
  }
2256
2297
 
2298
+ /**
2299
+ * ValueMapping is a mapping when for value that is from a single source value
2300
+ * It may refer to a field within a document or a literal value
2301
+ * @internal
2302
+ */
2303
+ export declare type ValueMapping = {
2304
+ type: 'value'
2305
+ source: Source
2306
+ }
2307
+
2257
2308
  /** @public */
2258
2309
  export declare type WelcomeEvent = {
2259
2310
  type: 'welcome'
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export { adapter as unstable__adapter, environment as unstable__environment } fr
4
4
  import { Observable, lastValueFrom } from 'rxjs';
5
5
  import { map, filter } from 'rxjs/operators';
6
6
  var name = "@sanity/client";
7
- var version = "5.4.1";
7
+ var version = "5.4.2-dev.0";
8
8
  const middleware = [debug({
9
9
  verbose: true,
10
10
  namespace: "sanity:client"
@@ -813,6 +813,12 @@ function _requestObservable(client, httpRequest, options) {
813
813
  ...options.query
814
814
  };
815
815
  }
816
+ if (config.resultSourceMap) {
817
+ options.query = {
818
+ resultSourceMap: true,
819
+ ...options.query
820
+ };
821
+ }
816
822
  const reqOptions = requestOptions(config, Object.assign({}, options, {
817
823
  url: _getUrl(client, uri, useCdn)
818
824
  }));