@sanity/client 7.0.1-canary.2 → 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 +1352 -1654
- package/dist/index.browser.d.ts +1352 -1654
- 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 +1352 -1654
- package/dist/index.d.ts +1352 -1654
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1375 -1677
- package/dist/stega.browser.d.ts +1375 -1677
- package/dist/stega.d.cts +1375 -1677
- package/dist/stega.d.ts +1375 -1677
- package/package.json +2 -1
- package/src/SanityClient.ts +34 -1102
- 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 -86
- package/src/data/dataMethods.ts +1 -1
- package/src/data/transaction.ts +1 -1
- package/src/datasets/DatasetsClient.ts +2 -64
- package/src/projects/ProjectsClient.ts +4 -46
- package/src/types.ts +30 -1
- package/src/users/UsersClient.ts +2 -24
- package/umd/sanityClient.js +102 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/index.cjs
CHANGED
|
@@ -823,6 +823,86 @@ const resourceDataBase = (config2) => {
|
|
|
823
823
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
824
824
|
}
|
|
825
825
|
};
|
|
826
|
+
function _generate(client, httpRequest, request) {
|
|
827
|
+
const dataset = config.hasDataset(client.config());
|
|
828
|
+
return _request(client, httpRequest, {
|
|
829
|
+
method: "POST",
|
|
830
|
+
uri: `/agent/action/generate/${dataset}`,
|
|
831
|
+
body: request
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
function _transform(client, httpRequest, request) {
|
|
835
|
+
const dataset = config.hasDataset(client.config());
|
|
836
|
+
return _request(client, httpRequest, {
|
|
837
|
+
method: "POST",
|
|
838
|
+
uri: `/agent/action/transform/${dataset}`,
|
|
839
|
+
body: request
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
function _translate(client, httpRequest, request) {
|
|
843
|
+
const dataset = config.hasDataset(client.config());
|
|
844
|
+
return _request(client, httpRequest, {
|
|
845
|
+
method: "POST",
|
|
846
|
+
uri: `/agent/action/translate/${dataset}`,
|
|
847
|
+
body: request
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
class ObservableAgentsActionClient {
|
|
851
|
+
#client;
|
|
852
|
+
#httpRequest;
|
|
853
|
+
constructor(client, httpRequest) {
|
|
854
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Run an instruction to generate content in a target document.
|
|
858
|
+
* @param request - instruction request
|
|
859
|
+
*/
|
|
860
|
+
generate(request) {
|
|
861
|
+
return _generate(this.#client, this.#httpRequest, request);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Transform a target document based on a source.
|
|
865
|
+
* @param request - translation request
|
|
866
|
+
*/
|
|
867
|
+
transform(request) {
|
|
868
|
+
return _transform(this.#client, this.#httpRequest, request);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Translate a target document based on a source.
|
|
872
|
+
* @param request - translation request
|
|
873
|
+
*/
|
|
874
|
+
translate(request) {
|
|
875
|
+
return _translate(this.#client, this.#httpRequest, request);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
class AgentActionsClient {
|
|
879
|
+
#client;
|
|
880
|
+
#httpRequest;
|
|
881
|
+
constructor(client, httpRequest) {
|
|
882
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Run an instruction to generate content in a target document.
|
|
886
|
+
* @param request - instruction request
|
|
887
|
+
*/
|
|
888
|
+
generate(request) {
|
|
889
|
+
return rxjs.lastValueFrom(_generate(this.#client, this.#httpRequest, request));
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Transform a target document based on a source.
|
|
893
|
+
* @param request - translation request
|
|
894
|
+
*/
|
|
895
|
+
transform(request) {
|
|
896
|
+
return rxjs.lastValueFrom(_transform(this.#client, this.#httpRequest, request));
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Translate a target document based on a source.
|
|
900
|
+
* @param request - translation request
|
|
901
|
+
*/
|
|
902
|
+
translate(request) {
|
|
903
|
+
return rxjs.lastValueFrom(_translate(this.#client, this.#httpRequest, request));
|
|
904
|
+
}
|
|
905
|
+
}
|
|
826
906
|
class ObservableAssetsClient {
|
|
827
907
|
#client;
|
|
828
908
|
#httpRequest;
|
|
@@ -1243,11 +1323,20 @@ class ObservableSanityClient {
|
|
|
1243
1323
|
live;
|
|
1244
1324
|
projects;
|
|
1245
1325
|
users;
|
|
1326
|
+
agent;
|
|
1327
|
+
/**
|
|
1328
|
+
* Private properties
|
|
1329
|
+
*/
|
|
1246
1330
|
#clientConfig;
|
|
1247
1331
|
#httpRequest;
|
|
1332
|
+
/**
|
|
1333
|
+
* Instance properties
|
|
1334
|
+
*/
|
|
1248
1335
|
listen = _listen;
|
|
1249
1336
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
1250
|
-
this.config(config$1), 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)
|
|
1337
|
+
this.config(config$1), 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 = {
|
|
1338
|
+
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
1339
|
+
};
|
|
1251
1340
|
}
|
|
1252
1341
|
/**
|
|
1253
1342
|
* Clone the client - returns a new instance
|
|
@@ -1386,15 +1475,24 @@ class SanityClient {
|
|
|
1386
1475
|
live;
|
|
1387
1476
|
projects;
|
|
1388
1477
|
users;
|
|
1478
|
+
agent;
|
|
1389
1479
|
/**
|
|
1390
1480
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1391
1481
|
*/
|
|
1392
1482
|
observable;
|
|
1483
|
+
/**
|
|
1484
|
+
* Private properties
|
|
1485
|
+
*/
|
|
1393
1486
|
#clientConfig;
|
|
1394
1487
|
#httpRequest;
|
|
1488
|
+
/**
|
|
1489
|
+
* Instance properties
|
|
1490
|
+
*/
|
|
1395
1491
|
listen = _listen;
|
|
1396
1492
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
1397
|
-
this.config(config$1), 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.
|
|
1493
|
+
this.config(config$1), 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 = {
|
|
1494
|
+
action: new AgentActionsClient(this, this.#httpRequest)
|
|
1495
|
+
}, this.observable = new ObservableSanityClient(httpRequest, config$1);
|
|
1398
1496
|
}
|
|
1399
1497
|
/**
|
|
1400
1498
|
* Clone the client - returns a new instance
|
|
@@ -1488,8 +1586,8 @@ class SanityClient {
|
|
|
1488
1586
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1489
1587
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1490
1588
|
*/
|
|
1491
|
-
patch(
|
|
1492
|
-
return new Patch(
|
|
1589
|
+
patch(documentId, operations) {
|
|
1590
|
+
return new Patch(documentId, operations, this);
|
|
1493
1591
|
}
|
|
1494
1592
|
/**
|
|
1495
1593
|
* Create a new transaction of mutations
|
|
@@ -1570,7 +1668,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1570
1668
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
1571
1669
|
};
|
|
1572
1670
|
}
|
|
1573
|
-
var name = "@sanity/client", version = "7.
|
|
1671
|
+
var name = "@sanity/client", version = "7.1.0";
|
|
1574
1672
|
const middleware = [
|
|
1575
1673
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1576
1674
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|