@sanity/client 6.11.3 → 6.11.4-canary.1
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 +4 -4
- package/dist/_chunks/{browserMiddleware-1MULg59S.cjs → browserMiddleware-EnEpy_gt.cjs} +247 -299
- package/dist/_chunks/browserMiddleware-EnEpy_gt.cjs.map +1 -0
- package/dist/_chunks/{browserMiddleware-heyg-fDk.js → browserMiddleware-nSeu_Rmf.js} +246 -299
- package/dist/_chunks/browserMiddleware-nSeu_Rmf.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-CHxg1-zH.cjs → nodeMiddleware-_hIIS1d7.cjs} +248 -300
- package/dist/_chunks/nodeMiddleware-_hIIS1d7.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-u_fUUnxa.js → nodeMiddleware-hZIb_1T_.js} +247 -300
- package/dist/_chunks/nodeMiddleware-hZIb_1T_.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-4w5UCEGT.cjs +479 -0
- package/dist/_chunks/stegaEncodeSourceMap-4w5UCEGT.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-SOgem38i.js +475 -0
- package/dist/_chunks/stegaEncodeSourceMap-SOgem38i.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-Tuf6zjiN.cjs +230 -0
- package/dist/_chunks/stegaEncodeSourceMap-Tuf6zjiN.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-zvyGxB_C.js +226 -0
- package/dist/_chunks/stegaEncodeSourceMap-zvyGxB_C.js.map +1 -0
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +319 -49
- package/dist/index.js +2 -2
- package/dist/stega.browser.cjs +12 -695
- package/dist/stega.browser.cjs.map +1 -1
- package/dist/stega.browser.js +7 -690
- package/dist/stega.browser.js.map +1 -1
- package/dist/stega.cjs +12 -446
- package/dist/stega.cjs.js +3 -3
- package/dist/stega.cjs.map +1 -1
- package/dist/stega.d.ts +1418 -1422
- package/dist/stega.js +7 -441
- package/dist/stega.js.map +1 -1
- package/package.json +11 -9
- package/src/SanityClient.ts +152 -75
- package/src/assets/AssetsClient.ts +19 -10
- package/src/config.ts +34 -12
- package/src/data/dataMethods.ts +40 -14
- package/src/data/patch.ts +12 -10
- package/src/data/transaction.ts +13 -12
- package/src/datasets/DatasetsClient.ts +36 -16
- package/src/projects/ProjectsClient.ts +21 -12
- package/src/stega/index.browser.ts +3 -7
- package/src/stega/index.ts +3 -7
- package/src/stega/shared.ts +7 -5
- package/src/stega/types.ts +11 -18
- package/src/types.ts +107 -5
- package/src/users/UsersClient.ts +20 -13
- package/umd/sanityClient.js +3148 -2235
- package/umd/sanityClient.min.js +4 -3
- package/dist/_chunks/browserMiddleware-1MULg59S.cjs.map +0 -1
- package/dist/_chunks/browserMiddleware-heyg-fDk.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-CHxg1-zH.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-u_fUUnxa.js.map +0 -1
- package/src/stega/SanityStegaClient.ts +0 -298
- package/src/stega/config.ts +0 -76
package/src/types.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type {Requester} from 'get-it'
|
|
4
4
|
|
|
5
|
+
import type {InitializedStegaConfig, StegaConfig} from './stega/types'
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
7
9
|
* @internal
|
|
@@ -89,6 +91,10 @@ export interface ClientConfig {
|
|
|
89
91
|
*@deprecated set `cache` and `next` options on `client.fetch` instead
|
|
90
92
|
*/
|
|
91
93
|
fetch?: RequestFetchOptions | boolean
|
|
94
|
+
/**
|
|
95
|
+
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
96
|
+
*/
|
|
97
|
+
stega?: StegaConfig | boolean
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
/** @public */
|
|
@@ -111,6 +117,10 @@ export interface InitializedClientConfig extends ClientConfig {
|
|
|
111
117
|
* @deprecated Internal, don't use
|
|
112
118
|
*/
|
|
113
119
|
cdnUrl: string
|
|
120
|
+
/**
|
|
121
|
+
* The fully initialized stega config, can be used to check if stega is enabled
|
|
122
|
+
*/
|
|
123
|
+
stega: InitializedStegaConfig
|
|
114
124
|
}
|
|
115
125
|
|
|
116
126
|
/** @public */
|
|
@@ -425,6 +435,79 @@ export interface PatchOperations {
|
|
|
425
435
|
|
|
426
436
|
/** @public */
|
|
427
437
|
export type QueryParams = {[key: string]: Any}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Verify this type has all the same keys as QueryOptions before exporting
|
|
441
|
+
* @internal
|
|
442
|
+
*/
|
|
443
|
+
export type _QueryParamsLikelyByMistake = {
|
|
444
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
445
|
+
body?: Any
|
|
446
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
447
|
+
cache?: Any
|
|
448
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
449
|
+
filterResponse?: Any
|
|
450
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
451
|
+
headers?: Any
|
|
452
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
453
|
+
method?: Any
|
|
454
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
455
|
+
next?: Any
|
|
456
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
457
|
+
perspective?: Any
|
|
458
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
459
|
+
query?: Any
|
|
460
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
461
|
+
resultSourceMap?: Any
|
|
462
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
463
|
+
signal?: Any
|
|
464
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
465
|
+
stega?: Any
|
|
466
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
467
|
+
tag?: Any
|
|
468
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
469
|
+
timeout?: Any
|
|
470
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
471
|
+
token?: Any
|
|
472
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
473
|
+
useCdn?: Any
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* It's easy to accidentally set query options such as `filterResponse`, `cache` and `next` as the second parameter in `client.fetch`,
|
|
478
|
+
* as that is a wide type used to set GROQ query paramaters and it accepts anything that can serialize to JSON.
|
|
479
|
+
* This type is used to prevent that, and will cause a type error if you try to pass a query option as the second parameter.
|
|
480
|
+
* If this type is `never`, it means `_QueryParamsLikelyByMistake` is missing keys from `QueryOptions`.
|
|
481
|
+
* @internal
|
|
482
|
+
*/
|
|
483
|
+
export type QueryParamsLikelyByMistake =
|
|
484
|
+
Required<_QueryParamsLikelyByMistake> extends Record<keyof QueryOptions, Any>
|
|
485
|
+
? _QueryParamsLikelyByMistake
|
|
486
|
+
: never
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* It's easy to accidentally set query options such as `filterResponse`, `cache` and `next` as the second parameter in `client.fetch`,
|
|
490
|
+
* as that is a wide type used to set GROQ query paramaters and it accepts anything that can serialize to JSON.
|
|
491
|
+
* This type is used to prevent that, and will cause a type error if you try to pass a query option as the second parameter.
|
|
492
|
+
* @internal
|
|
493
|
+
*/
|
|
494
|
+
export type QueryParamsWithoutQueryOptions = {
|
|
495
|
+
[K in keyof _QueryParamsLikelyByMistake]: never
|
|
496
|
+
} & QueryParams
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Transform a QueryParams generic type to a valid parameter type for `client.fetch
|
|
500
|
+
* @public
|
|
501
|
+
*/
|
|
502
|
+
export type QueryParamsParameter<QueryParamsParameterType> =
|
|
503
|
+
QueryParamsParameterType extends QueryParams
|
|
504
|
+
? QueryParamsParameterType
|
|
505
|
+
: QueryParamsParameterType extends Record<string, never>
|
|
506
|
+
? Record<string, never>
|
|
507
|
+
: QueryParamsParameterType extends undefined
|
|
508
|
+
? undefined | Record<string, never>
|
|
509
|
+
: never
|
|
510
|
+
|
|
428
511
|
/** @internal */
|
|
429
512
|
export type MutationSelection = {query: string; params?: QueryParams} | {id: string | string[]}
|
|
430
513
|
/** @internal */
|
|
@@ -664,24 +747,29 @@ export interface ListenOptions {
|
|
|
664
747
|
}
|
|
665
748
|
|
|
666
749
|
/** @public */
|
|
667
|
-
export interface ResponseQueryOptions
|
|
750
|
+
export interface ResponseQueryOptions extends RequestOptions {
|
|
668
751
|
perspective?: ClientPerspective
|
|
669
752
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
670
|
-
cache?: RequestInit['cache']
|
|
671
|
-
next?: T extends keyof RequestInit ? RequestInit[T] : never
|
|
672
753
|
useCdn?: boolean
|
|
754
|
+
stega?: boolean | StegaConfig
|
|
755
|
+
// The `cache` and `next` options are specific to the Next.js App Router integration
|
|
756
|
+
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
757
|
+
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
673
758
|
}
|
|
674
759
|
|
|
675
760
|
/** @public */
|
|
676
|
-
export
|
|
761
|
+
export interface FilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
677
762
|
filterResponse?: true
|
|
678
763
|
}
|
|
679
764
|
|
|
680
765
|
/** @public */
|
|
681
|
-
export
|
|
766
|
+
export interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
682
767
|
filterResponse: false
|
|
683
768
|
}
|
|
684
769
|
|
|
770
|
+
/** @public */
|
|
771
|
+
export type QueryOptions = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
|
|
772
|
+
|
|
685
773
|
/** @public */
|
|
686
774
|
export interface RawQueryResponse<R> {
|
|
687
775
|
query: string
|
|
@@ -898,3 +986,17 @@ export interface ContentSourceMap {
|
|
|
898
986
|
documents: ContentSourceMapDocuments
|
|
899
987
|
paths: ContentSourceMapPaths
|
|
900
988
|
}
|
|
989
|
+
|
|
990
|
+
export type {
|
|
991
|
+
ContentSourceMapParsedPath,
|
|
992
|
+
ContentSourceMapParsedPathKeyedSegment,
|
|
993
|
+
FilterDefault,
|
|
994
|
+
InitializedStegaConfig,
|
|
995
|
+
Logger,
|
|
996
|
+
ResolveStudioUrl,
|
|
997
|
+
StegaConfig,
|
|
998
|
+
StegaConfigRequiredKeys,
|
|
999
|
+
StudioBaseRoute,
|
|
1000
|
+
StudioBaseUrl,
|
|
1001
|
+
StudioUrl,
|
|
1002
|
+
} from './stega/types'
|
package/src/users/UsersClient.ts
CHANGED
|
@@ -4,13 +4,16 @@ import {_request} from '../data/dataMethods'
|
|
|
4
4
|
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
5
|
import type {CurrentSanityUser, HttpRequest, SanityUser} from '../types'
|
|
6
6
|
|
|
7
|
+
const clientSymbol = Symbol('#client')
|
|
8
|
+
const httpRequestSymbol = Symbol('#httpRequest')
|
|
9
|
+
|
|
7
10
|
/** @public */
|
|
8
11
|
export class ObservableUsersClient {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
private [clientSymbol]: ObservableSanityClient
|
|
13
|
+
private [httpRequestSymbol]: HttpRequest
|
|
11
14
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {
|
|
12
|
-
this
|
|
13
|
-
this
|
|
15
|
+
this[clientSymbol] = client
|
|
16
|
+
this[httpRequestSymbol] = httpRequest
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -22,8 +25,8 @@ export class ObservableUsersClient {
|
|
|
22
25
|
id: T,
|
|
23
26
|
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser> {
|
|
24
27
|
return _request<T extends 'me' ? CurrentSanityUser : SanityUser>(
|
|
25
|
-
this
|
|
26
|
-
this
|
|
28
|
+
this[clientSymbol],
|
|
29
|
+
this[httpRequestSymbol],
|
|
27
30
|
{uri: `/users/${id}`},
|
|
28
31
|
)
|
|
29
32
|
}
|
|
@@ -31,11 +34,11 @@ export class ObservableUsersClient {
|
|
|
31
34
|
|
|
32
35
|
/** @public */
|
|
33
36
|
export class UsersClient {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
private [clientSymbol]: SanityClient
|
|
38
|
+
private [httpRequestSymbol]: HttpRequest
|
|
36
39
|
constructor(client: SanityClient, httpRequest: HttpRequest) {
|
|
37
|
-
this
|
|
38
|
-
this
|
|
40
|
+
this[clientSymbol] = client
|
|
41
|
+
this[httpRequestSymbol] = httpRequest
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -47,9 +50,13 @@ export class UsersClient {
|
|
|
47
50
|
id: T,
|
|
48
51
|
): Promise<T extends 'me' ? CurrentSanityUser : SanityUser> {
|
|
49
52
|
return lastValueFrom(
|
|
50
|
-
_request<T extends 'me' ? CurrentSanityUser : SanityUser>(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
_request<T extends 'me' ? CurrentSanityUser : SanityUser>(
|
|
54
|
+
this[clientSymbol],
|
|
55
|
+
this[httpRequestSymbol],
|
|
56
|
+
{
|
|
57
|
+
uri: `/users/${id}`,
|
|
58
|
+
},
|
|
59
|
+
),
|
|
53
60
|
)
|
|
54
61
|
}
|
|
55
62
|
}
|