@sanity/client 7.8.1 → 7.8.2-datasets.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 +17 -16
- package/dist/_chunks-cjs/config.cjs +1 -0
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +29 -2
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/config.js +1 -0
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +29 -2
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/index.browser.cjs +54 -14
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +25 -10
- package/dist/index.browser.d.ts +25 -10
- package/dist/index.browser.js +54 -14
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +54 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +54 -15
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +9 -10
- package/dist/stega.browser.d.ts +9 -10
- package/dist/stega.d.cts +9 -10
- package/dist/stega.d.ts +9 -10
- package/package.json +1 -1
- package/src/agent/actions/commonTypes.ts +3 -0
- package/src/agent/actions/prompt.ts +4 -10
- package/src/assets/AssetsClient.ts +5 -0
- package/src/data/dataMethods.ts +34 -1
- package/src/datasets/DatasetsClient.ts +48 -9
- package/src/projects/ProjectsClient.ts +0 -5
- package/src/stega/filterDefault.ts +30 -2
- package/src/types.ts +4 -0
- package/src/validators.ts +1 -0
- package/umd/sanityClient.js +83 -16
- package/umd/sanityClient.min.js +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type {ClientPerspective as ClientPerspective_2} from '@sanity/client'
|
|
1
2
|
import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
|
|
2
3
|
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
3
4
|
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
@@ -780,6 +781,10 @@ declare type ClientConfigResource =
|
|
|
780
781
|
type: 'dashboard'
|
|
781
782
|
id: string
|
|
782
783
|
}
|
|
784
|
+
| {
|
|
785
|
+
type: 'project'
|
|
786
|
+
id: string
|
|
787
|
+
}
|
|
783
788
|
|
|
784
789
|
/** @public */
|
|
785
790
|
export declare class ClientError extends Error {
|
|
@@ -1749,6 +1754,7 @@ export declare interface GroqAgentActionParam {
|
|
|
1749
1754
|
type: 'groq'
|
|
1750
1755
|
query: string
|
|
1751
1756
|
params?: Record<string, string>
|
|
1757
|
+
perspective?: ClientPerspective_2
|
|
1752
1758
|
}
|
|
1753
1759
|
|
|
1754
1760
|
/**
|
|
@@ -3826,10 +3832,8 @@ export declare class ProjectsClient {
|
|
|
3826
3832
|
declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
|
|
3827
3833
|
/**
|
|
3828
3834
|
*
|
|
3829
|
-
* When
|
|
3830
|
-
*
|
|
3831
|
-
*
|
|
3832
|
-
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3835
|
+
* When format is 'json', the response will be json according to the instruction.
|
|
3836
|
+
* Note: In addition to setting this to 'json', `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3833
3837
|
*/
|
|
3834
3838
|
format: 'json'
|
|
3835
3839
|
}
|
|
@@ -3936,13 +3940,9 @@ declare interface PromptRequestBase {
|
|
|
3936
3940
|
|
|
3937
3941
|
declare interface PromptTextResponse {
|
|
3938
3942
|
/**
|
|
3939
|
-
*
|
|
3940
|
-
* When true, the response body will be json according to the instruction.
|
|
3941
|
-
* When false, the response is the raw text response to the instruction.
|
|
3942
|
-
*
|
|
3943
|
-
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3943
|
+
* When format is 'string', the response will be a raw text response to the instruction.
|
|
3944
3944
|
*/
|
|
3945
|
-
format?: '
|
|
3945
|
+
format?: 'string'
|
|
3946
3946
|
}
|
|
3947
3947
|
|
|
3948
3948
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type {ClientPerspective as ClientPerspective_2} from '@sanity/client'
|
|
1
2
|
import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
|
|
2
3
|
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
3
4
|
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
@@ -780,6 +781,10 @@ declare type ClientConfigResource =
|
|
|
780
781
|
type: 'dashboard'
|
|
781
782
|
id: string
|
|
782
783
|
}
|
|
784
|
+
| {
|
|
785
|
+
type: 'project'
|
|
786
|
+
id: string
|
|
787
|
+
}
|
|
783
788
|
|
|
784
789
|
/** @public */
|
|
785
790
|
export declare class ClientError extends Error {
|
|
@@ -1749,6 +1754,7 @@ export declare interface GroqAgentActionParam {
|
|
|
1749
1754
|
type: 'groq'
|
|
1750
1755
|
query: string
|
|
1751
1756
|
params?: Record<string, string>
|
|
1757
|
+
perspective?: ClientPerspective_2
|
|
1752
1758
|
}
|
|
1753
1759
|
|
|
1754
1760
|
/**
|
|
@@ -3826,10 +3832,8 @@ export declare class ProjectsClient {
|
|
|
3826
3832
|
declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
|
|
3827
3833
|
/**
|
|
3828
3834
|
*
|
|
3829
|
-
* When
|
|
3830
|
-
*
|
|
3831
|
-
*
|
|
3832
|
-
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3835
|
+
* When format is 'json', the response will be json according to the instruction.
|
|
3836
|
+
* Note: In addition to setting this to 'json', `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3833
3837
|
*/
|
|
3834
3838
|
format: 'json'
|
|
3835
3839
|
}
|
|
@@ -3936,13 +3940,9 @@ declare interface PromptRequestBase {
|
|
|
3936
3940
|
|
|
3937
3941
|
declare interface PromptTextResponse {
|
|
3938
3942
|
/**
|
|
3939
|
-
*
|
|
3940
|
-
* When true, the response body will be json according to the instruction.
|
|
3941
|
-
* When false, the response is the raw text response to the instruction.
|
|
3942
|
-
*
|
|
3943
|
-
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3943
|
+
* When format is 'string', the response will be a raw text response to the instruction.
|
|
3944
3944
|
*/
|
|
3945
|
-
format?: '
|
|
3945
|
+
format?: 'string'
|
|
3946
3946
|
}
|
|
3947
3947
|
|
|
3948
3948
|
/**
|
package/dist/index.js
CHANGED
|
@@ -931,10 +931,24 @@ 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
|
-
resourceConfig(config)
|
|
935
|
-
|
|
934
|
+
if (resourceConfig(config), operation === "" && path?.startsWith("datasets")) {
|
|
935
|
+
const { type, id } = config["~experimental_resource"];
|
|
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("/");
|
|
936
948
|
return `${resourceBase}/${uri2}`.replace(/\/($|\?)/, "$1");
|
|
937
949
|
}
|
|
950
|
+
if (operation === "")
|
|
951
|
+
return `/${path || ""}`;
|
|
938
952
|
const catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
939
953
|
return `/data${path !== void 0 ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
|
|
940
954
|
}
|
|
@@ -979,6 +993,8 @@ const resourceDataBase = (config) => {
|
|
|
979
993
|
return `/media-libraries/${id}`;
|
|
980
994
|
case "dashboard":
|
|
981
995
|
return `/dashboards/${id}`;
|
|
996
|
+
case "project":
|
|
997
|
+
return `/projects/${id}`;
|
|
982
998
|
default:
|
|
983
999
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
984
1000
|
}
|
|
@@ -1149,6 +1165,10 @@ function buildAssetUploadUrl(config, assetType) {
|
|
|
1149
1165
|
if (config["~experimental_resource"]) {
|
|
1150
1166
|
const { type, id } = config["~experimental_resource"];
|
|
1151
1167
|
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
|
+
);
|
|
1152
1172
|
case "dataset":
|
|
1153
1173
|
throw new Error(
|
|
1154
1174
|
"Assets are not supported for dataset resources, yet. Configure the client with `{projectId: <projectId>, dataset: <datasetId>}` instead."
|
|
@@ -1366,8 +1386,12 @@ class ObservableDatasetsClient {
|
|
|
1366
1386
|
* Fetch a list of datasets for the configured project
|
|
1367
1387
|
*/
|
|
1368
1388
|
list() {
|
|
1389
|
+
const resource = this.#client.config()["~experimental_resource"];
|
|
1390
|
+
if (resource && resource.type !== "project")
|
|
1391
|
+
throw new Error('`dataset.list()` requires a resource type of "project".');
|
|
1392
|
+
const uri = _getDataUrl(this.#client, "", "datasets");
|
|
1369
1393
|
return _request(this.#client, this.#httpRequest, {
|
|
1370
|
-
uri
|
|
1394
|
+
uri,
|
|
1371
1395
|
tag: null
|
|
1372
1396
|
});
|
|
1373
1397
|
}
|
|
@@ -1385,7 +1409,7 @@ class DatasetsClient {
|
|
|
1385
1409
|
* @param options - Options for the dataset
|
|
1386
1410
|
*/
|
|
1387
1411
|
create(name2, options) {
|
|
1388
|
-
return
|
|
1412
|
+
return lastValueFrom(
|
|
1389
1413
|
_modify(this.#client, this.#httpRequest, "PUT", name2, options)
|
|
1390
1414
|
);
|
|
1391
1415
|
}
|
|
@@ -1396,7 +1420,7 @@ class DatasetsClient {
|
|
|
1396
1420
|
* @param options - New options for the dataset
|
|
1397
1421
|
*/
|
|
1398
1422
|
edit(name2, options) {
|
|
1399
|
-
return
|
|
1423
|
+
return lastValueFrom(
|
|
1400
1424
|
_modify(this.#client, this.#httpRequest, "PATCH", name2, options)
|
|
1401
1425
|
);
|
|
1402
1426
|
}
|
|
@@ -1406,21 +1430,38 @@ class DatasetsClient {
|
|
|
1406
1430
|
* @param name - Name of the dataset to delete
|
|
1407
1431
|
*/
|
|
1408
1432
|
delete(name2) {
|
|
1409
|
-
return
|
|
1433
|
+
return lastValueFrom(_modify(this.#client, this.#httpRequest, "DELETE", name2));
|
|
1410
1434
|
}
|
|
1411
1435
|
/**
|
|
1412
1436
|
* Fetch a list of datasets for the configured project
|
|
1413
1437
|
*/
|
|
1414
1438
|
list() {
|
|
1415
|
-
|
|
1416
|
-
|
|
1439
|
+
const resource = this.#client.config()["~experimental_resource"];
|
|
1440
|
+
if (resource && resource.type !== "project")
|
|
1441
|
+
throw new Error('`dataset.list()` requires a resource type of "project".');
|
|
1442
|
+
const uri = _getDataUrl(this.#client, "", "datasets");
|
|
1443
|
+
return lastValueFrom(
|
|
1444
|
+
_request(this.#client, this.#httpRequest, { uri, tag: null })
|
|
1417
1445
|
);
|
|
1418
1446
|
}
|
|
1419
1447
|
}
|
|
1420
1448
|
function _modify(client, httpRequest, method, name2, options) {
|
|
1421
|
-
|
|
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, {
|
|
1422
1463
|
method,
|
|
1423
|
-
uri
|
|
1464
|
+
uri,
|
|
1424
1465
|
body: options,
|
|
1425
1466
|
tag: null
|
|
1426
1467
|
});
|
|
@@ -1432,7 +1473,6 @@ class ObservableProjectsClient {
|
|
|
1432
1473
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
1433
1474
|
}
|
|
1434
1475
|
list(options) {
|
|
1435
|
-
resourceGuard("projects", this.#client.config());
|
|
1436
1476
|
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
1437
1477
|
return _request(this.#client, this.#httpRequest, { uri });
|
|
1438
1478
|
}
|
|
@@ -1442,7 +1482,7 @@ class ObservableProjectsClient {
|
|
|
1442
1482
|
* @param projectId - ID of the project to fetch
|
|
1443
1483
|
*/
|
|
1444
1484
|
getById(projectId) {
|
|
1445
|
-
return
|
|
1485
|
+
return _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId}` });
|
|
1446
1486
|
}
|
|
1447
1487
|
}
|
|
1448
1488
|
class ProjectsClient {
|
|
@@ -1452,7 +1492,6 @@ class ProjectsClient {
|
|
|
1452
1492
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
1453
1493
|
}
|
|
1454
1494
|
list(options) {
|
|
1455
|
-
resourceGuard("projects", this.#client.config());
|
|
1456
1495
|
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
1457
1496
|
return lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
|
|
1458
1497
|
}
|
|
@@ -1462,7 +1501,7 @@ class ProjectsClient {
|
|
|
1462
1501
|
* @param projectId - ID of the project to fetch
|
|
1463
1502
|
*/
|
|
1464
1503
|
getById(projectId) {
|
|
1465
|
-
return
|
|
1504
|
+
return lastValueFrom(
|
|
1466
1505
|
_request(this.#client, this.#httpRequest, { uri: `/projects/${projectId}` })
|
|
1467
1506
|
);
|
|
1468
1507
|
}
|
|
@@ -2560,7 +2599,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2560
2599
|
return printNoDefaultExport(), createClient2(config);
|
|
2561
2600
|
};
|
|
2562
2601
|
}
|
|
2563
|
-
var name = "@sanity/client", version = "7.8.
|
|
2602
|
+
var name = "@sanity/client", version = "7.8.2-datasets.0";
|
|
2564
2603
|
const middleware = [
|
|
2565
2604
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2566
2605
|
headers({ "User-Agent": `${name} ${version}` }),
|