@sanity/client 7.0.1-canary.1 → 7.1.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 +102 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1366 -1538
- package/dist/index.browser.d.ts +1366 -1538
- package/dist/index.browser.js +102 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +103 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1366 -1538
- package/dist/index.d.ts +1366 -1538
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1373 -1545
- package/dist/stega.browser.d.ts +1373 -1545
- package/dist/stega.d.cts +1373 -1545
- package/dist/stega.d.ts +1373 -1545
- package/package.json +2 -1
- package/src/SanityClient.ts +30 -1078
- package/src/agent/actions/AgentActionsClient.ts +111 -0
- package/src/agent/actions/commonTypes.ts +336 -0
- package/src/agent/actions/generate.ts +274 -0
- package/src/agent/actions/transform.ts +215 -0
- package/src/agent/actions/translate.ts +165 -0
- package/src/assets/AssetsClient.ts +2 -98
- package/src/data/dataMethods.ts +1 -1
- package/src/data/transaction.ts +1 -1
- package/src/projects/ProjectsClient.ts +2 -2
- package/src/types.ts +30 -1
- package/umd/sanityClient.js +102 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -981,6 +981,86 @@ const resourceDataBase = (config) => {
|
|
|
981
981
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
982
982
|
}
|
|
983
983
|
};
|
|
984
|
+
function _generate(client, httpRequest, request) {
|
|
985
|
+
const dataset2 = hasDataset(client.config());
|
|
986
|
+
return _request(client, httpRequest, {
|
|
987
|
+
method: "POST",
|
|
988
|
+
uri: `/agent/action/generate/${dataset2}`,
|
|
989
|
+
body: request
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
function _transform(client, httpRequest, request) {
|
|
993
|
+
const dataset2 = hasDataset(client.config());
|
|
994
|
+
return _request(client, httpRequest, {
|
|
995
|
+
method: "POST",
|
|
996
|
+
uri: `/agent/action/transform/${dataset2}`,
|
|
997
|
+
body: request
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
function _translate(client, httpRequest, request) {
|
|
1001
|
+
const dataset2 = hasDataset(client.config());
|
|
1002
|
+
return _request(client, httpRequest, {
|
|
1003
|
+
method: "POST",
|
|
1004
|
+
uri: `/agent/action/translate/${dataset2}`,
|
|
1005
|
+
body: request
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
class ObservableAgentsActionClient {
|
|
1009
|
+
#client;
|
|
1010
|
+
#httpRequest;
|
|
1011
|
+
constructor(client, httpRequest) {
|
|
1012
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Run an instruction to generate content in a target document.
|
|
1016
|
+
* @param request - instruction request
|
|
1017
|
+
*/
|
|
1018
|
+
generate(request) {
|
|
1019
|
+
return _generate(this.#client, this.#httpRequest, request);
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Transform a target document based on a source.
|
|
1023
|
+
* @param request - translation request
|
|
1024
|
+
*/
|
|
1025
|
+
transform(request) {
|
|
1026
|
+
return _transform(this.#client, this.#httpRequest, request);
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Translate a target document based on a source.
|
|
1030
|
+
* @param request - translation request
|
|
1031
|
+
*/
|
|
1032
|
+
translate(request) {
|
|
1033
|
+
return _translate(this.#client, this.#httpRequest, request);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
class AgentActionsClient {
|
|
1037
|
+
#client;
|
|
1038
|
+
#httpRequest;
|
|
1039
|
+
constructor(client, httpRequest) {
|
|
1040
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Run an instruction to generate content in a target document.
|
|
1044
|
+
* @param request - instruction request
|
|
1045
|
+
*/
|
|
1046
|
+
generate(request) {
|
|
1047
|
+
return rxjs.lastValueFrom(_generate(this.#client, this.#httpRequest, request));
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Transform a target document based on a source.
|
|
1051
|
+
* @param request - translation request
|
|
1052
|
+
*/
|
|
1053
|
+
transform(request) {
|
|
1054
|
+
return rxjs.lastValueFrom(_transform(this.#client, this.#httpRequest, request));
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Translate a target document based on a source.
|
|
1058
|
+
* @param request - translation request
|
|
1059
|
+
*/
|
|
1060
|
+
translate(request) {
|
|
1061
|
+
return rxjs.lastValueFrom(_translate(this.#client, this.#httpRequest, request));
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
984
1064
|
class ObservableAssetsClient {
|
|
985
1065
|
#client;
|
|
986
1066
|
#httpRequest;
|
|
@@ -1401,11 +1481,20 @@ class ObservableSanityClient {
|
|
|
1401
1481
|
live;
|
|
1402
1482
|
projects;
|
|
1403
1483
|
users;
|
|
1484
|
+
agent;
|
|
1485
|
+
/**
|
|
1486
|
+
* Private properties
|
|
1487
|
+
*/
|
|
1404
1488
|
#clientConfig;
|
|
1405
1489
|
#httpRequest;
|
|
1490
|
+
/**
|
|
1491
|
+
* Instance properties
|
|
1492
|
+
*/
|
|
1406
1493
|
listen = _listen;
|
|
1407
1494
|
constructor(httpRequest, config = defaultConfig) {
|
|
1408
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest)
|
|
1495
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
|
|
1496
|
+
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
1497
|
+
};
|
|
1409
1498
|
}
|
|
1410
1499
|
/**
|
|
1411
1500
|
* Clone the client - returns a new instance
|
|
@@ -1544,15 +1633,24 @@ class SanityClient {
|
|
|
1544
1633
|
live;
|
|
1545
1634
|
projects;
|
|
1546
1635
|
users;
|
|
1636
|
+
agent;
|
|
1547
1637
|
/**
|
|
1548
1638
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1549
1639
|
*/
|
|
1550
1640
|
observable;
|
|
1641
|
+
/**
|
|
1642
|
+
* Private properties
|
|
1643
|
+
*/
|
|
1551
1644
|
#clientConfig;
|
|
1552
1645
|
#httpRequest;
|
|
1646
|
+
/**
|
|
1647
|
+
* Instance properties
|
|
1648
|
+
*/
|
|
1553
1649
|
listen = _listen;
|
|
1554
1650
|
constructor(httpRequest, config = defaultConfig) {
|
|
1555
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.
|
|
1651
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
|
|
1652
|
+
action: new AgentActionsClient(this, this.#httpRequest)
|
|
1653
|
+
}, this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1556
1654
|
}
|
|
1557
1655
|
/**
|
|
1558
1656
|
* Clone the client - returns a new instance
|
|
@@ -1646,8 +1744,8 @@ class SanityClient {
|
|
|
1646
1744
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1647
1745
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1648
1746
|
*/
|
|
1649
|
-
patch(
|
|
1650
|
-
return new Patch(
|
|
1747
|
+
patch(documentId, operations) {
|
|
1748
|
+
return new Patch(documentId, operations, this);
|
|
1651
1749
|
}
|
|
1652
1750
|
/**
|
|
1653
1751
|
* Create a new transaction of mutations
|