@sanity/client 5.0.0-esm.9 → 5.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 +141 -65
- package/dist/index.browser.cjs +82 -162
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +82 -162
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +83 -163
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +51 -58
- package/dist/index.js +83 -163
- package/dist/index.js.map +1 -1
- package/package.json +22 -23
- package/src/SanityClient.ts +23 -25
- package/src/assets/AssetsClient.ts +29 -5
- package/src/data/dataMethods.ts +2 -2
- package/src/data/encodeQueryString.ts +15 -14
- package/src/data/listen.ts +4 -4
- package/src/data/patch.ts +1 -13
- package/src/datasets/DatasetsClient.ts +1 -1
- package/src/generateHelpUrl.ts +1 -1
- package/src/http/errors.ts +3 -5
- package/src/http/request.ts +1 -1
- package/src/projects/ProjectsClient.ts +1 -1
- package/src/users/UsersClient.ts +1 -1
- package/src/warnings.ts +1 -1
- package/umd/sanityClient.js +109 -414
- package/umd/sanityClient.min.js +3 -3
- package/src/auth/AuthClient.ts +0 -67
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+
|
|
21
|
+
"url": "git+ssh://git@github.com/sanity-io/client.git"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Sanity.io <hello@sanity.io>",
|
|
@@ -91,38 +91,37 @@
|
|
|
91
91
|
"@sanity/eventsource": "^4",
|
|
92
92
|
"@types/node": "^18.11.18",
|
|
93
93
|
"get-it": "^8",
|
|
94
|
-
"make-error": "^1.3.6",
|
|
95
94
|
"rxjs": "^7"
|
|
96
95
|
},
|
|
97
96
|
"devDependencies": {
|
|
98
|
-
"@edge-runtime/types": "^2.0.
|
|
99
|
-
"@edge-runtime/vm": "^2.0.
|
|
100
|
-
"@rollup/plugin-commonjs": "^24.0.
|
|
97
|
+
"@edge-runtime/types": "^2.0.3",
|
|
98
|
+
"@edge-runtime/vm": "^2.0.3",
|
|
99
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
101
100
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
102
|
-
"@sanity/pkg-utils": "^2.
|
|
103
|
-
"@sanity/semantic-release-preset": "^
|
|
104
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
105
|
-
"@typescript-eslint/parser": "^5.
|
|
106
|
-
"@vitest/coverage-c8": "^0.
|
|
107
|
-
"eslint": "^8.
|
|
101
|
+
"@sanity/pkg-utils": "^2.2.3",
|
|
102
|
+
"@sanity/semantic-release-preset": "^4.0.0",
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
|
104
|
+
"@typescript-eslint/parser": "^5.50.0",
|
|
105
|
+
"@vitest/coverage-c8": "^0.28.3",
|
|
106
|
+
"eslint": "^8.33.0",
|
|
108
107
|
"eslint-config-prettier": "^8.6.0",
|
|
109
108
|
"eslint-plugin-prettier": "^4.2.1",
|
|
110
|
-
"eslint-plugin-simple-import-sort": "^
|
|
109
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
111
110
|
"faucet": "^0.0.3",
|
|
112
|
-
"happy-dom": "^8.
|
|
113
|
-
"ls-engines": "^0.
|
|
111
|
+
"happy-dom": "^8.2.3",
|
|
112
|
+
"ls-engines": "^0.9.0",
|
|
114
113
|
"nock": "^13.3.0",
|
|
115
|
-
"prettier": "^2.8.
|
|
116
|
-
"prettier-plugin-packagejson": "^2.
|
|
117
|
-
"rimraf": "^
|
|
118
|
-
"rollup": "^3.
|
|
114
|
+
"prettier": "^2.8.3",
|
|
115
|
+
"prettier-plugin-packagejson": "^2.4.2",
|
|
116
|
+
"rimraf": "^4.1.2",
|
|
117
|
+
"rollup": "^3.12.1",
|
|
119
118
|
"sse-channel": "^4.0.0",
|
|
120
|
-
"terser": "^5.16.
|
|
121
|
-
"typescript": "^4.9.
|
|
122
|
-
"vitest": "^0.
|
|
119
|
+
"terser": "^5.16.2",
|
|
120
|
+
"typescript": "^4.9.5",
|
|
121
|
+
"vitest": "^0.28.3",
|
|
123
122
|
"vitest-github-actions-reporter": "^0.9.0"
|
|
124
123
|
},
|
|
125
124
|
"engines": {
|
|
126
|
-
"node": ">=14"
|
|
125
|
+
"node": ">=14.18"
|
|
127
126
|
}
|
|
128
127
|
}
|
package/src/SanityClient.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {lastValueFrom, Observable} from 'rxjs'
|
|
2
2
|
|
|
3
3
|
import {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'
|
|
4
|
-
import {AuthClient, ObservableAuthClient} from './auth/AuthClient'
|
|
5
4
|
import {defaultConfig, initConfig} from './config'
|
|
6
5
|
import * as dataMethods from './data/dataMethods'
|
|
7
6
|
import {_listen} from './data/listen'
|
|
@@ -39,10 +38,8 @@ import {ObservableUsersClient, UsersClient} from './users/UsersClient'
|
|
|
39
38
|
export type {
|
|
40
39
|
_listen,
|
|
41
40
|
AssetsClient,
|
|
42
|
-
AuthClient,
|
|
43
41
|
DatasetsClient,
|
|
44
42
|
ObservableAssetsClient,
|
|
45
|
-
ObservableAuthClient,
|
|
46
43
|
ObservableDatasetsClient,
|
|
47
44
|
ObservableProjectsClient,
|
|
48
45
|
ObservableUsersClient,
|
|
@@ -53,7 +50,6 @@ export type {
|
|
|
53
50
|
/** @public */
|
|
54
51
|
export class ObservableSanityClient {
|
|
55
52
|
assets: ObservableAssetsClient
|
|
56
|
-
auth: ObservableAuthClient
|
|
57
53
|
datasets: ObservableDatasetsClient
|
|
58
54
|
projects: ObservableProjectsClient
|
|
59
55
|
users: ObservableUsersClient
|
|
@@ -64,13 +60,17 @@ export class ObservableSanityClient {
|
|
|
64
60
|
#clientConfig: InitializedClientConfig
|
|
65
61
|
#httpRequest: HttpRequest
|
|
66
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Instance properties
|
|
65
|
+
*/
|
|
66
|
+
listen = _listen
|
|
67
|
+
|
|
67
68
|
constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {
|
|
68
69
|
this.config(config)
|
|
69
70
|
|
|
70
71
|
this.#httpRequest = httpRequest
|
|
71
72
|
|
|
72
73
|
this.assets = new ObservableAssetsClient(this, this.#httpRequest)
|
|
73
|
-
this.auth = new ObservableAuthClient(this, this.#httpRequest)
|
|
74
74
|
this.datasets = new ObservableDatasetsClient(this, this.#httpRequest)
|
|
75
75
|
this.projects = new ObservableProjectsClient(this, this.#httpRequest)
|
|
76
76
|
this.users = new ObservableUsersClient(this, this.#httpRequest)
|
|
@@ -127,7 +127,7 @@ export class ObservableSanityClient {
|
|
|
127
127
|
* @param query - GROQ-query to perform
|
|
128
128
|
* @param params - Query parameters
|
|
129
129
|
*/
|
|
130
|
-
fetch<R = FIXME>(query: string, params:
|
|
130
|
+
fetch<R = FIXME, Q = QueryParams>(query: string, params: Q): Observable<R>
|
|
131
131
|
/**
|
|
132
132
|
* Perform a GROQ-query against the configured dataset.
|
|
133
133
|
*
|
|
@@ -135,9 +135,9 @@ export class ObservableSanityClient {
|
|
|
135
135
|
* @param params - Query parameters
|
|
136
136
|
* @param options - Request options
|
|
137
137
|
*/
|
|
138
|
-
fetch<R = FIXME>(
|
|
138
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
139
139
|
query: string,
|
|
140
|
-
params:
|
|
140
|
+
params: Q | undefined,
|
|
141
141
|
options: FilteredResponseQueryOptions
|
|
142
142
|
): Observable<R>
|
|
143
143
|
/**
|
|
@@ -147,17 +147,17 @@ export class ObservableSanityClient {
|
|
|
147
147
|
* @param params - Query parameters
|
|
148
148
|
* @param options - Request options
|
|
149
149
|
*/
|
|
150
|
-
fetch<R = FIXME>(
|
|
150
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
151
151
|
query: string,
|
|
152
|
-
params:
|
|
152
|
+
params: Q | undefined,
|
|
153
153
|
options: UnfilteredResponseQueryOptions
|
|
154
154
|
): Observable<RawQueryResponse<R>>
|
|
155
|
-
fetch<R
|
|
155
|
+
fetch<R, Q extends QueryParams>(
|
|
156
156
|
query: string,
|
|
157
|
-
params?:
|
|
157
|
+
params?: Q,
|
|
158
158
|
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
159
159
|
): Observable<RawQueryResponse<R> | R> {
|
|
160
|
-
return dataMethods._fetch<R>(this, this.#httpRequest, query, params, options)
|
|
160
|
+
return dataMethods._fetch<R, Q>(this, this.#httpRequest, query, params, options)
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
@@ -177,7 +177,7 @@ export class ObservableSanityClient {
|
|
|
177
177
|
* Fetch multiple documents in one request.
|
|
178
178
|
* Should be used sparingly - performing a query is usually a better option.
|
|
179
179
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
180
|
-
* If
|
|
180
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
181
181
|
*
|
|
182
182
|
* @param ids - Document IDs to fetch
|
|
183
183
|
* @param options - Request options
|
|
@@ -618,7 +618,6 @@ export class ObservableSanityClient {
|
|
|
618
618
|
/** @public */
|
|
619
619
|
export class SanityClient {
|
|
620
620
|
assets: AssetsClient
|
|
621
|
-
auth: AuthClient
|
|
622
621
|
datasets: DatasetsClient
|
|
623
622
|
projects: ProjectsClient
|
|
624
623
|
users: UsersClient
|
|
@@ -645,7 +644,6 @@ export class SanityClient {
|
|
|
645
644
|
this.#httpRequest = httpRequest
|
|
646
645
|
|
|
647
646
|
this.assets = new AssetsClient(this, this.#httpRequest)
|
|
648
|
-
this.auth = new AuthClient(this, this.#httpRequest)
|
|
649
647
|
this.datasets = new DatasetsClient(this, this.#httpRequest)
|
|
650
648
|
this.projects = new ProjectsClient(this, this.#httpRequest)
|
|
651
649
|
this.users = new UsersClient(this, this.#httpRequest)
|
|
@@ -708,7 +706,7 @@ export class SanityClient {
|
|
|
708
706
|
* @param query - GROQ-query to perform
|
|
709
707
|
* @param params - Optional query parameters
|
|
710
708
|
*/
|
|
711
|
-
fetch<R = FIXME>(query: string, params:
|
|
709
|
+
fetch<R = FIXME, Q = QueryParams>(query: string, params: Q): Promise<R>
|
|
712
710
|
/**
|
|
713
711
|
* Perform a GROQ-query against the configured dataset.
|
|
714
712
|
*
|
|
@@ -716,9 +714,9 @@ export class SanityClient {
|
|
|
716
714
|
* @param params - Optional query parameters
|
|
717
715
|
* @param options - Request options
|
|
718
716
|
*/
|
|
719
|
-
fetch<R = FIXME>(
|
|
717
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
720
718
|
query: string,
|
|
721
|
-
params:
|
|
719
|
+
params: Q | undefined,
|
|
722
720
|
options: FilteredResponseQueryOptions
|
|
723
721
|
): Promise<R>
|
|
724
722
|
/**
|
|
@@ -728,17 +726,17 @@ export class SanityClient {
|
|
|
728
726
|
* @param params - Optional query parameters
|
|
729
727
|
* @param options - Request options
|
|
730
728
|
*/
|
|
731
|
-
fetch<R = FIXME>(
|
|
729
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
732
730
|
query: string,
|
|
733
|
-
params:
|
|
731
|
+
params: Q | undefined,
|
|
734
732
|
options: UnfilteredResponseQueryOptions
|
|
735
733
|
): Promise<RawQueryResponse<R>>
|
|
736
|
-
fetch<R
|
|
734
|
+
fetch<R, Q extends QueryParams>(
|
|
737
735
|
query: string,
|
|
738
|
-
params?:
|
|
736
|
+
params?: Q,
|
|
739
737
|
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
740
738
|
): Promise<RawQueryResponse<R> | R> {
|
|
741
|
-
return lastValueFrom(dataMethods._fetch<R>(this, this.#httpRequest, query, params, options))
|
|
739
|
+
return lastValueFrom(dataMethods._fetch<R, Q>(this, this.#httpRequest, query, params, options))
|
|
742
740
|
}
|
|
743
741
|
|
|
744
742
|
/**
|
|
@@ -758,7 +756,7 @@ export class SanityClient {
|
|
|
758
756
|
* Fetch multiple documents in one request.
|
|
759
757
|
* Should be used sparingly - performing a query is usually a better option.
|
|
760
758
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
761
|
-
* If
|
|
759
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
762
760
|
*
|
|
763
761
|
* @param ids - Document IDs to fetch
|
|
764
762
|
* @param options - Request options
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {type Observable
|
|
1
|
+
import {lastValueFrom, type Observable} from 'rxjs'
|
|
2
2
|
import {filter, map} from 'rxjs/operators'
|
|
3
3
|
|
|
4
4
|
import {_requestObservable} from '../data/dataMethods'
|
|
@@ -26,7 +26,7 @@ export class ObservableAssetsClient {
|
|
|
26
26
|
/**
|
|
27
27
|
* Uploads a file asset to the configured dataset
|
|
28
28
|
*
|
|
29
|
-
* @param assetType - Asset type (file
|
|
29
|
+
* @param assetType - Asset type (file)
|
|
30
30
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
31
31
|
* @param options - Options to use for the upload
|
|
32
32
|
*/
|
|
@@ -39,7 +39,7 @@ export class ObservableAssetsClient {
|
|
|
39
39
|
/**
|
|
40
40
|
* Uploads an image asset to the configured dataset
|
|
41
41
|
*
|
|
42
|
-
* @param assetType - Asset type (
|
|
42
|
+
* @param assetType - Asset type (image)
|
|
43
43
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
44
44
|
* @param options - Options to use for the upload
|
|
45
45
|
*/
|
|
@@ -48,6 +48,18 @@ export class ObservableAssetsClient {
|
|
|
48
48
|
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
49
49
|
options?: UploadClientConfig
|
|
50
50
|
): Observable<HttpRequestEvent<{document: SanityImageAssetDocument}>>
|
|
51
|
+
/**
|
|
52
|
+
* Uploads a file or an image asset to the configured dataset
|
|
53
|
+
*
|
|
54
|
+
* @param assetType - Asset type (file/image)
|
|
55
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
56
|
+
* @param options - Options to use for the upload
|
|
57
|
+
*/
|
|
58
|
+
upload(
|
|
59
|
+
assetType: 'file' | 'image',
|
|
60
|
+
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
61
|
+
options?: UploadClientConfig
|
|
62
|
+
): Observable<HttpRequestEvent<{document: SanityAssetDocument | SanityImageAssetDocument}>>
|
|
51
63
|
upload(
|
|
52
64
|
assetType: 'file' | 'image',
|
|
53
65
|
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
@@ -69,7 +81,7 @@ export class AssetsClient {
|
|
|
69
81
|
/**
|
|
70
82
|
* Uploads a file asset to the configured dataset
|
|
71
83
|
*
|
|
72
|
-
* @param assetType - Asset type (file
|
|
84
|
+
* @param assetType - Asset type (file)
|
|
73
85
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
74
86
|
* @param options - Options to use for the upload
|
|
75
87
|
*/
|
|
@@ -81,7 +93,7 @@ export class AssetsClient {
|
|
|
81
93
|
/**
|
|
82
94
|
* Uploads an image asset to the configured dataset
|
|
83
95
|
*
|
|
84
|
-
* @param assetType - Asset type (
|
|
96
|
+
* @param assetType - Asset type (image)
|
|
85
97
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
86
98
|
* @param options - Options to use for the upload
|
|
87
99
|
*/
|
|
@@ -90,6 +102,18 @@ export class AssetsClient {
|
|
|
90
102
|
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
91
103
|
options?: UploadClientConfig
|
|
92
104
|
): Promise<SanityImageAssetDocument>
|
|
105
|
+
/**
|
|
106
|
+
* Uploads a file or an image asset to the configured dataset
|
|
107
|
+
*
|
|
108
|
+
* @param assetType - Asset type (file/image)
|
|
109
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
110
|
+
* @param options - Options to use for the upload
|
|
111
|
+
*/
|
|
112
|
+
upload(
|
|
113
|
+
assetType: 'file' | 'image',
|
|
114
|
+
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
115
|
+
options?: UploadClientConfig
|
|
116
|
+
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
93
117
|
upload(
|
|
94
118
|
assetType: 'file' | 'image',
|
|
95
119
|
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
package/src/data/dataMethods.ts
CHANGED
|
@@ -60,11 +60,11 @@ const indexBy = (docs: FIXME[], attr: FIXME) =>
|
|
|
60
60
|
const getQuerySizeLimit = 11264
|
|
61
61
|
|
|
62
62
|
/** @internal */
|
|
63
|
-
export function _fetch<R>(
|
|
63
|
+
export function _fetch<R, Q extends QueryParams>(
|
|
64
64
|
client: ObservableSanityClient | SanityClient,
|
|
65
65
|
httpRequest: HttpRequest,
|
|
66
66
|
query: string,
|
|
67
|
-
params?:
|
|
67
|
+
params?: Q,
|
|
68
68
|
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
69
69
|
): Observable<RawQueryResponse<R> | R> {
|
|
70
70
|
const mapResponse =
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import type {FIXME, QueryParams} from '../types'
|
|
2
2
|
|
|
3
|
-
const enc = encodeURIComponent
|
|
4
|
-
|
|
5
3
|
export default ({
|
|
6
4
|
query,
|
|
7
|
-
params = {}
|
|
8
|
-
options = {}
|
|
5
|
+
params = {},
|
|
6
|
+
options = {},
|
|
9
7
|
}: {
|
|
10
8
|
query: string
|
|
11
9
|
params?: QueryParams
|
|
12
10
|
options?: FIXME
|
|
13
11
|
}) => {
|
|
12
|
+
const searchParams = new URLSearchParams()
|
|
14
13
|
// We generally want tag at the start of the query string
|
|
15
14
|
const {tag, ...opts} = options
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (tag) searchParams.set('tag', tag)
|
|
16
|
+
searchParams.set('query', query)
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// Iterate params, the keys are prefixed with `$` and their values JSON stringified
|
|
19
|
+
for (const [key, value] of Object.entries(params)) {
|
|
20
|
+
searchParams.set(`$${key}`, JSON.stringify(value))
|
|
21
|
+
}
|
|
22
|
+
// Options are passed as-is
|
|
23
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
24
|
+
// Skip falsy values
|
|
25
|
+
if (value) searchParams.set(key, `${value}`)
|
|
26
|
+
}
|
|
23
27
|
|
|
24
|
-
return
|
|
25
|
-
// Only include the option if it is truthy
|
|
26
|
-
return options[option] ? `${qs}&${enc(option)}=${enc(options[option])}` : qs
|
|
27
|
-
}, qString)
|
|
28
|
+
return `?${searchParams}`
|
|
28
29
|
}
|
package/src/data/listen.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import polyfilledEventSource from '@sanity/eventsource'
|
|
2
2
|
import {Observable} from 'rxjs'
|
|
3
3
|
|
|
4
|
-
import type {SanityClient} from '../SanityClient'
|
|
4
|
+
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
5
|
import type {FIXME, ListenEvent, ListenOptions, MutationEvent, QueryParams} from '../types'
|
|
6
6
|
import defaults from '../util/defaults'
|
|
7
7
|
import pick from '../util/pick'
|
|
@@ -35,7 +35,7 @@ const defaultOptions = {
|
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
37
|
export function _listen<R extends Record<string, FIXME> = Record<string, FIXME>>(
|
|
38
|
-
this: SanityClient,
|
|
38
|
+
this: SanityClient | ObservableSanityClient,
|
|
39
39
|
query: string,
|
|
40
40
|
params?: QueryParams
|
|
41
41
|
): Observable<MutationEvent<R>>
|
|
@@ -48,14 +48,14 @@ export function _listen<R extends Record<string, FIXME> = Record<string, FIXME>>
|
|
|
48
48
|
* @internal
|
|
49
49
|
*/
|
|
50
50
|
export function _listen<R extends Record<string, FIXME> = Record<string, FIXME>>(
|
|
51
|
-
this: SanityClient,
|
|
51
|
+
this: SanityClient | ObservableSanityClient,
|
|
52
52
|
query: string,
|
|
53
53
|
params?: QueryParams,
|
|
54
54
|
options?: ListenOptions
|
|
55
55
|
): Observable<ListenEvent<R>>
|
|
56
56
|
/** @internal */
|
|
57
57
|
export function _listen<R extends Record<string, FIXME> = Record<string, FIXME>>(
|
|
58
|
-
this: SanityClient,
|
|
58
|
+
this: SanityClient | ObservableSanityClient,
|
|
59
59
|
query: string,
|
|
60
60
|
params?: QueryParams,
|
|
61
61
|
opts: ListenOptions = {}
|
package/src/data/patch.ts
CHANGED
|
@@ -28,18 +28,6 @@ export class BasePatch {
|
|
|
28
28
|
this.operations = operations
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* DEPRECATED: Don't use.
|
|
33
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
34
|
-
*
|
|
35
|
-
* @deprecated - Don't use.
|
|
36
|
-
* @param attrs - Attributes to replace
|
|
37
|
-
*/
|
|
38
|
-
replace(attrs: AttributeSet): this {
|
|
39
|
-
validateObject('replace', attrs)
|
|
40
|
-
return this._set('set', {$: attrs})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
31
|
/**
|
|
44
32
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
45
33
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -142,7 +130,7 @@ export class BasePatch {
|
|
|
142
130
|
* @param selector - Attribute or JSONPath expression for array
|
|
143
131
|
* @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x
|
|
144
132
|
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
145
|
-
* @param items - The elements to add to the array, beginning at the start index. If you don't specify
|
|
133
|
+
* @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
|
|
146
134
|
*/
|
|
147
135
|
splice(selector: string, start: number, deleteCount?: number, items?: FIXME[]): this {
|
|
148
136
|
// Negative indexes doesn't mean the same in Sanity as they do in JS;
|
package/src/generateHelpUrl.ts
CHANGED
package/src/http/errors.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {ErrorProps, FIXME} from '../types'
|
|
1
|
+
import type {ErrorProps, FIXME} from '../types'
|
|
4
2
|
|
|
5
3
|
/** @public */
|
|
6
|
-
export class ClientError extends
|
|
4
|
+
export class ClientError extends Error {
|
|
7
5
|
response: ErrorProps['response']
|
|
8
6
|
statusCode: ErrorProps['statusCode'] = 400
|
|
9
7
|
responseBody: ErrorProps['responseBody']
|
|
@@ -17,7 +15,7 @@ export class ClientError extends BaseError {
|
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
/** @public */
|
|
20
|
-
export class ServerError extends
|
|
18
|
+
export class ServerError extends Error {
|
|
21
19
|
response: ErrorProps['response']
|
|
22
20
|
statusCode: ErrorProps['statusCode'] = 500
|
|
23
21
|
responseBody: ErrorProps['responseBody']
|
package/src/http/request.ts
CHANGED
package/src/users/UsersClient.ts
CHANGED
package/src/warnings.ts
CHANGED
|
@@ -8,7 +8,7 @@ const createWarningPrinter = (message: string[]) =>
|
|
|
8
8
|
|
|
9
9
|
export const printCdnWarning = createWarningPrinter([
|
|
10
10
|
'You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and',
|
|
11
|
-
`cheaper. Think about it! For more info, see ${generateHelpUrl('js-client-cdn-configuration')}
|
|
11
|
+
`cheaper. Think about it! For more info, see ${generateHelpUrl('js-client-cdn-configuration')} `,
|
|
12
12
|
'To hide this warning, please set the `useCdn` option to either `true` or `false` when creating',
|
|
13
13
|
'the client.',
|
|
14
14
|
])
|