@sanity/client 5.3.1 → 5.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -10,6 +10,7 @@ import type {
10
10
  ResponseEvent,
11
11
  SanityAssetDocument,
12
12
  SanityImageAssetDocument,
13
+ UploadBody,
13
14
  UploadClientConfig,
14
15
  } from '../types'
15
16
  import * as validators from '../validators'
@@ -32,7 +33,7 @@ export class ObservableAssetsClient {
32
33
  */
33
34
  upload(
34
35
  assetType: 'file',
35
- body: File | Blob | Buffer | NodeJS.ReadableStream,
36
+ body: UploadBody,
36
37
  options?: UploadClientConfig
37
38
  ): Observable<HttpRequestEvent<{document: SanityAssetDocument}>>
38
39
 
@@ -45,7 +46,7 @@ export class ObservableAssetsClient {
45
46
  */
46
47
  upload(
47
48
  assetType: 'image',
48
- body: File | Blob | Buffer | NodeJS.ReadableStream,
49
+ body: UploadBody,
49
50
  options?: UploadClientConfig
50
51
  ): Observable<HttpRequestEvent<{document: SanityImageAssetDocument}>>
51
52
  /**
@@ -57,12 +58,12 @@ export class ObservableAssetsClient {
57
58
  */
58
59
  upload(
59
60
  assetType: 'file' | 'image',
60
- body: File | Blob | Buffer | NodeJS.ReadableStream,
61
+ body: UploadBody,
61
62
  options?: UploadClientConfig
62
63
  ): Observable<HttpRequestEvent<{document: SanityAssetDocument | SanityImageAssetDocument}>>
63
64
  upload(
64
65
  assetType: 'file' | 'image',
65
- body: File | Blob | Buffer | NodeJS.ReadableStream,
66
+ body: UploadBody,
66
67
  options?: UploadClientConfig
67
68
  ): Observable<HttpRequestEvent<{document: SanityAssetDocument | SanityImageAssetDocument}>> {
68
69
  return _upload(this.#client, this.#httpRequest, assetType, body, options)
@@ -87,7 +88,7 @@ export class AssetsClient {
87
88
  */
88
89
  upload(
89
90
  assetType: 'file',
90
- body: File | Blob | Buffer | NodeJS.ReadableStream,
91
+ body: UploadBody,
91
92
  options?: UploadClientConfig
92
93
  ): Promise<SanityAssetDocument>
93
94
  /**
@@ -99,7 +100,7 @@ export class AssetsClient {
99
100
  */
100
101
  upload(
101
102
  assetType: 'image',
102
- body: File | Blob | Buffer | NodeJS.ReadableStream,
103
+ body: UploadBody,
103
104
  options?: UploadClientConfig
104
105
  ): Promise<SanityImageAssetDocument>
105
106
  /**
@@ -111,12 +112,12 @@ export class AssetsClient {
111
112
  */
112
113
  upload(
113
114
  assetType: 'file' | 'image',
114
- body: File | Blob | Buffer | NodeJS.ReadableStream,
115
+ body: UploadBody,
115
116
  options?: UploadClientConfig
116
117
  ): Promise<SanityAssetDocument | SanityImageAssetDocument>
117
118
  upload(
118
119
  assetType: 'file' | 'image',
119
- body: File | Blob | Buffer | NodeJS.ReadableStream,
120
+ body: UploadBody,
120
121
  options?: UploadClientConfig
121
122
  ): Promise<SanityAssetDocument | SanityImageAssetDocument> {
122
123
  const observable = _upload(this.#client, this.#httpRequest, assetType, body, options)
@@ -137,7 +138,7 @@ function _upload(
137
138
  client: SanityClient | ObservableSanityClient,
138
139
  httpRequest: HttpRequest,
139
140
  assetType: 'image' | 'file',
140
- body: File | Blob | Buffer | NodeJS.ReadableStream,
141
+ body: UploadBody,
141
142
  opts: UploadClientConfig = {}
142
143
  ): Observable<HttpRequestEvent<{document: SanityAssetDocument | SanityImageAssetDocument}>> {
143
144
  validators.validateAssetType(assetType)
package/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file no-empty-interface
1
2
  import type {Requester} from 'get-it'
2
3
 
3
4
  /**
@@ -6,6 +7,14 @@ import type {Requester} from 'get-it'
6
7
  */
7
8
  export type Any = any // eslint-disable-line @typescript-eslint/no-explicit-any
8
9
 
10
+ declare global {
11
+ // Declare empty stub interfaces for environments where "dom" lib is not included
12
+ interface File {}
13
+ }
14
+
15
+ /** @public */
16
+ export type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream
17
+
9
18
  /** @public */
10
19
  export interface RequestOptions {
11
20
  timeout?: number