@sanity/client 7.26.2 → 8.0.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 +5 -377
- package/dist/browserUpload-CQgx9YYo.js +86 -0
- package/dist/browserUpload-CQgx9YYo.js.map +1 -0
- package/dist/browserUpload-icWlVP15.js +86 -0
- package/dist/browserUpload-icWlVP15.js.map +1 -0
- package/dist/config-a8VajuEY.js +126 -0
- package/dist/config-a8VajuEY.js.map +1 -0
- package/dist/csm.d.ts +122 -335
- package/dist/csm.js +79 -91
- package/dist/csm.js.map +1 -1
- package/dist/dist-C9ExSk2R.js +73 -0
- package/dist/dist-C9ExSk2R.js.map +1 -0
- package/dist/dist-Z8cIRxoB.js +69 -0
- package/dist/dist-Z8cIRxoB.js.map +1 -0
- package/dist/index.d.ts +107 -6723
- package/dist/index.js +2822 -2847
- package/dist/index.js.map +1 -1
- package/dist/{index.d.cts → index.node.d.ts} +4291 -5328
- package/dist/index.node.js +3131 -0
- package/dist/index.node.js.map +1 -0
- package/dist/isRecord-Kfmt-nk-.js +7 -0
- package/dist/isRecord-Kfmt-nk-.js.map +1 -0
- package/dist/media-library.d.ts +9 -100
- package/dist/media-library.js +36 -14
- package/dist/media-library.js.map +1 -1
- package/dist/request-CJxcN16k.js +372 -0
- package/dist/request-CJxcN16k.js.map +1 -0
- package/dist/request-k7VS_NnC.js +354 -0
- package/dist/request-k7VS_NnC.js.map +1 -0
- package/dist/resolveEditInfo-sq7yF78q.js +325 -0
- package/dist/resolveEditInfo-sq7yF78q.js.map +1 -0
- package/dist/rolldown-runtime-vyAXikos.js +9 -0
- package/dist/stega.d.ts +78 -7137
- package/dist/stega.js +27 -20
- package/dist/stega.js.map +1 -1
- package/dist/stegaClean-C18wLWau.js +21 -0
- package/dist/stegaClean-C18wLWau.js.map +1 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js +163 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js.map +1 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js +367 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +1 -0
- package/dist/{index.browser.d.cts → types-CUxZSgB2.d.ts} +3956 -5256
- package/dist/types-CfGzbXrl.d.ts +108 -0
- package/package.json +64 -141
- package/src/SanityClient.ts +82 -117
- package/src/agent/actions/AgentActionsClient.ts +12 -12
- package/src/agent/actions/commonTypes.ts +2 -1
- package/src/agent/actions/generate.ts +26 -6
- package/src/agent/actions/patch.ts +27 -7
- package/src/agent/actions/prompt.ts +19 -5
- package/src/agent/actions/transform.ts +23 -5
- package/src/agent/actions/translate.ts +23 -5
- package/src/assets/AssetsClient.ts +71 -23
- package/src/csm/applySourceDocuments.ts +3 -1
- package/src/csm/createEditUrl.ts +1 -1
- package/src/csm/draftUtils.ts +0 -1
- package/src/csm/index.ts +2 -2
- package/src/csm/studioPath.ts +2 -1
- package/src/csm/types.ts +8 -2
- package/src/data/dataMethods.ts +801 -349
- package/src/data/eventsource.ts +13 -10
- package/src/data/listen.ts +18 -23
- package/src/data/live.ts +44 -27
- package/src/data/resolveEventSourceFetch.ts +96 -0
- package/src/datasets/DatasetsClient.ts +58 -41
- package/src/defineCreateClient.ts +35 -23
- package/src/http/browserMiddleware.ts +7 -1
- package/src/http/browserUpload.ts +162 -0
- package/src/http/errors.ts +60 -6
- package/src/http/nodeMiddleware.ts +94 -30
- package/src/http/request.ts +310 -87
- package/src/http/requestOptions.ts +131 -15
- package/src/{index.browser.ts → index.node.ts} +9 -4
- package/src/index.ts +4 -3
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +26 -11
- package/src/projects/ProjectsClient.ts +18 -16
- package/src/releases/ReleasesClient.ts +38 -33
- package/src/stega/index.ts +1 -2
- package/src/stega/stegaEncodeSourceMap.ts +5 -0
- package/src/stega/types.ts +2 -2
- package/src/types.ts +148 -105
- package/src/users/UsersClient.ts +10 -14
- package/src/util/shareReplayLatest.ts +1 -1
- package/src/warnings.ts +6 -1
- package/dist/_chunks-cjs/config.cjs +0 -206
- package/dist/_chunks-cjs/config.cjs.map +0 -1
- package/dist/_chunks-cjs/isRecord.cjs +0 -6
- package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs +0 -334
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaClean.cjs +0 -46
- package/dist/_chunks-cjs/stegaClean.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +0 -388
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +0 -1
- package/dist/_chunks-es/config.js +0 -207
- package/dist/_chunks-es/config.js.map +0 -1
- package/dist/_chunks-es/isRecord.js +0 -7
- package/dist/_chunks-es/isRecord.js.map +0 -1
- package/dist/_chunks-es/resolveEditInfo.js +0 -335
- package/dist/_chunks-es/resolveEditInfo.js.map +0 -1
- package/dist/_chunks-es/stegaClean.js +0 -47
- package/dist/_chunks-es/stegaClean.js.map +0 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +0 -389
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
- package/dist/csm.cjs +0 -99
- package/dist/csm.cjs.map +0 -1
- package/dist/csm.d.cts +0 -391
- package/dist/index.browser.cjs +0 -3106
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.ts +0 -6802
- package/dist/index.browser.js +0 -3082
- package/dist/index.browser.js.map +0 -1
- package/dist/index.cjs +0 -2946
- package/dist/index.cjs.map +0 -1
- package/dist/media-library.cjs +0 -20
- package/dist/media-library.cjs.map +0 -1
- package/dist/media-library.d.cts +0 -117
- package/dist/stega.browser.cjs +0 -29
- package/dist/stega.browser.cjs.map +0 -1
- package/dist/stega.browser.d.cts +0 -7200
- package/dist/stega.browser.d.ts +0 -7200
- package/dist/stega.browser.js +0 -24
- package/dist/stega.browser.js.map +0 -1
- package/dist/stega.cjs +0 -29
- package/dist/stega.cjs.map +0 -1
- package/dist/stega.d.cts +0 -7200
- package/src/data/eventsourcePolyfill.ts +0 -7
- package/umd/.gitkeep +0 -1
- package/umd/sanityClient.js +0 -6543
- package/umd/sanityClient.min.js +0 -6
package/src/types.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-empty-interface
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
3
2
|
|
|
4
|
-
import type {
|
|
3
|
+
import type {FetchFunction} from 'get-it'
|
|
5
4
|
import type {Observable} from 'rxjs'
|
|
6
5
|
|
|
7
|
-
import type {SanityClient} from './SanityClient'
|
|
8
6
|
import type {InitializedStegaConfig, StegaConfig} from './stega/types'
|
|
9
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Low-level requester returned by `defineHttpRequest`. Surfaces as
|
|
10
|
+
* `client.config().requester` and as the named `requester` export.
|
|
11
|
+
*
|
|
12
|
+
* Defined locally rather than imported from `http/request` so api-extractor
|
|
13
|
+
* inlines it into the bundled `.d.ts` instead of emitting a relative import
|
|
14
|
+
* that doesn't survive into `dist/` ([#1290][]).
|
|
15
|
+
*
|
|
16
|
+
* [#1290]: https://github.com/sanity-io/client/issues/1290
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export type Requester = (options: Any) => Observable<unknown>
|
|
21
|
+
|
|
10
22
|
/**
|
|
11
23
|
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
12
24
|
* @internal
|
|
13
25
|
*/
|
|
14
|
-
export type Any = any //
|
|
26
|
+
export type Any = any // oxlint-disable-line typescript/no-explicit-any
|
|
15
27
|
|
|
16
28
|
declare global {
|
|
17
29
|
// Declare empty stub interfaces for environments where "dom" lib is not included
|
|
@@ -45,11 +57,15 @@ export type ReleaseId = `r${string}`
|
|
|
45
57
|
type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
46
58
|
|
|
47
59
|
/** @public */
|
|
48
|
-
export type StackablePerspective =
|
|
60
|
+
export type StackablePerspective = 'published' | 'drafts' | (string & {})
|
|
49
61
|
|
|
50
62
|
/** @public */
|
|
51
63
|
export type ClientPerspective =
|
|
52
|
-
|
|
64
|
+
| DeprecatedPreviewDrafts
|
|
65
|
+
| 'published'
|
|
66
|
+
| 'drafts'
|
|
67
|
+
| 'raw'
|
|
68
|
+
| StackablePerspective[]
|
|
53
69
|
|
|
54
70
|
/**
|
|
55
71
|
* @public
|
|
@@ -130,6 +146,12 @@ export interface ClientConfig {
|
|
|
130
146
|
* As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}
|
|
131
147
|
*/
|
|
132
148
|
apiVersion?: string
|
|
149
|
+
/**
|
|
150
|
+
* Route requests through an HTTP(S) proxy. Node.js only. Can be replaced
|
|
151
|
+
* on an existing client via `client.config({proxy})` or
|
|
152
|
+
* `client.withConfig({proxy})`. For environment-driven proxying, set
|
|
153
|
+
* `HTTP_PROXY`/`HTTPS_PROXY`/`NO_PROXY` before the process starts.
|
|
154
|
+
*/
|
|
133
155
|
proxy?: string
|
|
134
156
|
|
|
135
157
|
/**
|
|
@@ -192,16 +214,33 @@ export interface ClientConfig {
|
|
|
192
214
|
useProjectHostname?: boolean
|
|
193
215
|
|
|
194
216
|
/**
|
|
195
|
-
*
|
|
217
|
+
* Resolves the fetch implementation every request (including EventSource
|
|
218
|
+
* connections) goes through. Defaults to the environment entry point's
|
|
219
|
+
* fetch — the Node entry supplies get-it's undici-backed fetch (resolved
|
|
220
|
+
* via the entry point instead of a direct import so `get-it/node`/`undici`
|
|
221
|
+
* stays out of the browser bundle), the browser entry leaves it unset (the
|
|
222
|
+
* global fetch IS the environment's fetch there). Receives the explicit
|
|
223
|
+
* `proxy` config, when set, as its argument.
|
|
224
|
+
*
|
|
225
|
+
* Supplying it in the client config replaces the transport wholesale —
|
|
226
|
+
* custom fetch variants, alternative undici configurations, or a mock
|
|
227
|
+
* (the test suite injects `get-it/mock` this way).
|
|
228
|
+
*
|
|
229
|
+
* Returns get-it's minimal `FetchFunction` contract rather than the full
|
|
230
|
+
* `typeof fetch` — that is what the environments actually provide, and
|
|
231
|
+
* every consumer (the transport, the EventSource fetch resolver) only
|
|
232
|
+
* needs that subset.
|
|
233
|
+
*
|
|
234
|
+
* @internal
|
|
196
235
|
*/
|
|
197
|
-
|
|
236
|
+
resolveFetch?: (proxyUrl?: string) => FetchFunction
|
|
198
237
|
|
|
199
238
|
/**
|
|
200
239
|
* Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`
|
|
201
240
|
*/
|
|
202
241
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
203
242
|
/**
|
|
204
|
-
|
|
243
|
+
* @deprecated set `cache` and `next` options on `client.fetch` instead
|
|
205
244
|
*/
|
|
206
245
|
fetch?:
|
|
207
246
|
| {
|
|
@@ -217,33 +256,6 @@ export interface ClientConfig {
|
|
|
217
256
|
* Lineage token for recursion control
|
|
218
257
|
*/
|
|
219
258
|
lineage?: string
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* A custom request handler that intercepts all HTTP requests made by the client.
|
|
223
|
-
*
|
|
224
|
-
* Useful for logging, adding custom headers, refreshing auth tokens, rate limiting, etc.
|
|
225
|
-
*
|
|
226
|
-
* When using `withConfig()`, the new handler **replaces** the previous one (it does not
|
|
227
|
-
* wrap it). To compose handlers, you can chain them manually:
|
|
228
|
-
*
|
|
229
|
-
* ```ts
|
|
230
|
-
* const parent = createClient({...config, _requestHandler: handlerA})
|
|
231
|
-
* const child = parent.withConfig({
|
|
232
|
-
* _requestHandler: (req, defaultRequester) =>
|
|
233
|
-
* handlerB(req, (opts) => handlerA(opts, defaultRequester)),
|
|
234
|
-
* })
|
|
235
|
-
* ```
|
|
236
|
-
*
|
|
237
|
-
* Setting `_requestHandler` to `undefined` via `withConfig()` removes the handler.
|
|
238
|
-
*
|
|
239
|
-
* Note: This only applies to HTTP requests. Real-time listener connections
|
|
240
|
-
* (`client.listen()`) use EventSource and are not intercepted by this handler.
|
|
241
|
-
*
|
|
242
|
-
* @internal
|
|
243
|
-
* @deprecated Don't use outside of Sanity internals
|
|
244
|
-
* @see {@link RequestHandler}
|
|
245
|
-
*/
|
|
246
|
-
_requestHandler?: RequestHandler
|
|
247
259
|
}
|
|
248
260
|
|
|
249
261
|
/** @public */
|
|
@@ -270,6 +282,14 @@ export interface InitializedClientConfig extends ClientConfig {
|
|
|
270
282
|
* The fully initialized stega config, can be used to check if stega is enabled
|
|
271
283
|
*/
|
|
272
284
|
stega: InitializedStegaConfig
|
|
285
|
+
/**
|
|
286
|
+
* The resolved low-level requester for this client. Always populated by
|
|
287
|
+
* `createClient` so internal paths (e.g. the asset upload event stream) can
|
|
288
|
+
* reach the underlying transport.
|
|
289
|
+
*
|
|
290
|
+
* @internal
|
|
291
|
+
*/
|
|
292
|
+
requester: Requester
|
|
273
293
|
/**
|
|
274
294
|
* Default headers to include with all requests
|
|
275
295
|
*
|
|
@@ -280,7 +300,14 @@ export interface InitializedClientConfig extends ClientConfig {
|
|
|
280
300
|
|
|
281
301
|
/** @public */
|
|
282
302
|
export type AssetMetadataType =
|
|
283
|
-
|
|
303
|
+
| 'location'
|
|
304
|
+
| 'exif'
|
|
305
|
+
| 'image'
|
|
306
|
+
| 'palette'
|
|
307
|
+
| 'lqip'
|
|
308
|
+
| 'blurhash'
|
|
309
|
+
| 'thumbhash'
|
|
310
|
+
| 'none'
|
|
284
311
|
|
|
285
312
|
/** @public */
|
|
286
313
|
export interface UploadClientConfig {
|
|
@@ -300,7 +327,10 @@ export interface UploadClientConfig {
|
|
|
300
327
|
filename?: string
|
|
301
328
|
|
|
302
329
|
/**
|
|
303
|
-
* Milliseconds to wait before timing the request out
|
|
330
|
+
* Milliseconds to wait before timing the request out.
|
|
331
|
+
*
|
|
332
|
+
* Unlike other requests, uploads have NO timeout unless one is explicitly
|
|
333
|
+
* set here — uploads can legitimately be slow, so timing out is opt-in.
|
|
304
334
|
*/
|
|
305
335
|
timeout?: number
|
|
306
336
|
|
|
@@ -442,63 +472,56 @@ export interface ErrorProps {
|
|
|
442
472
|
details: Any
|
|
443
473
|
}
|
|
444
474
|
|
|
445
|
-
/**
|
|
475
|
+
/**
|
|
476
|
+
* The internal HTTP request abstraction used by the client. Resolves directly
|
|
477
|
+
* to the parsed response body as a Promise — middleware-level transport
|
|
478
|
+
* details (status codes, headers, progress events) are not exposed. The
|
|
479
|
+
* observable client surface wraps this in an Observable; the promise surface
|
|
480
|
+
* uses it directly.
|
|
481
|
+
*
|
|
482
|
+
* The body is typed as `unknown`; consumers narrow at their own boundary.
|
|
483
|
+
*
|
|
484
|
+
* @internal
|
|
485
|
+
*/
|
|
446
486
|
export type HttpRequest = {
|
|
447
|
-
(options:
|
|
487
|
+
(options: Any): Promise<unknown>
|
|
448
488
|
}
|
|
449
489
|
|
|
450
490
|
/**
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* Receives the resolved request options, a `defaultRequester` function that
|
|
454
|
-
* executes the request through the normal pipeline, and a `client` instance
|
|
455
|
-
* without a `_requestHandler` (to avoid recursive interception).
|
|
456
|
-
*
|
|
457
|
-
* The consumer can:
|
|
458
|
-
* - Modify request options before calling `defaultRequester`
|
|
459
|
-
* - Transform the response stream (e.g. via `pipe`)
|
|
460
|
-
* - Skip `defaultRequester` entirely and return a custom Observable
|
|
461
|
-
* - Use `client` to make additional requests (e.g. refresh an auth token on 401)
|
|
462
|
-
*
|
|
463
|
-
* When set via `withConfig()`, the new handler **replaces** (not wraps) the previous one.
|
|
464
|
-
*
|
|
465
|
-
* Note: This only applies to HTTP requests. Real-time listener connections
|
|
466
|
-
* (`client.listen()`) use EventSource and are not intercepted by this handler.
|
|
467
|
-
*
|
|
468
|
-
* @param request - The resolved request options including `url`
|
|
469
|
-
* @param defaultRequester - Executes the request through the normal pipeline
|
|
470
|
-
* @param client - A client instance with the same configuration but without a `_requestHandler`,
|
|
471
|
-
* useful for making side requests (e.g. token refresh) without triggering the handler recursively
|
|
491
|
+
* Target URL for a request. Exactly one of `url` or the deprecated `uri` alias
|
|
492
|
+
* must be given.
|
|
472
493
|
*
|
|
473
494
|
* @internal
|
|
474
|
-
* @deprecated Don't use outside of Sanity internals
|
|
475
495
|
*/
|
|
476
|
-
export type
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
496
|
+
export type RequestUrlOptions =
|
|
497
|
+
| {url: string; uri?: never}
|
|
498
|
+
| {
|
|
499
|
+
/**
|
|
500
|
+
* @deprecated Use `url` instead. Support for `uri` will be removed in a future version.
|
|
501
|
+
*/
|
|
502
|
+
uri: string
|
|
503
|
+
url?: never
|
|
504
|
+
}
|
|
481
505
|
|
|
482
506
|
/** @internal */
|
|
483
|
-
export
|
|
484
|
-
url
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
507
|
+
export type RequestObservableOptions = RequestUrlOptions &
|
|
508
|
+
Omit<RequestOptions, 'url'> & {
|
|
509
|
+
canUseCdn?: boolean
|
|
510
|
+
useCdn?: boolean
|
|
511
|
+
tag?: string
|
|
512
|
+
returnQuery?: boolean
|
|
513
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
514
|
+
perspective?: ClientPerspective
|
|
515
|
+
/**
|
|
516
|
+
* @beta
|
|
517
|
+
*/
|
|
518
|
+
variant?: ClientVariant
|
|
519
|
+
lastLiveEventId?: string
|
|
520
|
+
cacheMode?: 'noStale'
|
|
521
|
+
}
|
|
499
522
|
|
|
500
523
|
/** @public */
|
|
501
|
-
export interface
|
|
524
|
+
export interface UploadProgressEvent {
|
|
502
525
|
type: 'progress'
|
|
503
526
|
stage: 'upload' | 'download'
|
|
504
527
|
percent: number
|
|
@@ -508,18 +531,20 @@ export interface ProgressEvent {
|
|
|
508
531
|
}
|
|
509
532
|
|
|
510
533
|
/** @public */
|
|
511
|
-
export interface
|
|
534
|
+
export interface UploadResponseEvent<T = unknown> {
|
|
512
535
|
type: 'response'
|
|
513
536
|
body: T
|
|
514
|
-
url: string
|
|
515
|
-
method: string
|
|
516
|
-
statusCode: number
|
|
517
|
-
statusMessage?: string
|
|
518
|
-
headers: Record<string, string>
|
|
519
537
|
}
|
|
520
538
|
|
|
521
|
-
/**
|
|
522
|
-
|
|
539
|
+
/**
|
|
540
|
+
* Events emitted by `client.assets.upload()` when called via the observable
|
|
541
|
+
* API. Progress events are best-effort — they're only emitted when the
|
|
542
|
+
* environment supports tracking upload/download bytes (e.g. browsers via
|
|
543
|
+
* `XMLHttpRequest`). Other runtimes only emit the terminal `response` event.
|
|
544
|
+
*
|
|
545
|
+
* @public
|
|
546
|
+
*/
|
|
547
|
+
export type UploadEvent<T = unknown> = UploadResponseEvent<T> | UploadProgressEvent
|
|
523
548
|
|
|
524
549
|
/** @internal */
|
|
525
550
|
export interface AuthProvider {
|
|
@@ -652,7 +677,9 @@ export type IdentifiedSanityDocumentStub<T extends Record<string, Any> = Record<
|
|
|
652
677
|
|
|
653
678
|
/** @internal */
|
|
654
679
|
export type InsertPatch =
|
|
655
|
-
|
|
680
|
+
| {before: string; items: Any[]}
|
|
681
|
+
| {after: string; items: Any[]}
|
|
682
|
+
| {replace: string; items: Any[]}
|
|
656
683
|
|
|
657
684
|
// Note: this is actually incorrect/invalid, but implemented as-is for backwards compatibility
|
|
658
685
|
/** @internal */
|
|
@@ -669,7 +696,7 @@ export interface PatchOperations {
|
|
|
669
696
|
|
|
670
697
|
/** @public */
|
|
671
698
|
export interface QueryParams {
|
|
672
|
-
/*
|
|
699
|
+
/* oxlint-disable typescript/no-explicit-any */
|
|
673
700
|
[key: string]: any
|
|
674
701
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
675
702
|
body?: never
|
|
@@ -709,7 +736,7 @@ export interface QueryParams {
|
|
|
709
736
|
lastLiveEventId?: never
|
|
710
737
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
711
738
|
cacheMode?: never
|
|
712
|
-
/*
|
|
739
|
+
/* oxlint-enable typescript/no-explicit-any */
|
|
713
740
|
}
|
|
714
741
|
|
|
715
742
|
/**
|
|
@@ -722,7 +749,8 @@ export type QueryWithoutParams = Record<string, never> | undefined
|
|
|
722
749
|
export type MutationSelectionQueryParams = {[key: string]: Any}
|
|
723
750
|
/** @internal */
|
|
724
751
|
export type MutationSelection =
|
|
725
|
-
{query: string; params?: MutationSelectionQueryParams}
|
|
752
|
+
| {query: string; params?: MutationSelectionQueryParams}
|
|
753
|
+
| {id: string | string[]}
|
|
726
754
|
/** @internal */
|
|
727
755
|
export type PatchSelection = string | string[] | MutationSelection
|
|
728
756
|
/** @internal */
|
|
@@ -750,7 +778,10 @@ export type ReleaseAction =
|
|
|
750
778
|
|
|
751
779
|
/** @public */
|
|
752
780
|
export type VersionAction =
|
|
753
|
-
|
|
781
|
+
| CreateVersionAction
|
|
782
|
+
| DiscardVersionAction
|
|
783
|
+
| ReplaceVersionAction
|
|
784
|
+
| UnpublishVersionAction
|
|
754
785
|
|
|
755
786
|
/** @public */
|
|
756
787
|
export type Action =
|
|
@@ -1296,7 +1327,12 @@ export type ResetEvent = {
|
|
|
1296
1327
|
|
|
1297
1328
|
/** @public */
|
|
1298
1329
|
export type ListenEvent<R extends Record<string, Any> = Record<string, Any>> =
|
|
1299
|
-
MutationEvent<R>
|
|
1330
|
+
| MutationEvent<R>
|
|
1331
|
+
| ReconnectEvent
|
|
1332
|
+
| WelcomeBackEvent
|
|
1333
|
+
| ResetEvent
|
|
1334
|
+
| WelcomeEvent
|
|
1335
|
+
| OpenEvent
|
|
1300
1336
|
|
|
1301
1337
|
/** @public */
|
|
1302
1338
|
export type ListenEventName =
|
|
@@ -1476,7 +1512,9 @@ export interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
|
|
|
1476
1512
|
|
|
1477
1513
|
/** @public */
|
|
1478
1514
|
export type QueryOptions =
|
|
1479
|
-
|
|
1515
|
+
| FilteredResponseQueryOptions
|
|
1516
|
+
| UnfilteredResponseQueryOptions
|
|
1517
|
+
| UnfilteredResponseWithoutQuery
|
|
1480
1518
|
|
|
1481
1519
|
/** @public */
|
|
1482
1520
|
export interface RawQueryResponse<R> {
|
|
@@ -1595,11 +1633,10 @@ export interface MultipleActionResult {
|
|
|
1595
1633
|
}
|
|
1596
1634
|
|
|
1597
1635
|
/** @internal */
|
|
1598
|
-
export
|
|
1599
|
-
url?: string
|
|
1600
|
-
uri?: string
|
|
1636
|
+
export type RawRequestOptions = RequestUrlOptions & {
|
|
1601
1637
|
method?: string
|
|
1602
1638
|
token?: string
|
|
1639
|
+
/** @deprecated has no effect — response parsing is driven by the response `content-type` */
|
|
1603
1640
|
json?: boolean
|
|
1604
1641
|
tag?: string
|
|
1605
1642
|
useGlobalApi?: boolean
|
|
@@ -1607,9 +1644,10 @@ export interface RawRequestOptions {
|
|
|
1607
1644
|
query?: {[key: string]: string | string[]}
|
|
1608
1645
|
headers?: {[key: string]: string}
|
|
1609
1646
|
timeout?: number
|
|
1610
|
-
proxy?: string
|
|
1611
1647
|
body?: Any
|
|
1612
1648
|
maxRedirects?: number
|
|
1649
|
+
/** Max retries for this request; `0` disables retries. Overrides the client-level maximum in both directions. */
|
|
1650
|
+
maxRetries?: number
|
|
1613
1651
|
signal?: AbortSignal
|
|
1614
1652
|
}
|
|
1615
1653
|
|
|
@@ -1805,7 +1843,8 @@ export interface ContentSourceMapRemoteDocument extends ContentSourceMapDocument
|
|
|
1805
1843
|
|
|
1806
1844
|
/** @public */
|
|
1807
1845
|
export type ContentSourceMapDocuments = (
|
|
1808
|
-
|
|
1846
|
+
| ContentSourceMapDocument
|
|
1847
|
+
| ContentSourceMapRemoteDocument
|
|
1809
1848
|
)[]
|
|
1810
1849
|
|
|
1811
1850
|
/** @public */
|
|
@@ -1851,7 +1890,11 @@ export interface LiveEventGoAway {
|
|
|
1851
1890
|
}
|
|
1852
1891
|
/** @public */
|
|
1853
1892
|
export type LiveEvent =
|
|
1854
|
-
|
|
1893
|
+
| LiveEventRestart
|
|
1894
|
+
| LiveEventReconnect
|
|
1895
|
+
| LiveEventMessage
|
|
1896
|
+
| LiveEventWelcome
|
|
1897
|
+
| LiveEventGoAway
|
|
1855
1898
|
|
|
1856
1899
|
/** @public */
|
|
1857
1900
|
export interface SanityQueries {}
|
package/src/users/UsersClient.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {type Observable} from 'rxjs'
|
|
2
2
|
|
|
3
|
-
import {_request} from '../data/dataMethods'
|
|
3
|
+
import {_request, _requestObservable} from '../data/dataMethods'
|
|
4
4
|
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
5
|
import type {CurrentSanityUser, HttpRequest, SanityUser} from '../types'
|
|
6
6
|
|
|
@@ -18,13 +18,11 @@ export class ObservableUsersClient {
|
|
|
18
18
|
*
|
|
19
19
|
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
20
20
|
*/
|
|
21
|
-
getById<T extends 'me'
|
|
22
|
-
|
|
23
|
-
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser> {
|
|
24
|
-
return _request<T extends 'me' ? CurrentSanityUser : SanityUser>(
|
|
21
|
+
getById<T extends string>(id: T): Observable<T extends 'me' ? CurrentSanityUser : SanityUser> {
|
|
22
|
+
return _requestObservable<T extends 'me' ? CurrentSanityUser : SanityUser>(
|
|
25
23
|
this.#client,
|
|
26
24
|
this.#httpRequest,
|
|
27
|
-
{
|
|
25
|
+
{url: `/users/${id}`},
|
|
28
26
|
)
|
|
29
27
|
}
|
|
30
28
|
}
|
|
@@ -43,13 +41,11 @@ export class UsersClient {
|
|
|
43
41
|
*
|
|
44
42
|
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
45
43
|
*/
|
|
46
|
-
getById<T extends 'me'
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
uri: `/users/${id}`,
|
|
52
|
-
}),
|
|
44
|
+
getById<T extends string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser> {
|
|
45
|
+
return _request<T extends 'me' ? CurrentSanityUser : SanityUser>(
|
|
46
|
+
this.#client,
|
|
47
|
+
this.#httpRequest,
|
|
48
|
+
{url: `/users/${id}`},
|
|
53
49
|
)
|
|
54
50
|
}
|
|
55
51
|
}
|
|
@@ -44,7 +44,7 @@ function _shareReplayLatest<T>(config: ShareReplayLatestConfig<T>): MonoTypeOper
|
|
|
44
44
|
let latest: T | undefined
|
|
45
45
|
let emitted = false
|
|
46
46
|
|
|
47
|
-
//
|
|
47
|
+
// oxlint-disable-next-line no-unused-vars
|
|
48
48
|
const {predicate, ...shareConfig} = config
|
|
49
49
|
|
|
50
50
|
const wrapped = source.pipe(
|
package/src/warnings.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {type Any} from './types'
|
|
|
3
3
|
import {once} from './util/once'
|
|
4
4
|
|
|
5
5
|
const createWarningPrinter = (message: string[]) =>
|
|
6
|
-
//
|
|
6
|
+
// oxlint-disable-next-line no-console
|
|
7
7
|
once((...args: Any[]) => console.warn(message.join(' '), ...args))
|
|
8
8
|
|
|
9
9
|
export const printCdnAndWithCredentialsWarning = createWarningPrinter([
|
|
@@ -51,6 +51,11 @@ export const printCreateVersionWithBaseIdWarning = createWarningPrinter([
|
|
|
51
51
|
'You have called `createVersion()` with a defined `document`. The recommended approach is to provide a `baseId` and `releaseId` instead.',
|
|
52
52
|
])
|
|
53
53
|
|
|
54
|
+
export const printDeprecatedUriOptionWarning = createWarningPrinter([
|
|
55
|
+
'The `uri` request option has been renamed to `url`.',
|
|
56
|
+
'Please update your code to use `url` instead. Support for `uri` will be removed in a future version.',
|
|
57
|
+
])
|
|
58
|
+
|
|
54
59
|
export const printDeprecatedResourceConfigWarning = createWarningPrinter([
|
|
55
60
|
'The `~experimental_resource` configuration property has been renamed to `resource`.',
|
|
56
61
|
'Please update your client configuration to use `resource` instead. Support for `~experimental_resource` will be removed in a future version.',
|