@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.js
CHANGED
|
@@ -963,6 +963,86 @@ const resourceDataBase = (config) => {
|
|
|
963
963
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
964
964
|
}
|
|
965
965
|
};
|
|
966
|
+
function _generate(client, httpRequest, request) {
|
|
967
|
+
const dataset2 = hasDataset(client.config());
|
|
968
|
+
return _request(client, httpRequest, {
|
|
969
|
+
method: "POST",
|
|
970
|
+
uri: `/agent/action/generate/${dataset2}`,
|
|
971
|
+
body: request
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
function _transform(client, httpRequest, request) {
|
|
975
|
+
const dataset2 = hasDataset(client.config());
|
|
976
|
+
return _request(client, httpRequest, {
|
|
977
|
+
method: "POST",
|
|
978
|
+
uri: `/agent/action/transform/${dataset2}`,
|
|
979
|
+
body: request
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
function _translate(client, httpRequest, request) {
|
|
983
|
+
const dataset2 = hasDataset(client.config());
|
|
984
|
+
return _request(client, httpRequest, {
|
|
985
|
+
method: "POST",
|
|
986
|
+
uri: `/agent/action/translate/${dataset2}`,
|
|
987
|
+
body: request
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
class ObservableAgentsActionClient {
|
|
991
|
+
#client;
|
|
992
|
+
#httpRequest;
|
|
993
|
+
constructor(client, httpRequest) {
|
|
994
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Run an instruction to generate content in a target document.
|
|
998
|
+
* @param request - instruction request
|
|
999
|
+
*/
|
|
1000
|
+
generate(request) {
|
|
1001
|
+
return _generate(this.#client, this.#httpRequest, request);
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Transform a target document based on a source.
|
|
1005
|
+
* @param request - translation request
|
|
1006
|
+
*/
|
|
1007
|
+
transform(request) {
|
|
1008
|
+
return _transform(this.#client, this.#httpRequest, request);
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Translate a target document based on a source.
|
|
1012
|
+
* @param request - translation request
|
|
1013
|
+
*/
|
|
1014
|
+
translate(request) {
|
|
1015
|
+
return _translate(this.#client, this.#httpRequest, request);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
class AgentActionsClient {
|
|
1019
|
+
#client;
|
|
1020
|
+
#httpRequest;
|
|
1021
|
+
constructor(client, httpRequest) {
|
|
1022
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Run an instruction to generate content in a target document.
|
|
1026
|
+
* @param request - instruction request
|
|
1027
|
+
*/
|
|
1028
|
+
generate(request) {
|
|
1029
|
+
return lastValueFrom(_generate(this.#client, this.#httpRequest, request));
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Transform a target document based on a source.
|
|
1033
|
+
* @param request - translation request
|
|
1034
|
+
*/
|
|
1035
|
+
transform(request) {
|
|
1036
|
+
return lastValueFrom(_transform(this.#client, this.#httpRequest, request));
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Translate a target document based on a source.
|
|
1040
|
+
* @param request - translation request
|
|
1041
|
+
*/
|
|
1042
|
+
translate(request) {
|
|
1043
|
+
return lastValueFrom(_translate(this.#client, this.#httpRequest, request));
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
966
1046
|
class ObservableAssetsClient {
|
|
967
1047
|
#client;
|
|
968
1048
|
#httpRequest;
|
|
@@ -1383,11 +1463,20 @@ class ObservableSanityClient {
|
|
|
1383
1463
|
live;
|
|
1384
1464
|
projects;
|
|
1385
1465
|
users;
|
|
1466
|
+
agent;
|
|
1467
|
+
/**
|
|
1468
|
+
* Private properties
|
|
1469
|
+
*/
|
|
1386
1470
|
#clientConfig;
|
|
1387
1471
|
#httpRequest;
|
|
1472
|
+
/**
|
|
1473
|
+
* Instance properties
|
|
1474
|
+
*/
|
|
1388
1475
|
listen = _listen;
|
|
1389
1476
|
constructor(httpRequest, config = defaultConfig) {
|
|
1390
|
-
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)
|
|
1477
|
+
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 = {
|
|
1478
|
+
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
1479
|
+
};
|
|
1391
1480
|
}
|
|
1392
1481
|
/**
|
|
1393
1482
|
* Clone the client - returns a new instance
|
|
@@ -1526,15 +1615,24 @@ class SanityClient {
|
|
|
1526
1615
|
live;
|
|
1527
1616
|
projects;
|
|
1528
1617
|
users;
|
|
1618
|
+
agent;
|
|
1529
1619
|
/**
|
|
1530
1620
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1531
1621
|
*/
|
|
1532
1622
|
observable;
|
|
1623
|
+
/**
|
|
1624
|
+
* Private properties
|
|
1625
|
+
*/
|
|
1533
1626
|
#clientConfig;
|
|
1534
1627
|
#httpRequest;
|
|
1628
|
+
/**
|
|
1629
|
+
* Instance properties
|
|
1630
|
+
*/
|
|
1535
1631
|
listen = _listen;
|
|
1536
1632
|
constructor(httpRequest, config = defaultConfig) {
|
|
1537
|
-
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.
|
|
1633
|
+
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 = {
|
|
1634
|
+
action: new AgentActionsClient(this, this.#httpRequest)
|
|
1635
|
+
}, this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1538
1636
|
}
|
|
1539
1637
|
/**
|
|
1540
1638
|
* Clone the client - returns a new instance
|
|
@@ -1628,8 +1726,8 @@ class SanityClient {
|
|
|
1628
1726
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1629
1727
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1630
1728
|
*/
|
|
1631
|
-
patch(
|
|
1632
|
-
return new Patch(
|
|
1729
|
+
patch(documentId, operations) {
|
|
1730
|
+
return new Patch(documentId, operations, this);
|
|
1633
1731
|
}
|
|
1634
1732
|
/**
|
|
1635
1733
|
* Create a new transaction of mutations
|