@sanity/client 7.1.0 → 7.2.1
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 +516 -40
- package/dist/_chunks-cjs/config.cjs +14 -0
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +15 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +750 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1282 -1
- package/dist/index.browser.d.ts +1282 -1
- package/dist/index.browser.js +752 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +739 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1282 -1
- package/dist/index.d.ts +1282 -1
- package/dist/index.js +742 -7
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1282 -1
- package/dist/stega.browser.d.ts +1282 -1
- package/dist/stega.d.cts +1282 -1
- package/dist/stega.d.ts +1282 -1
- package/package.json +2 -1
- package/src/SanityClient.ts +592 -4
- package/src/data/dataMethods.ts +126 -2
- package/src/releases/ReleasesClient.ts +687 -0
- package/src/releases/createRelease.ts +53 -0
- package/src/types.ts +215 -0
- package/src/util/createVersionId.ts +79 -0
- package/src/validators.ts +23 -1
- package/umd/sanityClient.js +814 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { getIt } from "get-it";
|
|
2
2
|
import { adapter, environment } from "get-it";
|
|
3
3
|
import { retry, jsonRequest, jsonResponse, progress, observable } from "get-it/middleware";
|
|
4
|
-
import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY } from "rxjs";
|
|
4
|
+
import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY, map as map$1, firstValueFrom } from "rxjs";
|
|
5
5
|
import { stegaClean } from "./_chunks-es/stegaClean.js";
|
|
6
6
|
import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
|
|
7
|
+
import { getVersionFromId, isDraftId, getVersionId, getDraftId, isVersionId, getPublishedId } from "@sanity/client/csm";
|
|
8
|
+
import { customAlphabet } from "nanoid";
|
|
7
9
|
class ClientError extends Error {
|
|
8
10
|
response;
|
|
9
11
|
statusCode = 400;
|
|
@@ -135,6 +137,18 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
|
|
|
135
137
|
if (!doc._id)
|
|
136
138
|
throw new Error(`${op}() requires that the document contains an ID ("_id" property)`);
|
|
137
139
|
validateDocumentId(op, doc._id);
|
|
140
|
+
}, validateDocumentType = (op, type) => {
|
|
141
|
+
if (typeof type != "string")
|
|
142
|
+
throw new Error(`\`${op}()\`: \`${type}\` is not a valid document type`);
|
|
143
|
+
}, requireDocumentType = (op, doc) => {
|
|
144
|
+
if (!doc._type)
|
|
145
|
+
throw new Error(`\`${op}()\` requires that the document contains a type (\`_type\` property)`);
|
|
146
|
+
validateDocumentType(op, doc._type);
|
|
147
|
+
}, validateVersionIdMatch = (builtVersionId, document) => {
|
|
148
|
+
if (document._id && document._id !== builtVersionId)
|
|
149
|
+
throw new Error(
|
|
150
|
+
`The provided document ID (\`${document._id}\`) does not match the generated version ID (\`${builtVersionId}\`)`
|
|
151
|
+
);
|
|
138
152
|
}, validateInsert = (at, selector, items) => {
|
|
139
153
|
const signature = "insert(at, selector, items)";
|
|
140
154
|
if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
|
|
@@ -776,8 +790,24 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
|
|
|
776
790
|
) : $request.pipe(map(mapResponse));
|
|
777
791
|
}
|
|
778
792
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
779
|
-
const
|
|
780
|
-
|
|
793
|
+
const docId = (() => {
|
|
794
|
+
if (!opts.releaseId)
|
|
795
|
+
return id;
|
|
796
|
+
const versionId = getVersionFromId(id);
|
|
797
|
+
if (!versionId) {
|
|
798
|
+
if (isDraftId(id))
|
|
799
|
+
throw new Error(
|
|
800
|
+
`The document ID (\`${id}\`) is a draft, but \`options.releaseId\` is set as \`${opts.releaseId}\``
|
|
801
|
+
);
|
|
802
|
+
return getVersionId(id, opts.releaseId);
|
|
803
|
+
}
|
|
804
|
+
if (versionId !== opts.releaseId)
|
|
805
|
+
throw new Error(
|
|
806
|
+
`The document ID (\`${id}\`) is already a version of \`${versionId}\` release, but this does not match the provided \`options.releaseId\` (\`${opts.releaseId}\`)`
|
|
807
|
+
);
|
|
808
|
+
return id;
|
|
809
|
+
})(), options = {
|
|
810
|
+
uri: _getDataUrl(client, "doc", docId),
|
|
781
811
|
json: !0,
|
|
782
812
|
tag: opts.tag,
|
|
783
813
|
signal: opts.signal
|
|
@@ -802,12 +832,33 @@ function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
|
802
832
|
})
|
|
803
833
|
);
|
|
804
834
|
}
|
|
835
|
+
function _getReleaseDocuments(client, httpRequest, releaseId, opts = {}) {
|
|
836
|
+
return _dataRequest(
|
|
837
|
+
client,
|
|
838
|
+
httpRequest,
|
|
839
|
+
"query",
|
|
840
|
+
{
|
|
841
|
+
query: "*[sanity::partOfRelease($releaseId)]",
|
|
842
|
+
params: {
|
|
843
|
+
releaseId
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
opts
|
|
847
|
+
);
|
|
848
|
+
}
|
|
805
849
|
function _createIfNotExists(client, httpRequest, doc, options) {
|
|
806
850
|
return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
|
|
807
851
|
}
|
|
808
852
|
function _createOrReplace(client, httpRequest, doc, options) {
|
|
809
853
|
return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
|
|
810
854
|
}
|
|
855
|
+
function _createVersion(client, httpRequest, doc, publishedId, options) {
|
|
856
|
+
return requireDocumentId("createVersion", doc), requireDocumentType("createVersion", doc), _action(client, httpRequest, {
|
|
857
|
+
actionType: "sanity.action.document.version.create",
|
|
858
|
+
publishedId,
|
|
859
|
+
document: doc
|
|
860
|
+
}, options);
|
|
861
|
+
}
|
|
811
862
|
function _delete(client, httpRequest, selection, options) {
|
|
812
863
|
return _dataRequest(
|
|
813
864
|
client,
|
|
@@ -817,6 +868,26 @@ function _delete(client, httpRequest, selection, options) {
|
|
|
817
868
|
options
|
|
818
869
|
);
|
|
819
870
|
}
|
|
871
|
+
function _discardVersion(client, httpRequest, versionId, purge = !1, options) {
|
|
872
|
+
return _action(client, httpRequest, {
|
|
873
|
+
actionType: "sanity.action.document.version.discard",
|
|
874
|
+
versionId,
|
|
875
|
+
purge
|
|
876
|
+
}, options);
|
|
877
|
+
}
|
|
878
|
+
function _replaceVersion(client, httpRequest, doc, options) {
|
|
879
|
+
return requireDocumentId("replaceVersion", doc), requireDocumentType("replaceVersion", doc), _action(client, httpRequest, {
|
|
880
|
+
actionType: "sanity.action.document.version.replace",
|
|
881
|
+
document: doc
|
|
882
|
+
}, options);
|
|
883
|
+
}
|
|
884
|
+
function _unpublishVersion(client, httpRequest, versionId, publishedId, options) {
|
|
885
|
+
return _action(client, httpRequest, {
|
|
886
|
+
actionType: "sanity.action.document.version.unpublish",
|
|
887
|
+
versionId,
|
|
888
|
+
publishedId
|
|
889
|
+
}, options);
|
|
890
|
+
}
|
|
820
891
|
function _mutate(client, httpRequest, mutations, options) {
|
|
821
892
|
let mut;
|
|
822
893
|
mutations instanceof Patch || mutations instanceof ObservablePatch ? mut = { patch: mutations.serialize() } : mutations instanceof Transaction || mutations instanceof ObservableTransaction ? mut = mutations.serialize() : mut = mutations;
|
|
@@ -1419,6 +1490,498 @@ class ProjectsClient {
|
|
|
1419
1490
|
);
|
|
1420
1491
|
}
|
|
1421
1492
|
}
|
|
1493
|
+
const generateReleaseId = customAlphabet(
|
|
1494
|
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
|
1495
|
+
8
|
|
1496
|
+
), getDocumentVersionId = (publishedId, releaseId) => releaseId ? getVersionId(publishedId, releaseId) : getDraftId(publishedId);
|
|
1497
|
+
function deriveDocumentVersionId(op, {
|
|
1498
|
+
releaseId,
|
|
1499
|
+
publishedId,
|
|
1500
|
+
document
|
|
1501
|
+
}) {
|
|
1502
|
+
if (publishedId && document._id) {
|
|
1503
|
+
const versionId = getDocumentVersionId(publishedId, releaseId);
|
|
1504
|
+
return validateVersionIdMatch(versionId, document), versionId;
|
|
1505
|
+
}
|
|
1506
|
+
if (document._id) {
|
|
1507
|
+
const isDraft = isDraftId(document._id), isVersion = isVersionId(document._id);
|
|
1508
|
+
if (!isDraft && !isVersion)
|
|
1509
|
+
throw new Error(
|
|
1510
|
+
`\`${op}()\` requires a document with an \`_id\` that is a version or draft ID`
|
|
1511
|
+
);
|
|
1512
|
+
if (releaseId) {
|
|
1513
|
+
if (isDraft)
|
|
1514
|
+
throw new Error(
|
|
1515
|
+
`\`${op}()\` was called with a document ID (\`${document._id}\`) that is a draft ID, but a release ID (\`${releaseId}\`) was also provided.`
|
|
1516
|
+
);
|
|
1517
|
+
const builtVersionId = getVersionFromId(document._id);
|
|
1518
|
+
if (builtVersionId !== releaseId)
|
|
1519
|
+
throw new Error(
|
|
1520
|
+
`\`${op}()\` was called with a document ID (\`${document._id}\`) that is a version ID, but the release ID (\`${releaseId}\`) does not match the document's version ID (\`${builtVersionId}\`).`
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
return document._id;
|
|
1524
|
+
}
|
|
1525
|
+
if (publishedId)
|
|
1526
|
+
return getDocumentVersionId(publishedId, releaseId);
|
|
1527
|
+
throw new Error(`\`${op}()\` requires either a publishedId or a document with an \`_id\``);
|
|
1528
|
+
}
|
|
1529
|
+
const getArgs = (releaseOrOptions, maybeOptions) => {
|
|
1530
|
+
if (typeof releaseOrOptions == "object" && releaseOrOptions !== null && ("releaseId" in releaseOrOptions || "metadata" in releaseOrOptions)) {
|
|
1531
|
+
const { releaseId = generateReleaseId(), metadata = {} } = releaseOrOptions;
|
|
1532
|
+
return [releaseId, metadata, maybeOptions];
|
|
1533
|
+
}
|
|
1534
|
+
return [generateReleaseId(), {}, releaseOrOptions];
|
|
1535
|
+
}, createRelease = (releaseOrOptions, maybeOptions) => {
|
|
1536
|
+
const [releaseId, metadata, options] = getArgs(releaseOrOptions, maybeOptions), finalMetadata = {
|
|
1537
|
+
...metadata,
|
|
1538
|
+
releaseType: metadata.releaseType || "undecided"
|
|
1539
|
+
};
|
|
1540
|
+
return { action: {
|
|
1541
|
+
actionType: "sanity.action.release.create",
|
|
1542
|
+
releaseId,
|
|
1543
|
+
metadata: finalMetadata
|
|
1544
|
+
}, options };
|
|
1545
|
+
};
|
|
1546
|
+
class ObservableReleasesClient {
|
|
1547
|
+
#client;
|
|
1548
|
+
#httpRequest;
|
|
1549
|
+
constructor(client, httpRequest) {
|
|
1550
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* @public
|
|
1554
|
+
*
|
|
1555
|
+
* Retrieve a release by id.
|
|
1556
|
+
*
|
|
1557
|
+
* @category Releases
|
|
1558
|
+
*
|
|
1559
|
+
* @param params - Release action parameters:
|
|
1560
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
1561
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
1562
|
+
* @returns An observable that resolves to the release document {@link ReleaseDocument}.
|
|
1563
|
+
*
|
|
1564
|
+
* @example Retrieving a release by id
|
|
1565
|
+
* ```ts
|
|
1566
|
+
* client.observable.releases.get({releaseId: 'my-release'}).pipe(
|
|
1567
|
+
* tap((release) => console.log(release)),
|
|
1568
|
+
* // {
|
|
1569
|
+
* // _id: '_.releases.my-release',
|
|
1570
|
+
* // name: 'my-release'
|
|
1571
|
+
* // _type: 'system.release',
|
|
1572
|
+
* // metadata: {releaseType: 'asap'},
|
|
1573
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
1574
|
+
* // ...
|
|
1575
|
+
* // }
|
|
1576
|
+
* ).subscribe()
|
|
1577
|
+
* ```
|
|
1578
|
+
*/
|
|
1579
|
+
get({ releaseId }, options) {
|
|
1580
|
+
return _getDocument(
|
|
1581
|
+
this.#client,
|
|
1582
|
+
this.#httpRequest,
|
|
1583
|
+
`_.releases.${releaseId}`,
|
|
1584
|
+
options
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
create(releaseOrOptions, maybeOptions) {
|
|
1588
|
+
const { action, options } = createRelease(releaseOrOptions, maybeOptions), { releaseId, metadata } = action;
|
|
1589
|
+
return _action(this.#client, this.#httpRequest, action, options).pipe(
|
|
1590
|
+
map$1((actionResult) => ({
|
|
1591
|
+
...actionResult,
|
|
1592
|
+
releaseId,
|
|
1593
|
+
metadata
|
|
1594
|
+
}))
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* @public
|
|
1599
|
+
*
|
|
1600
|
+
* Edits an existing release, updating the metadata.
|
|
1601
|
+
*
|
|
1602
|
+
* @category Releases
|
|
1603
|
+
*
|
|
1604
|
+
* @param params - Release action parameters:
|
|
1605
|
+
* - `releaseId` - The id of the release to edit.
|
|
1606
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
1607
|
+
* @param options - Additional action options.
|
|
1608
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1609
|
+
*/
|
|
1610
|
+
edit({ releaseId, patch }, options) {
|
|
1611
|
+
const editAction = {
|
|
1612
|
+
actionType: "sanity.action.release.edit",
|
|
1613
|
+
releaseId,
|
|
1614
|
+
patch
|
|
1615
|
+
};
|
|
1616
|
+
return _action(this.#client, this.#httpRequest, editAction, options);
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* @public
|
|
1620
|
+
*
|
|
1621
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
1622
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
1623
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
1624
|
+
* take some time.
|
|
1625
|
+
*
|
|
1626
|
+
* During this period both the source and target documents are locked and cannot be
|
|
1627
|
+
* modified through any other means.
|
|
1628
|
+
*
|
|
1629
|
+
* @category Releases
|
|
1630
|
+
*
|
|
1631
|
+
* @param params - Release action parameters:
|
|
1632
|
+
* - `releaseId` - The id of the release to publish.
|
|
1633
|
+
* @param options - Additional action options.
|
|
1634
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1635
|
+
*/
|
|
1636
|
+
publish({ releaseId }, options) {
|
|
1637
|
+
const publishAction = {
|
|
1638
|
+
actionType: "sanity.action.release.publish",
|
|
1639
|
+
releaseId
|
|
1640
|
+
};
|
|
1641
|
+
return _action(this.#client, this.#httpRequest, publishAction, options);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* @public
|
|
1645
|
+
*
|
|
1646
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
1647
|
+
* are deleted and therefore no longer queryable.
|
|
1648
|
+
*
|
|
1649
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
1650
|
+
*
|
|
1651
|
+
* @category Releases
|
|
1652
|
+
*
|
|
1653
|
+
* @param params - Release action parameters:
|
|
1654
|
+
* - `releaseId` - The id of the release to archive.
|
|
1655
|
+
* @param options - Additional action options.
|
|
1656
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1657
|
+
*/
|
|
1658
|
+
archive({ releaseId }, options) {
|
|
1659
|
+
const archiveAction = {
|
|
1660
|
+
actionType: "sanity.action.release.archive",
|
|
1661
|
+
releaseId
|
|
1662
|
+
};
|
|
1663
|
+
return _action(this.#client, this.#httpRequest, archiveAction, options);
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* @public
|
|
1667
|
+
*
|
|
1668
|
+
* An unarchive action restores an archived release and all documents
|
|
1669
|
+
* with the content they had just prior to archiving.
|
|
1670
|
+
*
|
|
1671
|
+
* @category Releases
|
|
1672
|
+
*
|
|
1673
|
+
* @param params - Release action parameters:
|
|
1674
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
1675
|
+
* @param options - Additional action options.
|
|
1676
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1677
|
+
*/
|
|
1678
|
+
unarchive({ releaseId }, options) {
|
|
1679
|
+
const unarchiveAction = {
|
|
1680
|
+
actionType: "sanity.action.release.unarchive",
|
|
1681
|
+
releaseId
|
|
1682
|
+
};
|
|
1683
|
+
return _action(this.#client, this.#httpRequest, unarchiveAction, options);
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* @public
|
|
1687
|
+
*
|
|
1688
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
1689
|
+
* The release is locked such that no documents in the release can be modified and
|
|
1690
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
1691
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
1692
|
+
*
|
|
1693
|
+
* @category Releases
|
|
1694
|
+
*
|
|
1695
|
+
* @param params - Release action parameters:
|
|
1696
|
+
* - `releaseId` - The id of the release to schedule.
|
|
1697
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
1698
|
+
* @param options - Additional action options.
|
|
1699
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1700
|
+
*/
|
|
1701
|
+
schedule({ releaseId, publishAt }, options) {
|
|
1702
|
+
const scheduleAction = {
|
|
1703
|
+
actionType: "sanity.action.release.schedule",
|
|
1704
|
+
releaseId,
|
|
1705
|
+
publishAt
|
|
1706
|
+
};
|
|
1707
|
+
return _action(this.#client, this.#httpRequest, scheduleAction, options);
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* @public
|
|
1711
|
+
*
|
|
1712
|
+
* An unschedule action stops a release from being published.
|
|
1713
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
1714
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
1715
|
+
* has a reference to a document created by this one.
|
|
1716
|
+
*
|
|
1717
|
+
* @category Releases
|
|
1718
|
+
*
|
|
1719
|
+
* @param params - Release action parameters:
|
|
1720
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
1721
|
+
* @param options - Additional action options.
|
|
1722
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1723
|
+
*/
|
|
1724
|
+
unschedule({ releaseId }, options) {
|
|
1725
|
+
const unscheduleAction = {
|
|
1726
|
+
actionType: "sanity.action.release.unschedule",
|
|
1727
|
+
releaseId
|
|
1728
|
+
};
|
|
1729
|
+
return _action(this.#client, this.#httpRequest, unscheduleAction, options);
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* @public
|
|
1733
|
+
*
|
|
1734
|
+
* A delete action removes a published or archived release.
|
|
1735
|
+
* The backing system document will be removed from the dataset.
|
|
1736
|
+
*
|
|
1737
|
+
* @category Releases
|
|
1738
|
+
*
|
|
1739
|
+
* @param params - Release action parameters:
|
|
1740
|
+
* - `releaseId` - The id of the release to delete.
|
|
1741
|
+
* @param options - Additional action options.
|
|
1742
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1743
|
+
*/
|
|
1744
|
+
delete({ releaseId }, options) {
|
|
1745
|
+
const deleteAction = {
|
|
1746
|
+
actionType: "sanity.action.release.delete",
|
|
1747
|
+
releaseId
|
|
1748
|
+
};
|
|
1749
|
+
return _action(this.#client, this.#httpRequest, deleteAction, options);
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* @public
|
|
1753
|
+
*
|
|
1754
|
+
* Fetch the documents in a release by release id.
|
|
1755
|
+
*
|
|
1756
|
+
* @category Releases
|
|
1757
|
+
*
|
|
1758
|
+
* @param params - Release action parameters:
|
|
1759
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
1760
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
1761
|
+
* @returns An observable that resolves to the documents in the release.
|
|
1762
|
+
*/
|
|
1763
|
+
fetchDocuments({ releaseId }, options) {
|
|
1764
|
+
return _getReleaseDocuments(this.#client, this.#httpRequest, releaseId, options);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
class ReleasesClient {
|
|
1768
|
+
#client;
|
|
1769
|
+
#httpRequest;
|
|
1770
|
+
constructor(client, httpRequest) {
|
|
1771
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* @public
|
|
1775
|
+
*
|
|
1776
|
+
* Retrieve a release by id.
|
|
1777
|
+
*
|
|
1778
|
+
* @category Releases
|
|
1779
|
+
*
|
|
1780
|
+
* @param params - Release action parameters:
|
|
1781
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
1782
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
1783
|
+
* @returns A promise that resolves to the release document {@link ReleaseDocument}.
|
|
1784
|
+
*
|
|
1785
|
+
* @example Retrieving a release by id
|
|
1786
|
+
* ```ts
|
|
1787
|
+
* const release = await client.releases.get({releaseId: 'my-release'})
|
|
1788
|
+
* console.log(release)
|
|
1789
|
+
* // {
|
|
1790
|
+
* // _id: '_.releases.my-release',
|
|
1791
|
+
* // name: 'my-release'
|
|
1792
|
+
* // _type: 'system.release',
|
|
1793
|
+
* // metadata: {releaseType: 'asap'},
|
|
1794
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
1795
|
+
* // ...
|
|
1796
|
+
* // }
|
|
1797
|
+
* ```
|
|
1798
|
+
*/
|
|
1799
|
+
get({ releaseId }, options) {
|
|
1800
|
+
return lastValueFrom(
|
|
1801
|
+
_getDocument(
|
|
1802
|
+
this.#client,
|
|
1803
|
+
this.#httpRequest,
|
|
1804
|
+
`_.releases.${releaseId}`,
|
|
1805
|
+
options
|
|
1806
|
+
)
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
async create(releaseOrOptions, maybeOptions) {
|
|
1810
|
+
const { action, options } = createRelease(releaseOrOptions, maybeOptions), { releaseId, metadata } = action;
|
|
1811
|
+
return { ...await lastValueFrom(
|
|
1812
|
+
_action(this.#client, this.#httpRequest, action, options)
|
|
1813
|
+
), releaseId, metadata };
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* @public
|
|
1817
|
+
*
|
|
1818
|
+
* Edits an existing release, updating the metadata.
|
|
1819
|
+
*
|
|
1820
|
+
* @category Releases
|
|
1821
|
+
*
|
|
1822
|
+
* @param params - Release action parameters:
|
|
1823
|
+
* - `releaseId` - The id of the release to edit.
|
|
1824
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
1825
|
+
* @param options - Additional action options.
|
|
1826
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1827
|
+
*/
|
|
1828
|
+
edit({ releaseId, patch }, options) {
|
|
1829
|
+
const editAction = {
|
|
1830
|
+
actionType: "sanity.action.release.edit",
|
|
1831
|
+
releaseId,
|
|
1832
|
+
patch
|
|
1833
|
+
};
|
|
1834
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, editAction, options));
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* @public
|
|
1838
|
+
*
|
|
1839
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
1840
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
1841
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
1842
|
+
* take some time.
|
|
1843
|
+
*
|
|
1844
|
+
* During this period both the source and target documents are locked and cannot be
|
|
1845
|
+
* modified through any other means.
|
|
1846
|
+
*
|
|
1847
|
+
* @category Releases
|
|
1848
|
+
*
|
|
1849
|
+
* @param params - Release action parameters:
|
|
1850
|
+
* - `releaseId` - The id of the release to publish.
|
|
1851
|
+
* @param options - Additional action options.
|
|
1852
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1853
|
+
*/
|
|
1854
|
+
publish({ releaseId }, options) {
|
|
1855
|
+
const publishAction = {
|
|
1856
|
+
actionType: "sanity.action.release.publish",
|
|
1857
|
+
releaseId
|
|
1858
|
+
};
|
|
1859
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, publishAction, options));
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* @public
|
|
1863
|
+
*
|
|
1864
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
1865
|
+
* are deleted and therefore no longer queryable.
|
|
1866
|
+
*
|
|
1867
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
1868
|
+
*
|
|
1869
|
+
* @category Releases
|
|
1870
|
+
*
|
|
1871
|
+
* @param params - Release action parameters:
|
|
1872
|
+
* - `releaseId` - The id of the release to archive.
|
|
1873
|
+
* @param options - Additional action options.
|
|
1874
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1875
|
+
*/
|
|
1876
|
+
archive({ releaseId }, options) {
|
|
1877
|
+
const archiveAction = {
|
|
1878
|
+
actionType: "sanity.action.release.archive",
|
|
1879
|
+
releaseId
|
|
1880
|
+
};
|
|
1881
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, archiveAction, options));
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* @public
|
|
1885
|
+
*
|
|
1886
|
+
* An unarchive action restores an archived release and all documents
|
|
1887
|
+
* with the content they had just prior to archiving.
|
|
1888
|
+
*
|
|
1889
|
+
* @category Releases
|
|
1890
|
+
*
|
|
1891
|
+
* @param params - Release action parameters:
|
|
1892
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
1893
|
+
* @param options - Additional action options.
|
|
1894
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1895
|
+
*/
|
|
1896
|
+
unarchive({ releaseId }, options) {
|
|
1897
|
+
const unarchiveAction = {
|
|
1898
|
+
actionType: "sanity.action.release.unarchive",
|
|
1899
|
+
releaseId
|
|
1900
|
+
};
|
|
1901
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, unarchiveAction, options));
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* @public
|
|
1905
|
+
*
|
|
1906
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
1907
|
+
* The release is locked such that no documents in the release can be modified and
|
|
1908
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
1909
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
1910
|
+
*
|
|
1911
|
+
* @category Releases
|
|
1912
|
+
*
|
|
1913
|
+
* @param params - Release action parameters:
|
|
1914
|
+
* - `releaseId` - The id of the release to schedule.
|
|
1915
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
1916
|
+
* @param options - Additional action options.
|
|
1917
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1918
|
+
*/
|
|
1919
|
+
schedule({ releaseId, publishAt }, options) {
|
|
1920
|
+
const scheduleAction = {
|
|
1921
|
+
actionType: "sanity.action.release.schedule",
|
|
1922
|
+
releaseId,
|
|
1923
|
+
publishAt
|
|
1924
|
+
};
|
|
1925
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, scheduleAction, options));
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* @public
|
|
1929
|
+
*
|
|
1930
|
+
* An unschedule action stops a release from being published.
|
|
1931
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
1932
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
1933
|
+
* has a reference to a document created by this one.
|
|
1934
|
+
*
|
|
1935
|
+
* @category Releases
|
|
1936
|
+
*
|
|
1937
|
+
* @param params - Release action parameters:
|
|
1938
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
1939
|
+
* @param options - Additional action options.
|
|
1940
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1941
|
+
*/
|
|
1942
|
+
unschedule({ releaseId }, options) {
|
|
1943
|
+
const unscheduleAction = {
|
|
1944
|
+
actionType: "sanity.action.release.unschedule",
|
|
1945
|
+
releaseId
|
|
1946
|
+
};
|
|
1947
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, unscheduleAction, options));
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* @public
|
|
1951
|
+
*
|
|
1952
|
+
* A delete action removes a published or archived release.
|
|
1953
|
+
* The backing system document will be removed from the dataset.
|
|
1954
|
+
*
|
|
1955
|
+
* @category Releases
|
|
1956
|
+
*
|
|
1957
|
+
* @param params - Release action parameters:
|
|
1958
|
+
* - `releaseId` - The id of the release to delete.
|
|
1959
|
+
* @param options - Additional action options.
|
|
1960
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1961
|
+
*/
|
|
1962
|
+
delete({ releaseId }, options) {
|
|
1963
|
+
const deleteAction = {
|
|
1964
|
+
actionType: "sanity.action.release.delete",
|
|
1965
|
+
releaseId
|
|
1966
|
+
};
|
|
1967
|
+
return lastValueFrom(_action(this.#client, this.#httpRequest, deleteAction, options));
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* @public
|
|
1971
|
+
*
|
|
1972
|
+
* Fetch the documents in a release by release id.
|
|
1973
|
+
*
|
|
1974
|
+
* @category Releases
|
|
1975
|
+
*
|
|
1976
|
+
* @param params - Release action parameters:
|
|
1977
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
1978
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
1979
|
+
* @returns A promise that resolves to the documents in the release.
|
|
1980
|
+
*/
|
|
1981
|
+
fetchDocuments({ releaseId }, options) {
|
|
1982
|
+
return lastValueFrom(_getReleaseDocuments(this.#client, this.#httpRequest, releaseId, options));
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1422
1985
|
class ObservableUsersClient {
|
|
1423
1986
|
#client;
|
|
1424
1987
|
#httpRequest;
|
|
@@ -1464,6 +2027,7 @@ class ObservableSanityClient {
|
|
|
1464
2027
|
projects;
|
|
1465
2028
|
users;
|
|
1466
2029
|
agent;
|
|
2030
|
+
releases;
|
|
1467
2031
|
/**
|
|
1468
2032
|
* Private properties
|
|
1469
2033
|
*/
|
|
@@ -1476,7 +2040,7 @@ class ObservableSanityClient {
|
|
|
1476
2040
|
constructor(httpRequest, config = defaultConfig) {
|
|
1477
2041
|
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
2042
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
1479
|
-
};
|
|
2043
|
+
}, this.releases = new ObservableReleasesClient(this, this.#httpRequest);
|
|
1480
2044
|
}
|
|
1481
2045
|
/**
|
|
1482
2046
|
* Clone the client - returns a new instance
|
|
@@ -1549,9 +2113,96 @@ class ObservableSanityClient {
|
|
|
1549
2113
|
createOrReplace(document, options) {
|
|
1550
2114
|
return _createOrReplace(this, this.#httpRequest, document, options);
|
|
1551
2115
|
}
|
|
2116
|
+
createVersion({
|
|
2117
|
+
document,
|
|
2118
|
+
publishedId,
|
|
2119
|
+
releaseId
|
|
2120
|
+
}, options) {
|
|
2121
|
+
const documentVersionId = deriveDocumentVersionId("createVersion", {
|
|
2122
|
+
document,
|
|
2123
|
+
publishedId,
|
|
2124
|
+
releaseId
|
|
2125
|
+
}), documentVersion = { ...document, _id: documentVersionId }, versionPublishedId = publishedId || getPublishedId(document._id);
|
|
2126
|
+
return _createVersion(
|
|
2127
|
+
this,
|
|
2128
|
+
this.#httpRequest,
|
|
2129
|
+
documentVersion,
|
|
2130
|
+
versionPublishedId,
|
|
2131
|
+
options
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
1552
2134
|
delete(selection, options) {
|
|
1553
2135
|
return _delete(this, this.#httpRequest, selection, options);
|
|
1554
2136
|
}
|
|
2137
|
+
/**
|
|
2138
|
+
* @public
|
|
2139
|
+
*
|
|
2140
|
+
* Deletes the draft or release version of a document.
|
|
2141
|
+
*
|
|
2142
|
+
* @remarks
|
|
2143
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
2144
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
2145
|
+
*
|
|
2146
|
+
* @param params - Version action parameters:
|
|
2147
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
2148
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
2149
|
+
* @param purge - if `true` the document history is also discarded.
|
|
2150
|
+
* @param options - Additional action options.
|
|
2151
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
2152
|
+
*
|
|
2153
|
+
* @example Discarding a release version of a document
|
|
2154
|
+
* ```ts
|
|
2155
|
+
* client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2156
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
2157
|
+
* ```
|
|
2158
|
+
*
|
|
2159
|
+
* @example Discarding a draft version of a document
|
|
2160
|
+
* ```ts
|
|
2161
|
+
* client.observable.discardVersion({publishedId: 'myDocument'})
|
|
2162
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
2163
|
+
* ```
|
|
2164
|
+
*/
|
|
2165
|
+
discardVersion({ releaseId, publishedId }, purge, options) {
|
|
2166
|
+
const documentVersionId = getDocumentVersionId(publishedId, releaseId);
|
|
2167
|
+
return _discardVersion(this, this.#httpRequest, documentVersionId, purge, options);
|
|
2168
|
+
}
|
|
2169
|
+
replaceVersion({
|
|
2170
|
+
document,
|
|
2171
|
+
publishedId,
|
|
2172
|
+
releaseId
|
|
2173
|
+
}, options) {
|
|
2174
|
+
const documentVersionId = deriveDocumentVersionId("replaceVersion", {
|
|
2175
|
+
document,
|
|
2176
|
+
publishedId,
|
|
2177
|
+
releaseId
|
|
2178
|
+
}), documentVersion = { ...document, _id: documentVersionId };
|
|
2179
|
+
return _replaceVersion(this, this.#httpRequest, documentVersion, options);
|
|
2180
|
+
}
|
|
2181
|
+
/**
|
|
2182
|
+
* @public
|
|
2183
|
+
*
|
|
2184
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
2185
|
+
* the release is run.
|
|
2186
|
+
*
|
|
2187
|
+
* @remarks
|
|
2188
|
+
* * If the published document does not exist, an error will be thrown.
|
|
2189
|
+
*
|
|
2190
|
+
* @param params - Version action parameters:
|
|
2191
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
2192
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
2193
|
+
* @param options - Additional action options.
|
|
2194
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
2195
|
+
*
|
|
2196
|
+
* @example Unpublishing a release version of a published document
|
|
2197
|
+
* ```ts
|
|
2198
|
+
* client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2199
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
2200
|
+
* ```
|
|
2201
|
+
*/
|
|
2202
|
+
unpublishVersion({ releaseId, publishedId }, options) {
|
|
2203
|
+
const versionId = getVersionId(publishedId, releaseId);
|
|
2204
|
+
return _unpublishVersion(this, this.#httpRequest, versionId, publishedId, options);
|
|
2205
|
+
}
|
|
1555
2206
|
mutate(operations, options) {
|
|
1556
2207
|
return _mutate(this, this.#httpRequest, operations, options);
|
|
1557
2208
|
}
|
|
@@ -1616,6 +2267,7 @@ class SanityClient {
|
|
|
1616
2267
|
projects;
|
|
1617
2268
|
users;
|
|
1618
2269
|
agent;
|
|
2270
|
+
releases;
|
|
1619
2271
|
/**
|
|
1620
2272
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1621
2273
|
*/
|
|
@@ -1632,7 +2284,7 @@ class SanityClient {
|
|
|
1632
2284
|
constructor(httpRequest, config = defaultConfig) {
|
|
1633
2285
|
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
2286
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
1635
|
-
}, this.observable = new ObservableSanityClient(httpRequest, config);
|
|
2287
|
+
}, this.releases = new ReleasesClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1636
2288
|
}
|
|
1637
2289
|
/**
|
|
1638
2290
|
* Clone the client - returns a new instance
|
|
@@ -1713,9 +2365,104 @@ class SanityClient {
|
|
|
1713
2365
|
_createOrReplace(this, this.#httpRequest, document, options)
|
|
1714
2366
|
);
|
|
1715
2367
|
}
|
|
2368
|
+
createVersion({
|
|
2369
|
+
document,
|
|
2370
|
+
publishedId,
|
|
2371
|
+
releaseId
|
|
2372
|
+
}, options) {
|
|
2373
|
+
const documentVersionId = deriveDocumentVersionId("createVersion", {
|
|
2374
|
+
document,
|
|
2375
|
+
publishedId,
|
|
2376
|
+
releaseId
|
|
2377
|
+
}), documentVersion = { ...document, _id: documentVersionId }, versionPublishedId = publishedId || getPublishedId(document._id);
|
|
2378
|
+
return firstValueFrom(
|
|
2379
|
+
_createVersion(
|
|
2380
|
+
this,
|
|
2381
|
+
this.#httpRequest,
|
|
2382
|
+
documentVersion,
|
|
2383
|
+
versionPublishedId,
|
|
2384
|
+
options
|
|
2385
|
+
)
|
|
2386
|
+
);
|
|
2387
|
+
}
|
|
1716
2388
|
delete(selection, options) {
|
|
1717
2389
|
return lastValueFrom(_delete(this, this.#httpRequest, selection, options));
|
|
1718
2390
|
}
|
|
2391
|
+
/**
|
|
2392
|
+
* @public
|
|
2393
|
+
*
|
|
2394
|
+
* Deletes the draft or release version of a document.
|
|
2395
|
+
*
|
|
2396
|
+
* @remarks
|
|
2397
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
2398
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
2399
|
+
*
|
|
2400
|
+
* @param params - Version action parameters:
|
|
2401
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
2402
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
2403
|
+
* @param purge - if `true` the document history is also discarded.
|
|
2404
|
+
* @param options - Additional action options.
|
|
2405
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
2406
|
+
*
|
|
2407
|
+
* @example Discarding a release version of a document
|
|
2408
|
+
* ```ts
|
|
2409
|
+
* client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2410
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
2411
|
+
* ```
|
|
2412
|
+
*
|
|
2413
|
+
* @example Discarding a draft version of a document
|
|
2414
|
+
* ```ts
|
|
2415
|
+
* client.discardVersion({publishedId: 'myDocument'})
|
|
2416
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
2417
|
+
* ```
|
|
2418
|
+
*/
|
|
2419
|
+
discardVersion({ releaseId, publishedId }, purge, options) {
|
|
2420
|
+
const documentVersionId = getDocumentVersionId(publishedId, releaseId);
|
|
2421
|
+
return lastValueFrom(
|
|
2422
|
+
_discardVersion(this, this.#httpRequest, documentVersionId, purge, options)
|
|
2423
|
+
);
|
|
2424
|
+
}
|
|
2425
|
+
replaceVersion({
|
|
2426
|
+
document,
|
|
2427
|
+
publishedId,
|
|
2428
|
+
releaseId
|
|
2429
|
+
}, options) {
|
|
2430
|
+
const documentVersionId = deriveDocumentVersionId("replaceVersion", {
|
|
2431
|
+
document,
|
|
2432
|
+
publishedId,
|
|
2433
|
+
releaseId
|
|
2434
|
+
}), documentVersion = { ...document, _id: documentVersionId };
|
|
2435
|
+
return firstValueFrom(
|
|
2436
|
+
_replaceVersion(this, this.#httpRequest, documentVersion, options)
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* @public
|
|
2441
|
+
*
|
|
2442
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
2443
|
+
* the release is run.
|
|
2444
|
+
*
|
|
2445
|
+
* @remarks
|
|
2446
|
+
* * If the published document does not exist, an error will be thrown.
|
|
2447
|
+
*
|
|
2448
|
+
* @param params - Version action parameters:
|
|
2449
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
2450
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
2451
|
+
* @param options - Additional action options.
|
|
2452
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
2453
|
+
*
|
|
2454
|
+
* @example Unpublishing a release version of a published document
|
|
2455
|
+
* ```ts
|
|
2456
|
+
* await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2457
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
2458
|
+
* ```
|
|
2459
|
+
*/
|
|
2460
|
+
unpublishVersion({ releaseId, publishedId }, options) {
|
|
2461
|
+
const versionId = getVersionId(publishedId, releaseId);
|
|
2462
|
+
return lastValueFrom(
|
|
2463
|
+
_unpublishVersion(this, this.#httpRequest, versionId, publishedId, options)
|
|
2464
|
+
);
|
|
2465
|
+
}
|
|
1719
2466
|
mutate(operations, options) {
|
|
1720
2467
|
return lastValueFrom(_mutate(this, this.#httpRequest, operations, options));
|
|
1721
2468
|
}
|