@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.js
CHANGED
|
@@ -806,6 +806,86 @@ const resourceDataBase = (config) => {
|
|
|
806
806
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
+
function _generate(client, httpRequest, request) {
|
|
810
|
+
const dataset2 = hasDataset(client.config());
|
|
811
|
+
return _request(client, httpRequest, {
|
|
812
|
+
method: "POST",
|
|
813
|
+
uri: `/agent/action/generate/${dataset2}`,
|
|
814
|
+
body: request
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
function _transform(client, httpRequest, request) {
|
|
818
|
+
const dataset2 = hasDataset(client.config());
|
|
819
|
+
return _request(client, httpRequest, {
|
|
820
|
+
method: "POST",
|
|
821
|
+
uri: `/agent/action/transform/${dataset2}`,
|
|
822
|
+
body: request
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function _translate(client, httpRequest, request) {
|
|
826
|
+
const dataset2 = hasDataset(client.config());
|
|
827
|
+
return _request(client, httpRequest, {
|
|
828
|
+
method: "POST",
|
|
829
|
+
uri: `/agent/action/translate/${dataset2}`,
|
|
830
|
+
body: request
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
class ObservableAgentsActionClient {
|
|
834
|
+
#client;
|
|
835
|
+
#httpRequest;
|
|
836
|
+
constructor(client, httpRequest) {
|
|
837
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Run an instruction to generate content in a target document.
|
|
841
|
+
* @param request - instruction request
|
|
842
|
+
*/
|
|
843
|
+
generate(request) {
|
|
844
|
+
return _generate(this.#client, this.#httpRequest, request);
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Transform a target document based on a source.
|
|
848
|
+
* @param request - translation request
|
|
849
|
+
*/
|
|
850
|
+
transform(request) {
|
|
851
|
+
return _transform(this.#client, this.#httpRequest, request);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Translate a target document based on a source.
|
|
855
|
+
* @param request - translation request
|
|
856
|
+
*/
|
|
857
|
+
translate(request) {
|
|
858
|
+
return _translate(this.#client, this.#httpRequest, request);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
class AgentActionsClient {
|
|
862
|
+
#client;
|
|
863
|
+
#httpRequest;
|
|
864
|
+
constructor(client, httpRequest) {
|
|
865
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Run an instruction to generate content in a target document.
|
|
869
|
+
* @param request - instruction request
|
|
870
|
+
*/
|
|
871
|
+
generate(request) {
|
|
872
|
+
return lastValueFrom(_generate(this.#client, this.#httpRequest, request));
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Transform a target document based on a source.
|
|
876
|
+
* @param request - translation request
|
|
877
|
+
*/
|
|
878
|
+
transform(request) {
|
|
879
|
+
return lastValueFrom(_transform(this.#client, this.#httpRequest, request));
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Translate a target document based on a source.
|
|
883
|
+
* @param request - translation request
|
|
884
|
+
*/
|
|
885
|
+
translate(request) {
|
|
886
|
+
return lastValueFrom(_translate(this.#client, this.#httpRequest, request));
|
|
887
|
+
}
|
|
888
|
+
}
|
|
809
889
|
class ObservableAssetsClient {
|
|
810
890
|
#client;
|
|
811
891
|
#httpRequest;
|
|
@@ -1226,11 +1306,20 @@ class ObservableSanityClient {
|
|
|
1226
1306
|
live;
|
|
1227
1307
|
projects;
|
|
1228
1308
|
users;
|
|
1309
|
+
agent;
|
|
1310
|
+
/**
|
|
1311
|
+
* Private properties
|
|
1312
|
+
*/
|
|
1229
1313
|
#clientConfig;
|
|
1230
1314
|
#httpRequest;
|
|
1315
|
+
/**
|
|
1316
|
+
* Instance properties
|
|
1317
|
+
*/
|
|
1231
1318
|
listen = _listen;
|
|
1232
1319
|
constructor(httpRequest, config = defaultConfig) {
|
|
1233
|
-
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)
|
|
1320
|
+
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 = {
|
|
1321
|
+
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
1322
|
+
};
|
|
1234
1323
|
}
|
|
1235
1324
|
/**
|
|
1236
1325
|
* Clone the client - returns a new instance
|
|
@@ -1369,15 +1458,24 @@ class SanityClient {
|
|
|
1369
1458
|
live;
|
|
1370
1459
|
projects;
|
|
1371
1460
|
users;
|
|
1461
|
+
agent;
|
|
1372
1462
|
/**
|
|
1373
1463
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1374
1464
|
*/
|
|
1375
1465
|
observable;
|
|
1466
|
+
/**
|
|
1467
|
+
* Private properties
|
|
1468
|
+
*/
|
|
1376
1469
|
#clientConfig;
|
|
1377
1470
|
#httpRequest;
|
|
1471
|
+
/**
|
|
1472
|
+
* Instance properties
|
|
1473
|
+
*/
|
|
1378
1474
|
listen = _listen;
|
|
1379
1475
|
constructor(httpRequest, config = defaultConfig) {
|
|
1380
|
-
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.
|
|
1476
|
+
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 = {
|
|
1477
|
+
action: new AgentActionsClient(this, this.#httpRequest)
|
|
1478
|
+
}, this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1381
1479
|
}
|
|
1382
1480
|
/**
|
|
1383
1481
|
* Clone the client - returns a new instance
|
|
@@ -1471,8 +1569,8 @@ class SanityClient {
|
|
|
1471
1569
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1472
1570
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1473
1571
|
*/
|
|
1474
|
-
patch(
|
|
1475
|
-
return new Patch(
|
|
1572
|
+
patch(documentId, operations) {
|
|
1573
|
+
return new Patch(documentId, operations, this);
|
|
1476
1574
|
}
|
|
1477
1575
|
/**
|
|
1478
1576
|
* Create a new transaction of mutations
|
|
@@ -1553,7 +1651,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1553
1651
|
return printNoDefaultExport(), createClient2(config);
|
|
1554
1652
|
};
|
|
1555
1653
|
}
|
|
1556
|
-
var name = "@sanity/client", version = "7.
|
|
1654
|
+
var name = "@sanity/client", version = "7.1.0";
|
|
1557
1655
|
const middleware = [
|
|
1558
1656
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1559
1657
|
headers({ "User-Agent": `${name} ${version}` }),
|