@sanity/client 6.2.0-fetch.6 → 6.3.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.browser.cjs +13 -19
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +13 -19
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +14 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +105 -97
- package/dist/index.js +14 -20
- package/dist/index.js.map +1 -1
- package/package.json +23 -19
- package/src/SanityClient.ts +83 -83
- package/src/assets/AssetsClient.ts +13 -13
- package/src/config.ts +3 -4
- package/src/data/dataMethods.ts +20 -21
- package/src/data/listen.ts +3 -3
- package/src/data/patch.ts +11 -11
- package/src/data/transaction.ts +13 -13
- package/src/datasets/DatasetsClient.ts +4 -4
- package/src/http/request.ts +1 -1
- package/src/http/requestOptions.ts +1 -1
- package/src/index.browser.ts +1 -1
- package/src/index.ts +1 -1
- package/src/projects/ProjectsClient.ts +21 -9
- package/src/users/UsersClient.ts +4 -4
- package/src/validators.ts +2 -2
- package/src/warnings.ts +1 -1
- package/umd/sanityClient.js +57 -30
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.js
CHANGED
|
@@ -204,26 +204,26 @@ const validateObject = (op, val) => {
|
|
|
204
204
|
};
|
|
205
205
|
const validateDocumentId = (op, id) => {
|
|
206
206
|
if (typeof id !== "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes("..")) {
|
|
207
|
-
throw new Error("".concat(op,
|
|
207
|
+
throw new Error("".concat(op, '(): "').concat(id, '" is not a valid document ID'));
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
210
|
const requireDocumentId = (op, doc) => {
|
|
211
211
|
if (!doc._id) {
|
|
212
|
-
throw new Error("".concat(op,
|
|
212
|
+
throw new Error("".concat(op, '() requires that the document contains an ID ("_id" property)'));
|
|
213
213
|
}
|
|
214
214
|
validateDocumentId(op, doc._id);
|
|
215
215
|
};
|
|
216
216
|
const validateInsert = (at, selector, items) => {
|
|
217
217
|
const signature = "insert(at, selector, items)";
|
|
218
218
|
if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
|
|
219
|
-
const valid = VALID_INSERT_LOCATIONS.map(loc => "
|
|
220
|
-
throw new Error("".concat(signature,
|
|
219
|
+
const valid = VALID_INSERT_LOCATIONS.map(loc => '"'.concat(loc, '"')).join(", ");
|
|
220
|
+
throw new Error("".concat(signature, ' takes an "at"-argument which is one of: ').concat(valid));
|
|
221
221
|
}
|
|
222
222
|
if (typeof selector !== "string") {
|
|
223
|
-
throw new Error("".concat(signature,
|
|
223
|
+
throw new Error("".concat(signature, ' takes a "selector"-argument which must be a string'));
|
|
224
224
|
}
|
|
225
225
|
if (!Array.isArray(items)) {
|
|
226
|
-
throw new Error("".concat(signature,
|
|
226
|
+
throw new Error("".concat(signature, ' takes an "items"-argument which must be an array'));
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
229
|
const hasDataset = config => {
|
|
@@ -908,9 +908,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
908
908
|
const reqOptions = requestOptions(config, Object.assign({}, options, {
|
|
909
909
|
url: _getUrl(client, uri, useCdn)
|
|
910
910
|
}));
|
|
911
|
-
const request = new Observable(subscriber =>
|
|
912
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- the typings thinks it's optional because it's not required to specify it when calling createClient, but it's always defined in practice since SanityClient provides a default
|
|
913
|
-
httpRequest(reqOptions, config.requester).subscribe(subscriber));
|
|
911
|
+
const request = new Observable(subscriber => httpRequest(reqOptions, config.requester).subscribe(subscriber));
|
|
914
912
|
return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request;
|
|
915
913
|
}
|
|
916
914
|
function _request(client, httpRequest, options) {
|
|
@@ -1459,12 +1457,10 @@ class ObservableProjectsClient {
|
|
|
1459
1457
|
__privateSet$2(this, _client$1, client);
|
|
1460
1458
|
__privateSet$2(this, _httpRequest$2, httpRequest);
|
|
1461
1459
|
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
*/
|
|
1465
|
-
list() {
|
|
1460
|
+
list(options) {
|
|
1461
|
+
const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
|
|
1466
1462
|
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
|
|
1467
|
-
uri
|
|
1463
|
+
uri
|
|
1468
1464
|
});
|
|
1469
1465
|
}
|
|
1470
1466
|
/**
|
|
@@ -1487,12 +1483,10 @@ class ProjectsClient {
|
|
|
1487
1483
|
__privateSet$2(this, _client2$1, client);
|
|
1488
1484
|
__privateSet$2(this, _httpRequest2$2, httpRequest);
|
|
1489
1485
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
*/
|
|
1493
|
-
list() {
|
|
1486
|
+
list(options) {
|
|
1487
|
+
const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
|
|
1494
1488
|
return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
|
|
1495
|
-
uri
|
|
1489
|
+
uri
|
|
1496
1490
|
}));
|
|
1497
1491
|
}
|
|
1498
1492
|
/**
|