@sanity/client 8.1.0 → 8.2.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 +171 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +408 -61
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +650 -2
- package/dist/index.node.js +379 -19
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/{types-BODIEY7F.d.ts → types-nJhm5Nyq.d.ts} +651 -3
- package/package.json +1 -1
- package/src/SanityClient.ts +20 -0
- package/src/collaboration/CollaborationCommentsClient.ts +387 -0
- package/src/collaboration/comments.ts +313 -0
- package/src/collaboration/types.ts +252 -0
- package/src/data/dataMethods.ts +7 -1
- package/src/data/listen.ts +20 -5
- package/src/types.ts +234 -0
package/dist/index.node.js
CHANGED
|
@@ -726,7 +726,7 @@ function _fetchRequest(_stega, _params, options) {
|
|
|
726
726
|
}
|
|
727
727
|
/** @internal */
|
|
728
728
|
function _fetchObservable(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
729
|
-
return _observe(options.signal, (signal) => _fetch(client, httpRequest, _stega, query, _params, {
|
|
729
|
+
return _observe(options.signal, (signal) => _fetch$1(client, httpRequest, _stega, query, _params, {
|
|
730
730
|
...options,
|
|
731
731
|
signal
|
|
732
732
|
}));
|
|
@@ -736,7 +736,7 @@ function _fetchObservable(client, httpRequest, _stega, query, _params = {}, opti
|
|
|
736
736
|
*
|
|
737
737
|
* @internal
|
|
738
738
|
*/
|
|
739
|
-
function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
739
|
+
function _fetch$1(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
740
740
|
let { stega, params, mapResponse, reqOpts } = _fetchRequest(_stega, _params, options), request = _dataRequest(client, httpRequest, "query", {
|
|
741
741
|
query,
|
|
742
742
|
params
|
|
@@ -889,7 +889,7 @@ function _createVersionFromBaseObservable(client, httpRequest, publishedId, base
|
|
|
889
889
|
}
|
|
890
890
|
/** @internal */
|
|
891
891
|
function _deleteObservable(client, httpRequest, selection, options) {
|
|
892
|
-
return _observe(options?.signal, (signal) => _delete(client, httpRequest, selection, {
|
|
892
|
+
return _observe(options?.signal, (signal) => _delete$1(client, httpRequest, selection, {
|
|
893
893
|
...options,
|
|
894
894
|
signal
|
|
895
895
|
}));
|
|
@@ -994,7 +994,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
994
994
|
* @internal
|
|
995
995
|
*/
|
|
996
996
|
function _createObservable(client, httpRequest, doc, op, options = {}) {
|
|
997
|
-
return _observe(options.signal, (signal) => _create(client, httpRequest, doc, op, {
|
|
997
|
+
return _observe(options.signal, (signal) => _create$1(client, httpRequest, doc, op, {
|
|
998
998
|
...options,
|
|
999
999
|
signal
|
|
1000
1000
|
}));
|
|
@@ -1004,7 +1004,7 @@ function _createObservable(client, httpRequest, doc, op, options = {}) {
|
|
|
1004
1004
|
*
|
|
1005
1005
|
* @internal
|
|
1006
1006
|
*/
|
|
1007
|
-
function _create(client, httpRequest, doc, op, options = {}) {
|
|
1007
|
+
function _create$1(client, httpRequest, doc, op, options = {}) {
|
|
1008
1008
|
let mutation = { [op]: doc }, opts = Object.assign({
|
|
1009
1009
|
returnFirst: !0,
|
|
1010
1010
|
returnDocuments: !0
|
|
@@ -1041,7 +1041,7 @@ function _mutate(client, httpRequest, mutations, options) {
|
|
|
1041
1041
|
*
|
|
1042
1042
|
* @internal
|
|
1043
1043
|
*/
|
|
1044
|
-
function _delete(client, httpRequest, selection, options) {
|
|
1044
|
+
function _delete$1(client, httpRequest, selection, options) {
|
|
1045
1045
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [{ delete: getSelection(selection) }] }, options);
|
|
1046
1046
|
}
|
|
1047
1047
|
/**
|
|
@@ -1050,7 +1050,7 @@ function _delete(client, httpRequest, selection, options) {
|
|
|
1050
1050
|
* @internal
|
|
1051
1051
|
*/
|
|
1052
1052
|
function _createIfNotExists(client, httpRequest, doc, options) {
|
|
1053
|
-
return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
|
|
1053
|
+
return requireDocumentId("createIfNotExists", doc), _create$1(client, httpRequest, doc, "createIfNotExists", options);
|
|
1054
1054
|
}
|
|
1055
1055
|
/**
|
|
1056
1056
|
* Promise-based sibling of {@link _createOrReplaceObservable}.
|
|
@@ -1058,7 +1058,7 @@ function _createIfNotExists(client, httpRequest, doc, options) {
|
|
|
1058
1058
|
* @internal
|
|
1059
1059
|
*/
|
|
1060
1060
|
function _createOrReplace(client, httpRequest, doc, options) {
|
|
1061
|
-
return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
|
|
1061
|
+
return requireDocumentId("createOrReplace", doc), _create$1(client, httpRequest, doc, "createOrReplace", options);
|
|
1062
1062
|
}
|
|
1063
1063
|
/**
|
|
1064
1064
|
* Promise-based sibling of {@link _createVersionObservable}.
|
|
@@ -1589,6 +1589,7 @@ function resolveEventSourceFetch(config, options = {}) {
|
|
|
1589
1589
|
function pickBaseFetch(config) {
|
|
1590
1590
|
return config.resolveFetch ? config.resolveFetch(typeof config.proxy == "string" ? config.proxy : void 0) : globalThis.fetch.bind(globalThis);
|
|
1591
1591
|
}
|
|
1592
|
+
/** @internal */
|
|
1592
1593
|
const possibleOptions = [
|
|
1593
1594
|
"includePreviousRevision",
|
|
1594
1595
|
"includeResult",
|
|
@@ -1600,8 +1601,8 @@ const possibleOptions = [
|
|
|
1600
1601
|
"tag"
|
|
1601
1602
|
], defaultOptions = { includeResult: !0 };
|
|
1602
1603
|
/** @public */
|
|
1603
|
-
function _listen(query, params, opts = {}) {
|
|
1604
|
-
let
|
|
1604
|
+
function _listen$1(query, params, opts = {}) {
|
|
1605
|
+
let { url, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = {
|
|
1605
1606
|
...defaults_default(opts, defaultOptions),
|
|
1606
1607
|
tag
|
|
1607
1608
|
}, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({
|
|
@@ -1613,7 +1614,12 @@ function _listen(query, params, opts = {}) {
|
|
|
1613
1614
|
}
|
|
1614
1615
|
}), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
|
|
1615
1616
|
if (uri.length > 14800) return throwError(() => /* @__PURE__ */ Error("Query too large for listener"));
|
|
1616
|
-
let listenFor = options.events ? options.events : ["mutation"]
|
|
1617
|
+
let listenFor = options.events ? options.events : ["mutation"];
|
|
1618
|
+
return _connectListenEventSource(this, uri, listenFor);
|
|
1619
|
+
}
|
|
1620
|
+
/** @internal */
|
|
1621
|
+
function _connectListenEventSource(client, uri, listenFor) {
|
|
1622
|
+
let config = client.config(), { token, withCredentials, headers: configHeaders } = config, headers = {};
|
|
1617
1623
|
token && (headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(headers, configHeaders);
|
|
1618
1624
|
let initEventSource = () => new EventSource(uri, { fetch: resolveEventSourceFetch(config, {
|
|
1619
1625
|
headers: Object.keys(headers).length ? headers : void 0,
|
|
@@ -1624,6 +1630,358 @@ function _listen(query, params, opts = {}) {
|
|
|
1624
1630
|
..."data" in event ? event.data : {}
|
|
1625
1631
|
})));
|
|
1626
1632
|
}
|
|
1633
|
+
/** @internal */
|
|
1634
|
+
const possibleRequestOptions = [
|
|
1635
|
+
"headers",
|
|
1636
|
+
"signal",
|
|
1637
|
+
"tag",
|
|
1638
|
+
"timeout",
|
|
1639
|
+
"token"
|
|
1640
|
+
];
|
|
1641
|
+
function commentUrl(id) {
|
|
1642
|
+
if (!id) throw Error("Comment ID must be provided");
|
|
1643
|
+
return `/collaboration/comments/${encodeURIComponent(id)}`;
|
|
1644
|
+
}
|
|
1645
|
+
function resolveCommentResource(client) {
|
|
1646
|
+
let { resource, projectId, dataset } = client.config();
|
|
1647
|
+
if (resource) return resource;
|
|
1648
|
+
if (projectId && dataset) return {
|
|
1649
|
+
type: "dataset",
|
|
1650
|
+
id: `${projectId}.${dataset}`
|
|
1651
|
+
};
|
|
1652
|
+
throw Error("`resource` or `projectId` and `dataset` must be configured to use collaboration comments");
|
|
1653
|
+
}
|
|
1654
|
+
function resourceQuery(client) {
|
|
1655
|
+
let { collaboration } = client.config(), organizationId = collaboration?.organizationId;
|
|
1656
|
+
if (!organizationId) throw Error("`collaboration.organizationId` must be configured to use collaboration comments");
|
|
1657
|
+
let resource = resolveCommentResource(client);
|
|
1658
|
+
return {
|
|
1659
|
+
organizationId,
|
|
1660
|
+
resourceId: resource.id,
|
|
1661
|
+
resourceType: resource.type
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
/** @internal */
|
|
1665
|
+
function _getTargetDocumentRef(client, documentId) {
|
|
1666
|
+
if (!documentId) throw Error("Document ID must be provided");
|
|
1667
|
+
let resource = resolveCommentResource(client);
|
|
1668
|
+
return `${resource.type}:${resource.id}:${getPublishedId(documentId)}`;
|
|
1669
|
+
}
|
|
1670
|
+
function write(client, httpRequest, method, url, body, options = {}) {
|
|
1671
|
+
return _requestObservable(client, httpRequest, {
|
|
1672
|
+
method,
|
|
1673
|
+
url,
|
|
1674
|
+
body,
|
|
1675
|
+
query: {
|
|
1676
|
+
...resourceQuery(client),
|
|
1677
|
+
...options.transactionId ? { transactionId: options.transactionId } : {}
|
|
1678
|
+
},
|
|
1679
|
+
...pick(options, possibleRequestOptions)
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
/**
|
|
1683
|
+
* `commentId` picks the written comment out of the results: a status update
|
|
1684
|
+
* cascades to the comment's replies, and the API leaves the results unordered.
|
|
1685
|
+
* Creates pass the requested `_id`, which is undefined when the API assigns
|
|
1686
|
+
* one, and always come back with a single result.
|
|
1687
|
+
*/
|
|
1688
|
+
function writeDocument(commentId, ...args) {
|
|
1689
|
+
return write(...args).pipe(map$1(({ results }) => {
|
|
1690
|
+
let result = commentId ? results.find(({ id }) => id === commentId) : results[0];
|
|
1691
|
+
if (!result?.document) throw Error("Comment write did not return a comment document");
|
|
1692
|
+
return result.document;
|
|
1693
|
+
}));
|
|
1694
|
+
}
|
|
1695
|
+
function writeMutationResult(...args) {
|
|
1696
|
+
return write(...args).pipe(map$1(({ transactionId, results }) => ({
|
|
1697
|
+
transactionId,
|
|
1698
|
+
documentIds: results.map((result) => result.id),
|
|
1699
|
+
results
|
|
1700
|
+
})));
|
|
1701
|
+
}
|
|
1702
|
+
/** @internal */
|
|
1703
|
+
function _create(client, httpRequest, body, options) {
|
|
1704
|
+
return writeDocument(body._id, client, httpRequest, "POST", "/collaboration/comments", body, options);
|
|
1705
|
+
}
|
|
1706
|
+
/** @internal */
|
|
1707
|
+
function _update(client, httpRequest, id, body, options) {
|
|
1708
|
+
return writeDocument(id, client, httpRequest, "PATCH", commentUrl(id), body, options);
|
|
1709
|
+
}
|
|
1710
|
+
/** @internal */
|
|
1711
|
+
function _delete(client, httpRequest, id, options) {
|
|
1712
|
+
return writeMutationResult(client, httpRequest, "DELETE", commentUrl(id), void 0, options);
|
|
1713
|
+
}
|
|
1714
|
+
/** @internal */
|
|
1715
|
+
function _addReaction(client, httpRequest, id, shortName, options) {
|
|
1716
|
+
return writeDocument(id, client, httpRequest, "POST", `${commentUrl(id)}/reactions`, { shortName }, options);
|
|
1717
|
+
}
|
|
1718
|
+
/** @internal */
|
|
1719
|
+
function _removeReaction(client, httpRequest, id, shortName, options) {
|
|
1720
|
+
return writeDocument(id, client, httpRequest, "DELETE", `${commentUrl(id)}/reactions/${encodeURIComponent(shortName)}`, void 0, options);
|
|
1721
|
+
}
|
|
1722
|
+
/** @internal */
|
|
1723
|
+
function _fetch(client, httpRequest, query, params, options) {
|
|
1724
|
+
let search = resourceQuery(client);
|
|
1725
|
+
return _requestObservable(client, httpRequest, {
|
|
1726
|
+
...encodeQueryString({
|
|
1727
|
+
query,
|
|
1728
|
+
params
|
|
1729
|
+
}).length < 11264 ? {
|
|
1730
|
+
method: "GET",
|
|
1731
|
+
url: `/collaboration/comments/query${encodeQueryString({
|
|
1732
|
+
query,
|
|
1733
|
+
params,
|
|
1734
|
+
options: search
|
|
1735
|
+
})}`
|
|
1736
|
+
} : {
|
|
1737
|
+
method: "POST",
|
|
1738
|
+
url: "/collaboration/comments/query",
|
|
1739
|
+
query: search,
|
|
1740
|
+
body: {
|
|
1741
|
+
query,
|
|
1742
|
+
params: params ?? {}
|
|
1743
|
+
}
|
|
1744
|
+
},
|
|
1745
|
+
...pick(options || {}, possibleRequestOptions)
|
|
1746
|
+
}).pipe(map$1((response) => response.result));
|
|
1747
|
+
}
|
|
1748
|
+
/** @internal */
|
|
1749
|
+
function _listen(client, query, params, options) {
|
|
1750
|
+
let opts = options ?? {}, { requestTagPrefix } = client.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, listenOpts = pick({
|
|
1751
|
+
...defaults_default(opts, defaultOptions),
|
|
1752
|
+
tag
|
|
1753
|
+
}, possibleOptions), qs = encodeQueryString({
|
|
1754
|
+
query,
|
|
1755
|
+
params,
|
|
1756
|
+
options: {
|
|
1757
|
+
...listenOpts,
|
|
1758
|
+
...resourceQuery(client)
|
|
1759
|
+
}
|
|
1760
|
+
}), uri = `${client.getUrl("/collaboration/comments/listen")}${qs}`;
|
|
1761
|
+
return uri.length > 14800 ? throwError(() => /* @__PURE__ */ Error("Query too large for listener")) : _connectListenEventSource(client, uri, opts.events ? opts.events : ["mutation"]);
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Comments on the configured organization resource.
|
|
1765
|
+
*
|
|
1766
|
+
* Requires `collaboration.organizationId`, plus either `resource` or `projectId` and `dataset`.
|
|
1767
|
+
*
|
|
1768
|
+
* @alpha
|
|
1769
|
+
*/
|
|
1770
|
+
var ObservableCollaborationCommentsClient = class {
|
|
1771
|
+
#client;
|
|
1772
|
+
#httpRequest;
|
|
1773
|
+
constructor(client, httpRequest) {
|
|
1774
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Create a comment or reply on the configured resource.
|
|
1778
|
+
*
|
|
1779
|
+
* A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
|
|
1780
|
+
* Replies inherit `target`, `status`, and `threadId` from the parent comment.
|
|
1781
|
+
*
|
|
1782
|
+
* @param body - Comment to create
|
|
1783
|
+
* @param options - Optional request options
|
|
1784
|
+
* @returns The created comment
|
|
1785
|
+
*/
|
|
1786
|
+
create(body, options) {
|
|
1787
|
+
return _create(this.#client, this.#httpRequest, body, options);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Update an existing comment.
|
|
1791
|
+
*
|
|
1792
|
+
* Updating `status` cascades to the comment's replies.
|
|
1793
|
+
*
|
|
1794
|
+
* @param id - Comment document ID
|
|
1795
|
+
* @param body - Fields to update
|
|
1796
|
+
* @param options - Optional request options
|
|
1797
|
+
* @returns The updated comment
|
|
1798
|
+
*/
|
|
1799
|
+
update(id, body, options) {
|
|
1800
|
+
return _update(this.#client, this.#httpRequest, id, body, options);
|
|
1801
|
+
}
|
|
1802
|
+
/**
|
|
1803
|
+
* Delete a comment and its replies.
|
|
1804
|
+
*
|
|
1805
|
+
* @param id - Comment document ID
|
|
1806
|
+
* @param options - Optional request options
|
|
1807
|
+
* @returns Mutation result, where `documentIds` covers the comment and every deleted reply
|
|
1808
|
+
*/
|
|
1809
|
+
delete(id, options) {
|
|
1810
|
+
return _delete(this.#client, this.#httpRequest, id, options);
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Add the current user's reaction to a comment.
|
|
1814
|
+
*
|
|
1815
|
+
* @param id - Comment document ID
|
|
1816
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1817
|
+
* @param options - Optional request options
|
|
1818
|
+
* @returns The comment, with the reaction applied
|
|
1819
|
+
*/
|
|
1820
|
+
addReaction(id, shortName, options) {
|
|
1821
|
+
return _addReaction(this.#client, this.#httpRequest, id, shortName, options);
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Remove the current user's reaction from a comment.
|
|
1825
|
+
*
|
|
1826
|
+
* @param id - Comment document ID
|
|
1827
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1828
|
+
* @param options - Optional request options
|
|
1829
|
+
* @returns The comment, with the reaction removed
|
|
1830
|
+
*/
|
|
1831
|
+
removeReaction(id, shortName, options) {
|
|
1832
|
+
return _removeReaction(this.#client, this.#httpRequest, id, shortName, options);
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Build the global document reference used by `target.document._ref`, for use in
|
|
1836
|
+
* queries and listeners.
|
|
1837
|
+
*
|
|
1838
|
+
* The reference is built from the configured `resource` and the published ID of
|
|
1839
|
+
* the given document ID, since comment references always use published IDs.
|
|
1840
|
+
*
|
|
1841
|
+
* @example
|
|
1842
|
+
* ```ts
|
|
1843
|
+
* client.collaboration.comments.listen(
|
|
1844
|
+
* '*[_type == "sanity.comment" && target.document._ref == $ref]',
|
|
1845
|
+
* {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
|
|
1846
|
+
* )
|
|
1847
|
+
* ```
|
|
1848
|
+
*
|
|
1849
|
+
* @param documentId - Document ID, in published, draft or version form
|
|
1850
|
+
* @returns Global document reference, of the form `resourceType:resourceId:documentId`
|
|
1851
|
+
*/
|
|
1852
|
+
getTargetDocumentRef(documentId) {
|
|
1853
|
+
return _getTargetDocumentRef(this.#client, documentId);
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Fetch comments on the configured resource.
|
|
1857
|
+
*
|
|
1858
|
+
* Takes the same `query` and `params` as `client.fetch`, and switches from a
|
|
1859
|
+
* GET to a POST for queries too large for the request URL in the same way,
|
|
1860
|
+
* but queries the comments endpoint, which accepts none of the query options
|
|
1861
|
+
* `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
|
|
1862
|
+
* `resultSourceMap`, stega).
|
|
1863
|
+
*
|
|
1864
|
+
* The query runs against the organization store, which is not scoped to
|
|
1865
|
+
* comments, so filter on `_type == "sanity.comment"`.
|
|
1866
|
+
*
|
|
1867
|
+
* @param query - GROQ-query to perform
|
|
1868
|
+
* @param params - Optional query parameters
|
|
1869
|
+
* @param options - Optional request options
|
|
1870
|
+
*/
|
|
1871
|
+
fetch(query, params, options) {
|
|
1872
|
+
return _fetch(this.#client, this.#httpRequest, query, params, options);
|
|
1873
|
+
}
|
|
1874
|
+
listen(query, params, options) {
|
|
1875
|
+
return _listen(this.#client, query, params, options);
|
|
1876
|
+
}
|
|
1877
|
+
}, CollaborationCommentsClient = class {
|
|
1878
|
+
#client;
|
|
1879
|
+
#httpRequest;
|
|
1880
|
+
constructor(client, httpRequest) {
|
|
1881
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* Create a comment or reply on the configured resource.
|
|
1885
|
+
*
|
|
1886
|
+
* A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
|
|
1887
|
+
* Replies inherit `target`, `status`, and `threadId` from the parent comment.
|
|
1888
|
+
*
|
|
1889
|
+
* @param body - Comment to create
|
|
1890
|
+
* @param options - Optional request options
|
|
1891
|
+
* @returns The created comment
|
|
1892
|
+
*/
|
|
1893
|
+
create(body, options) {
|
|
1894
|
+
return lastValueFrom(_create(this.#client, this.#httpRequest, body, options));
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Update an existing comment.
|
|
1898
|
+
*
|
|
1899
|
+
* Updating `status` cascades to the comment's replies.
|
|
1900
|
+
*
|
|
1901
|
+
* @param id - Comment document ID
|
|
1902
|
+
* @param body - Fields to update
|
|
1903
|
+
* @param options - Optional request options
|
|
1904
|
+
* @returns The updated comment
|
|
1905
|
+
*/
|
|
1906
|
+
update(id, body, options) {
|
|
1907
|
+
return lastValueFrom(_update(this.#client, this.#httpRequest, id, body, options));
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Delete a comment and its replies.
|
|
1911
|
+
*
|
|
1912
|
+
* @param id - Comment document ID
|
|
1913
|
+
* @param options - Optional request options
|
|
1914
|
+
* @returns Mutation result, where `documentIds` covers the comment and every deleted reply
|
|
1915
|
+
*/
|
|
1916
|
+
delete(id, options) {
|
|
1917
|
+
return lastValueFrom(_delete(this.#client, this.#httpRequest, id, options));
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Add the current user's reaction to a comment.
|
|
1921
|
+
*
|
|
1922
|
+
* @param id - Comment document ID
|
|
1923
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1924
|
+
* @param options - Optional request options
|
|
1925
|
+
* @returns The comment, with the reaction applied
|
|
1926
|
+
*/
|
|
1927
|
+
addReaction(id, shortName, options) {
|
|
1928
|
+
return lastValueFrom(_addReaction(this.#client, this.#httpRequest, id, shortName, options));
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Remove the current user's reaction from a comment.
|
|
1932
|
+
*
|
|
1933
|
+
* @param id - Comment document ID
|
|
1934
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1935
|
+
* @param options - Optional request options
|
|
1936
|
+
* @returns The comment, with the reaction removed
|
|
1937
|
+
*/
|
|
1938
|
+
removeReaction(id, shortName, options) {
|
|
1939
|
+
return lastValueFrom(_removeReaction(this.#client, this.#httpRequest, id, shortName, options));
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Build the global document reference used by `target.document._ref`, for use in
|
|
1943
|
+
* queries and listeners.
|
|
1944
|
+
*
|
|
1945
|
+
* The reference is built from the configured `resource` and the published ID of
|
|
1946
|
+
* the given document ID, since comment references always use published IDs.
|
|
1947
|
+
*
|
|
1948
|
+
* @example
|
|
1949
|
+
* ```ts
|
|
1950
|
+
* const comments = await client.collaboration.comments.fetch(
|
|
1951
|
+
* '*[_type == "sanity.comment" && target.document._ref == $ref]',
|
|
1952
|
+
* {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
|
|
1953
|
+
* )
|
|
1954
|
+
* ```
|
|
1955
|
+
*
|
|
1956
|
+
* @param documentId - Document ID, in published, draft or version form
|
|
1957
|
+
* @returns Global document reference, of the form `resourceType:resourceId:documentId`
|
|
1958
|
+
*/
|
|
1959
|
+
getTargetDocumentRef(documentId) {
|
|
1960
|
+
return _getTargetDocumentRef(this.#client, documentId);
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Fetch comments on the configured resource.
|
|
1964
|
+
*
|
|
1965
|
+
* Takes the same `query` and `params` as `client.fetch`, and switches from a
|
|
1966
|
+
* GET to a POST for queries too large for the request URL in the same way,
|
|
1967
|
+
* but queries the comments endpoint, which accepts none of the query options
|
|
1968
|
+
* `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
|
|
1969
|
+
* `resultSourceMap`, stega).
|
|
1970
|
+
*
|
|
1971
|
+
* The query runs against the organization store, which is not scoped to
|
|
1972
|
+
* comments, so filter on `_type == "sanity.comment"`.
|
|
1973
|
+
*
|
|
1974
|
+
* @param query - GROQ-query to perform
|
|
1975
|
+
* @param params - Optional query parameters
|
|
1976
|
+
* @param options - Optional request options
|
|
1977
|
+
*/
|
|
1978
|
+
fetch(query, params, options) {
|
|
1979
|
+
return lastValueFrom(_fetch(this.#client, this.#httpRequest, query, params, options));
|
|
1980
|
+
}
|
|
1981
|
+
listen(query, params, options) {
|
|
1982
|
+
return _listen(this.#client, query, params, options);
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1627
1985
|
/**
|
|
1628
1986
|
* A variant of share that takes a predicate function to determine which value to replay to new subscribers
|
|
1629
1987
|
* @param configOrPredicate - Predicate function to determine which value to replay
|
|
@@ -2689,6 +3047,7 @@ var ObservableReleasesClient = class {
|
|
|
2689
3047
|
projects;
|
|
2690
3048
|
users;
|
|
2691
3049
|
agent;
|
|
3050
|
+
collaboration;
|
|
2692
3051
|
functions;
|
|
2693
3052
|
releases;
|
|
2694
3053
|
/**
|
|
@@ -2699,9 +3058,9 @@ var ObservableReleasesClient = class {
|
|
|
2699
3058
|
/**
|
|
2700
3059
|
* Instance properties
|
|
2701
3060
|
*/
|
|
2702
|
-
listen = _listen;
|
|
3061
|
+
listen = _listen$1;
|
|
2703
3062
|
constructor(httpRequest, config = defaultConfig) {
|
|
2704
|
-
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.mediaLibrary = { video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest) }, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = { action: new ObservableAgentsActionClient(this, this.#httpRequest) }, this.functions = new ObservableFunctionsClient(this, this.#httpRequest), this.releases = new ObservableReleasesClient(this, this.#httpRequest);
|
|
3063
|
+
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.mediaLibrary = { video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest) }, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = { action: new ObservableAgentsActionClient(this, this.#httpRequest) }, this.collaboration = { comments: new ObservableCollaborationCommentsClient(this, this.#httpRequest) }, this.functions = new ObservableFunctionsClient(this, this.#httpRequest), this.releases = new ObservableReleasesClient(this, this.#httpRequest);
|
|
2705
3064
|
}
|
|
2706
3065
|
/**
|
|
2707
3066
|
* Clone the client - returns a new instance
|
|
@@ -2924,6 +3283,7 @@ var ObservableReleasesClient = class {
|
|
|
2924
3283
|
projects;
|
|
2925
3284
|
users;
|
|
2926
3285
|
agent;
|
|
3286
|
+
collaboration;
|
|
2927
3287
|
functions;
|
|
2928
3288
|
releases;
|
|
2929
3289
|
/**
|
|
@@ -2938,9 +3298,9 @@ var ObservableReleasesClient = class {
|
|
|
2938
3298
|
/**
|
|
2939
3299
|
* Instance properties
|
|
2940
3300
|
*/
|
|
2941
|
-
listen = _listen;
|
|
3301
|
+
listen = _listen$1;
|
|
2942
3302
|
constructor(httpRequest, config = defaultConfig) {
|
|
2943
|
-
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.mediaLibrary = { video: new MediaLibraryVideoClient(this, this.#httpRequest) }, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = { action: new AgentActionsClient(this, this.#httpRequest) }, this.functions = new FunctionsClient(this, this.#httpRequest), this.releases = new ReleasesClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3303
|
+
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.mediaLibrary = { video: new MediaLibraryVideoClient(this, this.#httpRequest) }, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = { action: new AgentActionsClient(this, this.#httpRequest) }, this.collaboration = { comments: new CollaborationCommentsClient(this, this.#httpRequest) }, this.functions = new FunctionsClient(this, this.#httpRequest), this.releases = new ReleasesClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
2944
3304
|
}
|
|
2945
3305
|
/**
|
|
2946
3306
|
* Clone the client - returns a new instance
|
|
@@ -2970,7 +3330,7 @@ var ObservableReleasesClient = class {
|
|
|
2970
3330
|
});
|
|
2971
3331
|
}
|
|
2972
3332
|
fetch(query, params, options) {
|
|
2973
|
-
return _fetch(this, this.#httpRequest, this.#clientConfig.stega, query, params, options);
|
|
3333
|
+
return _fetch$1(this, this.#httpRequest, this.#clientConfig.stega, query, params, options);
|
|
2974
3334
|
}
|
|
2975
3335
|
getDocument(id, options) {
|
|
2976
3336
|
if (options?.includeAllVersions === !0) return _getDocument(this, this.#httpRequest, id, {
|
|
@@ -3008,7 +3368,7 @@ var ObservableReleasesClient = class {
|
|
|
3008
3368
|
return _documentsExists(this, this.#httpRequest, ids, options);
|
|
3009
3369
|
}
|
|
3010
3370
|
create(document, options) {
|
|
3011
|
-
return _create(this, this.#httpRequest, document, "create", options);
|
|
3371
|
+
return _create$1(this, this.#httpRequest, document, "create", options);
|
|
3012
3372
|
}
|
|
3013
3373
|
createIfNotExists(document, options) {
|
|
3014
3374
|
return _createIfNotExists(this, this.#httpRequest, document, options);
|
|
@@ -3029,7 +3389,7 @@ var ObservableReleasesClient = class {
|
|
|
3029
3389
|
return _createVersion(this, this.#httpRequest, documentVersion, versionPublishedId, options);
|
|
3030
3390
|
}
|
|
3031
3391
|
delete(selection, options) {
|
|
3032
|
-
return _delete(this, this.#httpRequest, selection, options);
|
|
3392
|
+
return _delete$1(this, this.#httpRequest, selection, options);
|
|
3033
3393
|
}
|
|
3034
3394
|
/**
|
|
3035
3395
|
* @public
|
|
@@ -3202,7 +3562,7 @@ function defineDeprecatedCreateClient(createClient) {
|
|
|
3202
3562
|
return printNoDefaultExport(), createClient(config);
|
|
3203
3563
|
};
|
|
3204
3564
|
}
|
|
3205
|
-
var name = "@sanity/client", version = "8.
|
|
3565
|
+
var name = "@sanity/client", version = "8.2.0";
|
|
3206
3566
|
const log = createDebug("sanity:client");
|
|
3207
3567
|
function isNodeReadableStream(value) {
|
|
3208
3568
|
return typeof value != "object" || !value || !("pipe" in value) ? !1 : typeof value.pipe == "function";
|