@sanity/client 7.8.2-datasets.0 → 7.9.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/_chunks-cjs/config.cjs +0 -1
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +0 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +15 -51
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +4 -4
- package/dist/index.browser.d.ts +4 -4
- package/dist/index.browser.js +15 -51
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +16 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +16 -51
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +4 -4
- package/dist/stega.browser.d.ts +4 -4
- package/dist/stega.d.cts +4 -4
- package/dist/stega.d.ts +4 -4
- package/package.json +1 -1
- package/src/assets/AssetsClient.ts +0 -5
- package/src/data/dataMethods.ts +1 -34
- package/src/datasets/DatasetsClient.ts +16 -39
- package/src/types.ts +4 -4
- package/src/validators.ts +0 -1
- package/umd/sanityClient.js +15 -51
- package/umd/sanityClient.min.js +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -781,10 +781,6 @@ declare type ClientConfigResource =
|
|
|
781
781
|
type: 'dashboard'
|
|
782
782
|
id: string
|
|
783
783
|
}
|
|
784
|
-
| {
|
|
785
|
-
type: 'project'
|
|
786
|
-
id: string
|
|
787
|
-
}
|
|
788
784
|
|
|
789
785
|
/** @public */
|
|
790
786
|
export declare class ClientError extends Error {
|
|
@@ -4110,6 +4106,9 @@ export declare type ReleaseAction =
|
|
|
4110
4106
|
| UnscheduleReleaseAction
|
|
4111
4107
|
| DeleteReleaseAction
|
|
4112
4108
|
|
|
4109
|
+
/** @public */
|
|
4110
|
+
export declare type ReleaseCardinality = 'many' | 'one' | undefined
|
|
4111
|
+
|
|
4113
4112
|
/** @internal */
|
|
4114
4113
|
export declare interface ReleaseDocument extends SanityDocument {
|
|
4115
4114
|
/**
|
|
@@ -4146,6 +4145,7 @@ export declare interface ReleaseDocument extends SanityDocument {
|
|
|
4146
4145
|
description?: string
|
|
4147
4146
|
intendedPublishAt?: string
|
|
4148
4147
|
releaseType: ReleaseType
|
|
4148
|
+
cardinality?: ReleaseCardinality
|
|
4149
4149
|
}
|
|
4150
4150
|
}
|
|
4151
4151
|
|
package/dist/index.d.ts
CHANGED
|
@@ -781,10 +781,6 @@ declare type ClientConfigResource =
|
|
|
781
781
|
type: 'dashboard'
|
|
782
782
|
id: string
|
|
783
783
|
}
|
|
784
|
-
| {
|
|
785
|
-
type: 'project'
|
|
786
|
-
id: string
|
|
787
|
-
}
|
|
788
784
|
|
|
789
785
|
/** @public */
|
|
790
786
|
export declare class ClientError extends Error {
|
|
@@ -4110,6 +4106,9 @@ export declare type ReleaseAction =
|
|
|
4110
4106
|
| UnscheduleReleaseAction
|
|
4111
4107
|
| DeleteReleaseAction
|
|
4112
4108
|
|
|
4109
|
+
/** @public */
|
|
4110
|
+
export declare type ReleaseCardinality = 'many' | 'one' | undefined
|
|
4111
|
+
|
|
4113
4112
|
/** @internal */
|
|
4114
4113
|
export declare interface ReleaseDocument extends SanityDocument {
|
|
4115
4114
|
/**
|
|
@@ -4146,6 +4145,7 @@ export declare interface ReleaseDocument extends SanityDocument {
|
|
|
4146
4145
|
description?: string
|
|
4147
4146
|
intendedPublishAt?: string
|
|
4148
4147
|
releaseType: ReleaseType
|
|
4148
|
+
cardinality?: ReleaseCardinality
|
|
4149
4149
|
}
|
|
4150
4150
|
}
|
|
4151
4151
|
|
package/dist/index.js
CHANGED
|
@@ -931,24 +931,10 @@ function _request(client, httpRequest, options) {
|
|
|
931
931
|
function _getDataUrl(client, operation, path) {
|
|
932
932
|
const config = client.config();
|
|
933
933
|
if (config["~experimental_resource"]) {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
if (type === "dataset") {
|
|
937
|
-
const segments = id.split(".");
|
|
938
|
-
if (segments.length !== 2)
|
|
939
|
-
throw new Error('Invalid dataset resource ID. Expected format "project.dataset".');
|
|
940
|
-
const base = `/projects/${segments[0]}`, uri3 = [path].filter(Boolean).join("/");
|
|
941
|
-
return `${base}/${uri3}`.replace(/\/($|\?)/, "$1");
|
|
942
|
-
} else if (type === "project") {
|
|
943
|
-
const base = `/projects/${id}`, uri3 = [path].filter(Boolean).join("/");
|
|
944
|
-
return `${base}/${uri3}`.replace(/\/($|\?)/, "$1");
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
const resourceBase = resourceDataBase(config), uri2 = [operation, path].filter(Boolean).join("/");
|
|
934
|
+
resourceConfig(config);
|
|
935
|
+
const resourceBase = resourceDataBase(config), uri2 = path !== void 0 ? `${operation}/${path}` : operation;
|
|
948
936
|
return `${resourceBase}/${uri2}`.replace(/\/($|\?)/, "$1");
|
|
949
937
|
}
|
|
950
|
-
if (operation === "")
|
|
951
|
-
return `/${path || ""}`;
|
|
952
938
|
const catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
953
939
|
return `/data${path !== void 0 ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
|
|
954
940
|
}
|
|
@@ -993,8 +979,6 @@ const resourceDataBase = (config) => {
|
|
|
993
979
|
return `/media-libraries/${id}`;
|
|
994
980
|
case "dashboard":
|
|
995
981
|
return `/dashboards/${id}`;
|
|
996
|
-
case "project":
|
|
997
|
-
return `/projects/${id}`;
|
|
998
982
|
default:
|
|
999
983
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
1000
984
|
}
|
|
@@ -1165,10 +1149,6 @@ function buildAssetUploadUrl(config, assetType) {
|
|
|
1165
1149
|
if (config["~experimental_resource"]) {
|
|
1166
1150
|
const { type, id } = config["~experimental_resource"];
|
|
1167
1151
|
switch (type) {
|
|
1168
|
-
case "project":
|
|
1169
|
-
throw new Error(
|
|
1170
|
-
"Assets are not supported for project resources, yet. Configure the client with `{projectId: <projectId>}` instead."
|
|
1171
|
-
);
|
|
1172
1152
|
case "dataset":
|
|
1173
1153
|
throw new Error(
|
|
1174
1154
|
"Assets are not supported for dataset resources, yet. Configure the client with `{projectId: <projectId>, dataset: <datasetId>}` instead."
|
|
@@ -1386,11 +1366,10 @@ class ObservableDatasetsClient {
|
|
|
1386
1366
|
* Fetch a list of datasets for the configured project
|
|
1387
1367
|
*/
|
|
1388
1368
|
list() {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
return _request(this.#client, this.#httpRequest, {
|
|
1369
|
+
resourceGuard("dataset", this.#client.config());
|
|
1370
|
+
const config = this.#client.config(), projectId = config.projectId;
|
|
1371
|
+
let uri = "/datasets";
|
|
1372
|
+
return config.useProjectHostname === !1 && (uri = `/projects/${projectId}/datasets`), _request(this.#client, this.#httpRequest, {
|
|
1394
1373
|
uri,
|
|
1395
1374
|
tag: null
|
|
1396
1375
|
});
|
|
@@ -1409,7 +1388,7 @@ class DatasetsClient {
|
|
|
1409
1388
|
* @param options - Options for the dataset
|
|
1410
1389
|
*/
|
|
1411
1390
|
create(name2, options) {
|
|
1412
|
-
return lastValueFrom(
|
|
1391
|
+
return resourceGuard("dataset", this.#client.config()), lastValueFrom(
|
|
1413
1392
|
_modify(this.#client, this.#httpRequest, "PUT", name2, options)
|
|
1414
1393
|
);
|
|
1415
1394
|
}
|
|
@@ -1420,7 +1399,7 @@ class DatasetsClient {
|
|
|
1420
1399
|
* @param options - New options for the dataset
|
|
1421
1400
|
*/
|
|
1422
1401
|
edit(name2, options) {
|
|
1423
|
-
return lastValueFrom(
|
|
1402
|
+
return resourceGuard("dataset", this.#client.config()), lastValueFrom(
|
|
1424
1403
|
_modify(this.#client, this.#httpRequest, "PATCH", name2, options)
|
|
1425
1404
|
);
|
|
1426
1405
|
}
|
|
@@ -1430,38 +1409,24 @@ class DatasetsClient {
|
|
|
1430
1409
|
* @param name - Name of the dataset to delete
|
|
1431
1410
|
*/
|
|
1432
1411
|
delete(name2) {
|
|
1433
|
-
return lastValueFrom(_modify(this.#client, this.#httpRequest, "DELETE", name2));
|
|
1412
|
+
return resourceGuard("dataset", this.#client.config()), lastValueFrom(_modify(this.#client, this.#httpRequest, "DELETE", name2));
|
|
1434
1413
|
}
|
|
1435
1414
|
/**
|
|
1436
1415
|
* Fetch a list of datasets for the configured project
|
|
1437
1416
|
*/
|
|
1438
1417
|
list() {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
return lastValueFrom(
|
|
1418
|
+
resourceGuard("dataset", this.#client.config());
|
|
1419
|
+
const config = this.#client.config(), projectId = config.projectId;
|
|
1420
|
+
let uri = "/datasets";
|
|
1421
|
+
return config.useProjectHostname === !1 && (uri = `/projects/${projectId}/datasets`), lastValueFrom(
|
|
1444
1422
|
_request(this.#client, this.#httpRequest, { uri, tag: null })
|
|
1445
1423
|
);
|
|
1446
1424
|
}
|
|
1447
1425
|
}
|
|
1448
1426
|
function _modify(client, httpRequest, method, name2, options) {
|
|
1449
|
-
dataset(name2)
|
|
1450
|
-
const resource = client.config()["~experimental_resource"];
|
|
1451
|
-
if (resource)
|
|
1452
|
-
if (resource.type === "dataset") {
|
|
1453
|
-
const segments = resource.id.split(".");
|
|
1454
|
-
if (segments.length !== 2)
|
|
1455
|
-
throw new Error('Dataset resource ID must be in the format "project.dataset"');
|
|
1456
|
-
const datasetName = segments[1];
|
|
1457
|
-
if (name2 !== datasetName)
|
|
1458
|
-
throw new Error(`Dataset name "${name2}" does not match resource dataset "${datasetName}"`);
|
|
1459
|
-
} else
|
|
1460
|
-
throw new Error('Dataset create/edit/delete operations require a resource type of "dataset"');
|
|
1461
|
-
const uri = _getDataUrl(client, "", `datasets/${name2}`);
|
|
1462
|
-
return _request(client, httpRequest, {
|
|
1427
|
+
return resourceGuard("dataset", client.config()), dataset(name2), _request(client, httpRequest, {
|
|
1463
1428
|
method,
|
|
1464
|
-
uri
|
|
1429
|
+
uri: `/datasets/${name2}`,
|
|
1465
1430
|
body: options,
|
|
1466
1431
|
tag: null
|
|
1467
1432
|
});
|
|
@@ -2599,7 +2564,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2599
2564
|
return printNoDefaultExport(), createClient2(config);
|
|
2600
2565
|
};
|
|
2601
2566
|
}
|
|
2602
|
-
var name = "@sanity/client", version = "7.
|
|
2567
|
+
var name = "@sanity/client", version = "7.9.0";
|
|
2603
2568
|
const middleware = [
|
|
2604
2569
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2605
2570
|
headers({ "User-Agent": `${name} ${version}` }),
|