@sanity/client 7.1.0 → 7.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 +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 +815 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
mod
|
|
20
20
|
));
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
22
|
-
var getIt = require("get-it"), middleware = require("get-it/middleware"), rxjs = require("rxjs"), stegaClean = require("./_chunks-cjs/stegaClean.cjs"), operators = require("rxjs/operators");
|
|
22
|
+
var getIt = require("get-it"), middleware = require("get-it/middleware"), rxjs = require("rxjs"), stegaClean = require("./_chunks-cjs/stegaClean.cjs"), operators = require("rxjs/operators"), csm = require("@sanity/client/csm"), nanoid = require("nanoid");
|
|
23
23
|
class ClientError extends Error {
|
|
24
24
|
response;
|
|
25
25
|
statusCode = 400;
|
|
@@ -151,6 +151,18 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
|
|
|
151
151
|
if (!doc._id)
|
|
152
152
|
throw new Error(`${op}() requires that the document contains an ID ("_id" property)`);
|
|
153
153
|
validateDocumentId(op, doc._id);
|
|
154
|
+
}, validateDocumentType = (op, type) => {
|
|
155
|
+
if (typeof type != "string")
|
|
156
|
+
throw new Error(`\`${op}()\`: \`${type}\` is not a valid document type`);
|
|
157
|
+
}, requireDocumentType = (op, doc) => {
|
|
158
|
+
if (!doc._type)
|
|
159
|
+
throw new Error(`\`${op}()\` requires that the document contains a type (\`_type\` property)`);
|
|
160
|
+
validateDocumentType(op, doc._type);
|
|
161
|
+
}, validateVersionIdMatch = (builtVersionId, document) => {
|
|
162
|
+
if (document._id && document._id !== builtVersionId)
|
|
163
|
+
throw new Error(
|
|
164
|
+
`The provided document ID (\`${document._id}\`) does not match the generated version ID (\`${builtVersionId}\`)`
|
|
165
|
+
);
|
|
154
166
|
}, validateInsert = (at, selector, items) => {
|
|
155
167
|
const signature = "insert(at, selector, items)";
|
|
156
168
|
if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
|
|
@@ -794,8 +806,24 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
|
|
|
794
806
|
) : $request.pipe(operators.map(mapResponse));
|
|
795
807
|
}
|
|
796
808
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
797
|
-
const
|
|
798
|
-
|
|
809
|
+
const docId = (() => {
|
|
810
|
+
if (!opts.releaseId)
|
|
811
|
+
return id;
|
|
812
|
+
const versionId = csm.getVersionFromId(id);
|
|
813
|
+
if (!versionId) {
|
|
814
|
+
if (csm.isDraftId(id))
|
|
815
|
+
throw new Error(
|
|
816
|
+
`The document ID (\`${id}\`) is a draft, but \`options.releaseId\` is set as \`${opts.releaseId}\``
|
|
817
|
+
);
|
|
818
|
+
return csm.getVersionId(id, opts.releaseId);
|
|
819
|
+
}
|
|
820
|
+
if (versionId !== opts.releaseId)
|
|
821
|
+
throw new Error(
|
|
822
|
+
`The document ID (\`${id}\`) is already a version of \`${versionId}\` release, but this does not match the provided \`options.releaseId\` (\`${opts.releaseId}\`)`
|
|
823
|
+
);
|
|
824
|
+
return id;
|
|
825
|
+
})(), options = {
|
|
826
|
+
uri: _getDataUrl(client, "doc", docId),
|
|
799
827
|
json: !0,
|
|
800
828
|
tag: opts.tag,
|
|
801
829
|
signal: opts.signal
|
|
@@ -820,12 +848,33 @@ function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
|
820
848
|
})
|
|
821
849
|
);
|
|
822
850
|
}
|
|
851
|
+
function _getReleaseDocuments(client, httpRequest, releaseId, opts = {}) {
|
|
852
|
+
return _dataRequest(
|
|
853
|
+
client,
|
|
854
|
+
httpRequest,
|
|
855
|
+
"query",
|
|
856
|
+
{
|
|
857
|
+
query: "*[sanity::partOfRelease($releaseId)]",
|
|
858
|
+
params: {
|
|
859
|
+
releaseId
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
opts
|
|
863
|
+
);
|
|
864
|
+
}
|
|
823
865
|
function _createIfNotExists(client, httpRequest, doc, options) {
|
|
824
866
|
return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
|
|
825
867
|
}
|
|
826
868
|
function _createOrReplace(client, httpRequest, doc, options) {
|
|
827
869
|
return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
|
|
828
870
|
}
|
|
871
|
+
function _createVersion(client, httpRequest, doc, publishedId, options) {
|
|
872
|
+
return requireDocumentId("createVersion", doc), requireDocumentType("createVersion", doc), _action(client, httpRequest, {
|
|
873
|
+
actionType: "sanity.action.document.version.create",
|
|
874
|
+
publishedId,
|
|
875
|
+
document: doc
|
|
876
|
+
}, options);
|
|
877
|
+
}
|
|
829
878
|
function _delete(client, httpRequest, selection, options) {
|
|
830
879
|
return _dataRequest(
|
|
831
880
|
client,
|
|
@@ -835,6 +884,26 @@ function _delete(client, httpRequest, selection, options) {
|
|
|
835
884
|
options
|
|
836
885
|
);
|
|
837
886
|
}
|
|
887
|
+
function _discardVersion(client, httpRequest, versionId, purge = !1, options) {
|
|
888
|
+
return _action(client, httpRequest, {
|
|
889
|
+
actionType: "sanity.action.document.version.discard",
|
|
890
|
+
versionId,
|
|
891
|
+
purge
|
|
892
|
+
}, options);
|
|
893
|
+
}
|
|
894
|
+
function _replaceVersion(client, httpRequest, doc, options) {
|
|
895
|
+
return requireDocumentId("replaceVersion", doc), requireDocumentType("replaceVersion", doc), _action(client, httpRequest, {
|
|
896
|
+
actionType: "sanity.action.document.version.replace",
|
|
897
|
+
document: doc
|
|
898
|
+
}, options);
|
|
899
|
+
}
|
|
900
|
+
function _unpublishVersion(client, httpRequest, versionId, publishedId, options) {
|
|
901
|
+
return _action(client, httpRequest, {
|
|
902
|
+
actionType: "sanity.action.document.version.unpublish",
|
|
903
|
+
versionId,
|
|
904
|
+
publishedId
|
|
905
|
+
}, options);
|
|
906
|
+
}
|
|
838
907
|
function _mutate(client, httpRequest, mutations, options) {
|
|
839
908
|
let mut;
|
|
840
909
|
mutations instanceof Patch || mutations instanceof ObservablePatch ? mut = { patch: mutations.serialize() } : mutations instanceof Transaction || mutations instanceof ObservableTransaction ? mut = mutations.serialize() : mut = mutations;
|
|
@@ -1437,6 +1506,498 @@ class ProjectsClient {
|
|
|
1437
1506
|
);
|
|
1438
1507
|
}
|
|
1439
1508
|
}
|
|
1509
|
+
const generateReleaseId = nanoid.customAlphabet(
|
|
1510
|
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
|
1511
|
+
8
|
|
1512
|
+
), getDocumentVersionId = (publishedId, releaseId) => releaseId ? csm.getVersionId(publishedId, releaseId) : csm.getDraftId(publishedId);
|
|
1513
|
+
function deriveDocumentVersionId(op, {
|
|
1514
|
+
releaseId,
|
|
1515
|
+
publishedId,
|
|
1516
|
+
document
|
|
1517
|
+
}) {
|
|
1518
|
+
if (publishedId && document._id) {
|
|
1519
|
+
const versionId = getDocumentVersionId(publishedId, releaseId);
|
|
1520
|
+
return validateVersionIdMatch(versionId, document), versionId;
|
|
1521
|
+
}
|
|
1522
|
+
if (document._id) {
|
|
1523
|
+
const isDraft = csm.isDraftId(document._id), isVersion = csm.isVersionId(document._id);
|
|
1524
|
+
if (!isDraft && !isVersion)
|
|
1525
|
+
throw new Error(
|
|
1526
|
+
`\`${op}()\` requires a document with an \`_id\` that is a version or draft ID`
|
|
1527
|
+
);
|
|
1528
|
+
if (releaseId) {
|
|
1529
|
+
if (isDraft)
|
|
1530
|
+
throw new Error(
|
|
1531
|
+
`\`${op}()\` was called with a document ID (\`${document._id}\`) that is a draft ID, but a release ID (\`${releaseId}\`) was also provided.`
|
|
1532
|
+
);
|
|
1533
|
+
const builtVersionId = csm.getVersionFromId(document._id);
|
|
1534
|
+
if (builtVersionId !== releaseId)
|
|
1535
|
+
throw new Error(
|
|
1536
|
+
`\`${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}\`).`
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
return document._id;
|
|
1540
|
+
}
|
|
1541
|
+
if (publishedId)
|
|
1542
|
+
return getDocumentVersionId(publishedId, releaseId);
|
|
1543
|
+
throw new Error(`\`${op}()\` requires either a publishedId or a document with an \`_id\``);
|
|
1544
|
+
}
|
|
1545
|
+
const getArgs = (releaseOrOptions, maybeOptions) => {
|
|
1546
|
+
if (typeof releaseOrOptions == "object" && releaseOrOptions !== null && ("releaseId" in releaseOrOptions || "metadata" in releaseOrOptions)) {
|
|
1547
|
+
const { releaseId = generateReleaseId(), metadata = {} } = releaseOrOptions;
|
|
1548
|
+
return [releaseId, metadata, maybeOptions];
|
|
1549
|
+
}
|
|
1550
|
+
return [generateReleaseId(), {}, releaseOrOptions];
|
|
1551
|
+
}, createRelease = (releaseOrOptions, maybeOptions) => {
|
|
1552
|
+
const [releaseId, metadata, options] = getArgs(releaseOrOptions, maybeOptions), finalMetadata = {
|
|
1553
|
+
...metadata,
|
|
1554
|
+
releaseType: metadata.releaseType || "undecided"
|
|
1555
|
+
};
|
|
1556
|
+
return { action: {
|
|
1557
|
+
actionType: "sanity.action.release.create",
|
|
1558
|
+
releaseId,
|
|
1559
|
+
metadata: finalMetadata
|
|
1560
|
+
}, options };
|
|
1561
|
+
};
|
|
1562
|
+
class ObservableReleasesClient {
|
|
1563
|
+
#client;
|
|
1564
|
+
#httpRequest;
|
|
1565
|
+
constructor(client, httpRequest) {
|
|
1566
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* @public
|
|
1570
|
+
*
|
|
1571
|
+
* Retrieve a release by id.
|
|
1572
|
+
*
|
|
1573
|
+
* @category Releases
|
|
1574
|
+
*
|
|
1575
|
+
* @param params - Release action parameters:
|
|
1576
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
1577
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
1578
|
+
* @returns An observable that resolves to the release document {@link ReleaseDocument}.
|
|
1579
|
+
*
|
|
1580
|
+
* @example Retrieving a release by id
|
|
1581
|
+
* ```ts
|
|
1582
|
+
* client.observable.releases.get({releaseId: 'my-release'}).pipe(
|
|
1583
|
+
* tap((release) => console.log(release)),
|
|
1584
|
+
* // {
|
|
1585
|
+
* // _id: '_.releases.my-release',
|
|
1586
|
+
* // name: 'my-release'
|
|
1587
|
+
* // _type: 'system.release',
|
|
1588
|
+
* // metadata: {releaseType: 'asap'},
|
|
1589
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
1590
|
+
* // ...
|
|
1591
|
+
* // }
|
|
1592
|
+
* ).subscribe()
|
|
1593
|
+
* ```
|
|
1594
|
+
*/
|
|
1595
|
+
get({ releaseId }, options) {
|
|
1596
|
+
return _getDocument(
|
|
1597
|
+
this.#client,
|
|
1598
|
+
this.#httpRequest,
|
|
1599
|
+
`_.releases.${releaseId}`,
|
|
1600
|
+
options
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
create(releaseOrOptions, maybeOptions) {
|
|
1604
|
+
const { action, options } = createRelease(releaseOrOptions, maybeOptions), { releaseId, metadata } = action;
|
|
1605
|
+
return _action(this.#client, this.#httpRequest, action, options).pipe(
|
|
1606
|
+
rxjs.map((actionResult) => ({
|
|
1607
|
+
...actionResult,
|
|
1608
|
+
releaseId,
|
|
1609
|
+
metadata
|
|
1610
|
+
}))
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* @public
|
|
1615
|
+
*
|
|
1616
|
+
* Edits an existing release, updating the metadata.
|
|
1617
|
+
*
|
|
1618
|
+
* @category Releases
|
|
1619
|
+
*
|
|
1620
|
+
* @param params - Release action parameters:
|
|
1621
|
+
* - `releaseId` - The id of the release to edit.
|
|
1622
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
1623
|
+
* @param options - Additional action options.
|
|
1624
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1625
|
+
*/
|
|
1626
|
+
edit({ releaseId, patch }, options) {
|
|
1627
|
+
const editAction = {
|
|
1628
|
+
actionType: "sanity.action.release.edit",
|
|
1629
|
+
releaseId,
|
|
1630
|
+
patch
|
|
1631
|
+
};
|
|
1632
|
+
return _action(this.#client, this.#httpRequest, editAction, options);
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* @public
|
|
1636
|
+
*
|
|
1637
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
1638
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
1639
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
1640
|
+
* take some time.
|
|
1641
|
+
*
|
|
1642
|
+
* During this period both the source and target documents are locked and cannot be
|
|
1643
|
+
* modified through any other means.
|
|
1644
|
+
*
|
|
1645
|
+
* @category Releases
|
|
1646
|
+
*
|
|
1647
|
+
* @param params - Release action parameters:
|
|
1648
|
+
* - `releaseId` - The id of the release to publish.
|
|
1649
|
+
* @param options - Additional action options.
|
|
1650
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1651
|
+
*/
|
|
1652
|
+
publish({ releaseId }, options) {
|
|
1653
|
+
const publishAction = {
|
|
1654
|
+
actionType: "sanity.action.release.publish",
|
|
1655
|
+
releaseId
|
|
1656
|
+
};
|
|
1657
|
+
return _action(this.#client, this.#httpRequest, publishAction, options);
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* @public
|
|
1661
|
+
*
|
|
1662
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
1663
|
+
* are deleted and therefore no longer queryable.
|
|
1664
|
+
*
|
|
1665
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
1666
|
+
*
|
|
1667
|
+
* @category Releases
|
|
1668
|
+
*
|
|
1669
|
+
* @param params - Release action parameters:
|
|
1670
|
+
* - `releaseId` - The id of the release to archive.
|
|
1671
|
+
* @param options - Additional action options.
|
|
1672
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1673
|
+
*/
|
|
1674
|
+
archive({ releaseId }, options) {
|
|
1675
|
+
const archiveAction = {
|
|
1676
|
+
actionType: "sanity.action.release.archive",
|
|
1677
|
+
releaseId
|
|
1678
|
+
};
|
|
1679
|
+
return _action(this.#client, this.#httpRequest, archiveAction, options);
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* @public
|
|
1683
|
+
*
|
|
1684
|
+
* An unarchive action restores an archived release and all documents
|
|
1685
|
+
* with the content they had just prior to archiving.
|
|
1686
|
+
*
|
|
1687
|
+
* @category Releases
|
|
1688
|
+
*
|
|
1689
|
+
* @param params - Release action parameters:
|
|
1690
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
1691
|
+
* @param options - Additional action options.
|
|
1692
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1693
|
+
*/
|
|
1694
|
+
unarchive({ releaseId }, options) {
|
|
1695
|
+
const unarchiveAction = {
|
|
1696
|
+
actionType: "sanity.action.release.unarchive",
|
|
1697
|
+
releaseId
|
|
1698
|
+
};
|
|
1699
|
+
return _action(this.#client, this.#httpRequest, unarchiveAction, options);
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* @public
|
|
1703
|
+
*
|
|
1704
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
1705
|
+
* The release is locked such that no documents in the release can be modified and
|
|
1706
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
1707
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
1708
|
+
*
|
|
1709
|
+
* @category Releases
|
|
1710
|
+
*
|
|
1711
|
+
* @param params - Release action parameters:
|
|
1712
|
+
* - `releaseId` - The id of the release to schedule.
|
|
1713
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
1714
|
+
* @param options - Additional action options.
|
|
1715
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1716
|
+
*/
|
|
1717
|
+
schedule({ releaseId, publishAt }, options) {
|
|
1718
|
+
const scheduleAction = {
|
|
1719
|
+
actionType: "sanity.action.release.schedule",
|
|
1720
|
+
releaseId,
|
|
1721
|
+
publishAt
|
|
1722
|
+
};
|
|
1723
|
+
return _action(this.#client, this.#httpRequest, scheduleAction, options);
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* @public
|
|
1727
|
+
*
|
|
1728
|
+
* An unschedule action stops a release from being published.
|
|
1729
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
1730
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
1731
|
+
* has a reference to a document created by this one.
|
|
1732
|
+
*
|
|
1733
|
+
* @category Releases
|
|
1734
|
+
*
|
|
1735
|
+
* @param params - Release action parameters:
|
|
1736
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
1737
|
+
* @param options - Additional action options.
|
|
1738
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1739
|
+
*/
|
|
1740
|
+
unschedule({ releaseId }, options) {
|
|
1741
|
+
const unscheduleAction = {
|
|
1742
|
+
actionType: "sanity.action.release.unschedule",
|
|
1743
|
+
releaseId
|
|
1744
|
+
};
|
|
1745
|
+
return _action(this.#client, this.#httpRequest, unscheduleAction, options);
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* @public
|
|
1749
|
+
*
|
|
1750
|
+
* A delete action removes a published or archived release.
|
|
1751
|
+
* The backing system document will be removed from the dataset.
|
|
1752
|
+
*
|
|
1753
|
+
* @category Releases
|
|
1754
|
+
*
|
|
1755
|
+
* @param params - Release action parameters:
|
|
1756
|
+
* - `releaseId` - The id of the release to delete.
|
|
1757
|
+
* @param options - Additional action options.
|
|
1758
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
1759
|
+
*/
|
|
1760
|
+
delete({ releaseId }, options) {
|
|
1761
|
+
const deleteAction = {
|
|
1762
|
+
actionType: "sanity.action.release.delete",
|
|
1763
|
+
releaseId
|
|
1764
|
+
};
|
|
1765
|
+
return _action(this.#client, this.#httpRequest, deleteAction, options);
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* @public
|
|
1769
|
+
*
|
|
1770
|
+
* Fetch the documents in a release by release id.
|
|
1771
|
+
*
|
|
1772
|
+
* @category Releases
|
|
1773
|
+
*
|
|
1774
|
+
* @param params - Release action parameters:
|
|
1775
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
1776
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
1777
|
+
* @returns An observable that resolves to the documents in the release.
|
|
1778
|
+
*/
|
|
1779
|
+
fetchDocuments({ releaseId }, options) {
|
|
1780
|
+
return _getReleaseDocuments(this.#client, this.#httpRequest, releaseId, options);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
class ReleasesClient {
|
|
1784
|
+
#client;
|
|
1785
|
+
#httpRequest;
|
|
1786
|
+
constructor(client, httpRequest) {
|
|
1787
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* @public
|
|
1791
|
+
*
|
|
1792
|
+
* Retrieve a release by id.
|
|
1793
|
+
*
|
|
1794
|
+
* @category Releases
|
|
1795
|
+
*
|
|
1796
|
+
* @param params - Release action parameters:
|
|
1797
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
1798
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
1799
|
+
* @returns A promise that resolves to the release document {@link ReleaseDocument}.
|
|
1800
|
+
*
|
|
1801
|
+
* @example Retrieving a release by id
|
|
1802
|
+
* ```ts
|
|
1803
|
+
* const release = await client.releases.get({releaseId: 'my-release'})
|
|
1804
|
+
* console.log(release)
|
|
1805
|
+
* // {
|
|
1806
|
+
* // _id: '_.releases.my-release',
|
|
1807
|
+
* // name: 'my-release'
|
|
1808
|
+
* // _type: 'system.release',
|
|
1809
|
+
* // metadata: {releaseType: 'asap'},
|
|
1810
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
1811
|
+
* // ...
|
|
1812
|
+
* // }
|
|
1813
|
+
* ```
|
|
1814
|
+
*/
|
|
1815
|
+
get({ releaseId }, options) {
|
|
1816
|
+
return rxjs.lastValueFrom(
|
|
1817
|
+
_getDocument(
|
|
1818
|
+
this.#client,
|
|
1819
|
+
this.#httpRequest,
|
|
1820
|
+
`_.releases.${releaseId}`,
|
|
1821
|
+
options
|
|
1822
|
+
)
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
async create(releaseOrOptions, maybeOptions) {
|
|
1826
|
+
const { action, options } = createRelease(releaseOrOptions, maybeOptions), { releaseId, metadata } = action;
|
|
1827
|
+
return { ...await rxjs.lastValueFrom(
|
|
1828
|
+
_action(this.#client, this.#httpRequest, action, options)
|
|
1829
|
+
), releaseId, metadata };
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* @public
|
|
1833
|
+
*
|
|
1834
|
+
* Edits an existing release, updating the metadata.
|
|
1835
|
+
*
|
|
1836
|
+
* @category Releases
|
|
1837
|
+
*
|
|
1838
|
+
* @param params - Release action parameters:
|
|
1839
|
+
* - `releaseId` - The id of the release to edit.
|
|
1840
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
1841
|
+
* @param options - Additional action options.
|
|
1842
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1843
|
+
*/
|
|
1844
|
+
edit({ releaseId, patch }, options) {
|
|
1845
|
+
const editAction = {
|
|
1846
|
+
actionType: "sanity.action.release.edit",
|
|
1847
|
+
releaseId,
|
|
1848
|
+
patch
|
|
1849
|
+
};
|
|
1850
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, editAction, options));
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* @public
|
|
1854
|
+
*
|
|
1855
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
1856
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
1857
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
1858
|
+
* take some time.
|
|
1859
|
+
*
|
|
1860
|
+
* During this period both the source and target documents are locked and cannot be
|
|
1861
|
+
* modified through any other means.
|
|
1862
|
+
*
|
|
1863
|
+
* @category Releases
|
|
1864
|
+
*
|
|
1865
|
+
* @param params - Release action parameters:
|
|
1866
|
+
* - `releaseId` - The id of the release to publish.
|
|
1867
|
+
* @param options - Additional action options.
|
|
1868
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1869
|
+
*/
|
|
1870
|
+
publish({ releaseId }, options) {
|
|
1871
|
+
const publishAction = {
|
|
1872
|
+
actionType: "sanity.action.release.publish",
|
|
1873
|
+
releaseId
|
|
1874
|
+
};
|
|
1875
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, publishAction, options));
|
|
1876
|
+
}
|
|
1877
|
+
/**
|
|
1878
|
+
* @public
|
|
1879
|
+
*
|
|
1880
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
1881
|
+
* are deleted and therefore no longer queryable.
|
|
1882
|
+
*
|
|
1883
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
1884
|
+
*
|
|
1885
|
+
* @category Releases
|
|
1886
|
+
*
|
|
1887
|
+
* @param params - Release action parameters:
|
|
1888
|
+
* - `releaseId` - The id of the release to archive.
|
|
1889
|
+
* @param options - Additional action options.
|
|
1890
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1891
|
+
*/
|
|
1892
|
+
archive({ releaseId }, options) {
|
|
1893
|
+
const archiveAction = {
|
|
1894
|
+
actionType: "sanity.action.release.archive",
|
|
1895
|
+
releaseId
|
|
1896
|
+
};
|
|
1897
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, archiveAction, options));
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* @public
|
|
1901
|
+
*
|
|
1902
|
+
* An unarchive action restores an archived release and all documents
|
|
1903
|
+
* with the content they had just prior to archiving.
|
|
1904
|
+
*
|
|
1905
|
+
* @category Releases
|
|
1906
|
+
*
|
|
1907
|
+
* @param params - Release action parameters:
|
|
1908
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
1909
|
+
* @param options - Additional action options.
|
|
1910
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1911
|
+
*/
|
|
1912
|
+
unarchive({ releaseId }, options) {
|
|
1913
|
+
const unarchiveAction = {
|
|
1914
|
+
actionType: "sanity.action.release.unarchive",
|
|
1915
|
+
releaseId
|
|
1916
|
+
};
|
|
1917
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, unarchiveAction, options));
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* @public
|
|
1921
|
+
*
|
|
1922
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
1923
|
+
* The release is locked such that no documents in the release can be modified and
|
|
1924
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
1925
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
1926
|
+
*
|
|
1927
|
+
* @category Releases
|
|
1928
|
+
*
|
|
1929
|
+
* @param params - Release action parameters:
|
|
1930
|
+
* - `releaseId` - The id of the release to schedule.
|
|
1931
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
1932
|
+
* @param options - Additional action options.
|
|
1933
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1934
|
+
*/
|
|
1935
|
+
schedule({ releaseId, publishAt }, options) {
|
|
1936
|
+
const scheduleAction = {
|
|
1937
|
+
actionType: "sanity.action.release.schedule",
|
|
1938
|
+
releaseId,
|
|
1939
|
+
publishAt
|
|
1940
|
+
};
|
|
1941
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, scheduleAction, options));
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* @public
|
|
1945
|
+
*
|
|
1946
|
+
* An unschedule action stops a release from being published.
|
|
1947
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
1948
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
1949
|
+
* has a reference to a document created by this one.
|
|
1950
|
+
*
|
|
1951
|
+
* @category Releases
|
|
1952
|
+
*
|
|
1953
|
+
* @param params - Release action parameters:
|
|
1954
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
1955
|
+
* @param options - Additional action options.
|
|
1956
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1957
|
+
*/
|
|
1958
|
+
unschedule({ releaseId }, options) {
|
|
1959
|
+
const unscheduleAction = {
|
|
1960
|
+
actionType: "sanity.action.release.unschedule",
|
|
1961
|
+
releaseId
|
|
1962
|
+
};
|
|
1963
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, unscheduleAction, options));
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* @public
|
|
1967
|
+
*
|
|
1968
|
+
* A delete action removes a published or archived release.
|
|
1969
|
+
* The backing system document will be removed from the dataset.
|
|
1970
|
+
*
|
|
1971
|
+
* @category Releases
|
|
1972
|
+
*
|
|
1973
|
+
* @param params - Release action parameters:
|
|
1974
|
+
* - `releaseId` - The id of the release to delete.
|
|
1975
|
+
* @param options - Additional action options.
|
|
1976
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
1977
|
+
*/
|
|
1978
|
+
delete({ releaseId }, options) {
|
|
1979
|
+
const deleteAction = {
|
|
1980
|
+
actionType: "sanity.action.release.delete",
|
|
1981
|
+
releaseId
|
|
1982
|
+
};
|
|
1983
|
+
return rxjs.lastValueFrom(_action(this.#client, this.#httpRequest, deleteAction, options));
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* @public
|
|
1987
|
+
*
|
|
1988
|
+
* Fetch the documents in a release by release id.
|
|
1989
|
+
*
|
|
1990
|
+
* @category Releases
|
|
1991
|
+
*
|
|
1992
|
+
* @param params - Release action parameters:
|
|
1993
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
1994
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
1995
|
+
* @returns A promise that resolves to the documents in the release.
|
|
1996
|
+
*/
|
|
1997
|
+
fetchDocuments({ releaseId }, options) {
|
|
1998
|
+
return rxjs.lastValueFrom(_getReleaseDocuments(this.#client, this.#httpRequest, releaseId, options));
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
1440
2001
|
class ObservableUsersClient {
|
|
1441
2002
|
#client;
|
|
1442
2003
|
#httpRequest;
|
|
@@ -1482,6 +2043,7 @@ class ObservableSanityClient {
|
|
|
1482
2043
|
projects;
|
|
1483
2044
|
users;
|
|
1484
2045
|
agent;
|
|
2046
|
+
releases;
|
|
1485
2047
|
/**
|
|
1486
2048
|
* Private properties
|
|
1487
2049
|
*/
|
|
@@ -1494,7 +2056,7 @@ class ObservableSanityClient {
|
|
|
1494
2056
|
constructor(httpRequest, config = defaultConfig) {
|
|
1495
2057
|
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 = {
|
|
1496
2058
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
1497
|
-
};
|
|
2059
|
+
}, this.releases = new ObservableReleasesClient(this, this.#httpRequest);
|
|
1498
2060
|
}
|
|
1499
2061
|
/**
|
|
1500
2062
|
* Clone the client - returns a new instance
|
|
@@ -1567,9 +2129,96 @@ class ObservableSanityClient {
|
|
|
1567
2129
|
createOrReplace(document, options) {
|
|
1568
2130
|
return _createOrReplace(this, this.#httpRequest, document, options);
|
|
1569
2131
|
}
|
|
2132
|
+
createVersion({
|
|
2133
|
+
document,
|
|
2134
|
+
publishedId,
|
|
2135
|
+
releaseId
|
|
2136
|
+
}, options) {
|
|
2137
|
+
const documentVersionId = deriveDocumentVersionId("createVersion", {
|
|
2138
|
+
document,
|
|
2139
|
+
publishedId,
|
|
2140
|
+
releaseId
|
|
2141
|
+
}), documentVersion = { ...document, _id: documentVersionId }, versionPublishedId = publishedId || csm.getPublishedId(document._id);
|
|
2142
|
+
return _createVersion(
|
|
2143
|
+
this,
|
|
2144
|
+
this.#httpRequest,
|
|
2145
|
+
documentVersion,
|
|
2146
|
+
versionPublishedId,
|
|
2147
|
+
options
|
|
2148
|
+
);
|
|
2149
|
+
}
|
|
1570
2150
|
delete(selection, options) {
|
|
1571
2151
|
return _delete(this, this.#httpRequest, selection, options);
|
|
1572
2152
|
}
|
|
2153
|
+
/**
|
|
2154
|
+
* @public
|
|
2155
|
+
*
|
|
2156
|
+
* Deletes the draft or release version of a document.
|
|
2157
|
+
*
|
|
2158
|
+
* @remarks
|
|
2159
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
2160
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
2161
|
+
*
|
|
2162
|
+
* @param params - Version action parameters:
|
|
2163
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
2164
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
2165
|
+
* @param purge - if `true` the document history is also discarded.
|
|
2166
|
+
* @param options - Additional action options.
|
|
2167
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
2168
|
+
*
|
|
2169
|
+
* @example Discarding a release version of a document
|
|
2170
|
+
* ```ts
|
|
2171
|
+
* client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2172
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
2173
|
+
* ```
|
|
2174
|
+
*
|
|
2175
|
+
* @example Discarding a draft version of a document
|
|
2176
|
+
* ```ts
|
|
2177
|
+
* client.observable.discardVersion({publishedId: 'myDocument'})
|
|
2178
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
2179
|
+
* ```
|
|
2180
|
+
*/
|
|
2181
|
+
discardVersion({ releaseId, publishedId }, purge, options) {
|
|
2182
|
+
const documentVersionId = getDocumentVersionId(publishedId, releaseId);
|
|
2183
|
+
return _discardVersion(this, this.#httpRequest, documentVersionId, purge, options);
|
|
2184
|
+
}
|
|
2185
|
+
replaceVersion({
|
|
2186
|
+
document,
|
|
2187
|
+
publishedId,
|
|
2188
|
+
releaseId
|
|
2189
|
+
}, options) {
|
|
2190
|
+
const documentVersionId = deriveDocumentVersionId("replaceVersion", {
|
|
2191
|
+
document,
|
|
2192
|
+
publishedId,
|
|
2193
|
+
releaseId
|
|
2194
|
+
}), documentVersion = { ...document, _id: documentVersionId };
|
|
2195
|
+
return _replaceVersion(this, this.#httpRequest, documentVersion, options);
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* @public
|
|
2199
|
+
*
|
|
2200
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
2201
|
+
* the release is run.
|
|
2202
|
+
*
|
|
2203
|
+
* @remarks
|
|
2204
|
+
* * If the published document does not exist, an error will be thrown.
|
|
2205
|
+
*
|
|
2206
|
+
* @param params - Version action parameters:
|
|
2207
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
2208
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
2209
|
+
* @param options - Additional action options.
|
|
2210
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
2211
|
+
*
|
|
2212
|
+
* @example Unpublishing a release version of a published document
|
|
2213
|
+
* ```ts
|
|
2214
|
+
* client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2215
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
2216
|
+
* ```
|
|
2217
|
+
*/
|
|
2218
|
+
unpublishVersion({ releaseId, publishedId }, options) {
|
|
2219
|
+
const versionId = csm.getVersionId(publishedId, releaseId);
|
|
2220
|
+
return _unpublishVersion(this, this.#httpRequest, versionId, publishedId, options);
|
|
2221
|
+
}
|
|
1573
2222
|
mutate(operations, options) {
|
|
1574
2223
|
return _mutate(this, this.#httpRequest, operations, options);
|
|
1575
2224
|
}
|
|
@@ -1634,6 +2283,7 @@ class SanityClient {
|
|
|
1634
2283
|
projects;
|
|
1635
2284
|
users;
|
|
1636
2285
|
agent;
|
|
2286
|
+
releases;
|
|
1637
2287
|
/**
|
|
1638
2288
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1639
2289
|
*/
|
|
@@ -1650,7 +2300,7 @@ class SanityClient {
|
|
|
1650
2300
|
constructor(httpRequest, config = defaultConfig) {
|
|
1651
2301
|
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 = {
|
|
1652
2302
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
1653
|
-
}, this.observable = new ObservableSanityClient(httpRequest, config);
|
|
2303
|
+
}, this.releases = new ReleasesClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1654
2304
|
}
|
|
1655
2305
|
/**
|
|
1656
2306
|
* Clone the client - returns a new instance
|
|
@@ -1731,9 +2381,104 @@ class SanityClient {
|
|
|
1731
2381
|
_createOrReplace(this, this.#httpRequest, document, options)
|
|
1732
2382
|
);
|
|
1733
2383
|
}
|
|
2384
|
+
createVersion({
|
|
2385
|
+
document,
|
|
2386
|
+
publishedId,
|
|
2387
|
+
releaseId
|
|
2388
|
+
}, options) {
|
|
2389
|
+
const documentVersionId = deriveDocumentVersionId("createVersion", {
|
|
2390
|
+
document,
|
|
2391
|
+
publishedId,
|
|
2392
|
+
releaseId
|
|
2393
|
+
}), documentVersion = { ...document, _id: documentVersionId }, versionPublishedId = publishedId || csm.getPublishedId(document._id);
|
|
2394
|
+
return rxjs.firstValueFrom(
|
|
2395
|
+
_createVersion(
|
|
2396
|
+
this,
|
|
2397
|
+
this.#httpRequest,
|
|
2398
|
+
documentVersion,
|
|
2399
|
+
versionPublishedId,
|
|
2400
|
+
options
|
|
2401
|
+
)
|
|
2402
|
+
);
|
|
2403
|
+
}
|
|
1734
2404
|
delete(selection, options) {
|
|
1735
2405
|
return rxjs.lastValueFrom(_delete(this, this.#httpRequest, selection, options));
|
|
1736
2406
|
}
|
|
2407
|
+
/**
|
|
2408
|
+
* @public
|
|
2409
|
+
*
|
|
2410
|
+
* Deletes the draft or release version of a document.
|
|
2411
|
+
*
|
|
2412
|
+
* @remarks
|
|
2413
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
2414
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
2415
|
+
*
|
|
2416
|
+
* @param params - Version action parameters:
|
|
2417
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
2418
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
2419
|
+
* @param purge - if `true` the document history is also discarded.
|
|
2420
|
+
* @param options - Additional action options.
|
|
2421
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
2422
|
+
*
|
|
2423
|
+
* @example Discarding a release version of a document
|
|
2424
|
+
* ```ts
|
|
2425
|
+
* client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2426
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
2427
|
+
* ```
|
|
2428
|
+
*
|
|
2429
|
+
* @example Discarding a draft version of a document
|
|
2430
|
+
* ```ts
|
|
2431
|
+
* client.discardVersion({publishedId: 'myDocument'})
|
|
2432
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
2433
|
+
* ```
|
|
2434
|
+
*/
|
|
2435
|
+
discardVersion({ releaseId, publishedId }, purge, options) {
|
|
2436
|
+
const documentVersionId = getDocumentVersionId(publishedId, releaseId);
|
|
2437
|
+
return rxjs.lastValueFrom(
|
|
2438
|
+
_discardVersion(this, this.#httpRequest, documentVersionId, purge, options)
|
|
2439
|
+
);
|
|
2440
|
+
}
|
|
2441
|
+
replaceVersion({
|
|
2442
|
+
document,
|
|
2443
|
+
publishedId,
|
|
2444
|
+
releaseId
|
|
2445
|
+
}, options) {
|
|
2446
|
+
const documentVersionId = deriveDocumentVersionId("replaceVersion", {
|
|
2447
|
+
document,
|
|
2448
|
+
publishedId,
|
|
2449
|
+
releaseId
|
|
2450
|
+
}), documentVersion = { ...document, _id: documentVersionId };
|
|
2451
|
+
return rxjs.firstValueFrom(
|
|
2452
|
+
_replaceVersion(this, this.#httpRequest, documentVersion, options)
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
/**
|
|
2456
|
+
* @public
|
|
2457
|
+
*
|
|
2458
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
2459
|
+
* the release is run.
|
|
2460
|
+
*
|
|
2461
|
+
* @remarks
|
|
2462
|
+
* * If the published document does not exist, an error will be thrown.
|
|
2463
|
+
*
|
|
2464
|
+
* @param params - Version action parameters:
|
|
2465
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
2466
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
2467
|
+
* @param options - Additional action options.
|
|
2468
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
2469
|
+
*
|
|
2470
|
+
* @example Unpublishing a release version of a published document
|
|
2471
|
+
* ```ts
|
|
2472
|
+
* await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
2473
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
2474
|
+
* ```
|
|
2475
|
+
*/
|
|
2476
|
+
unpublishVersion({ releaseId, publishedId }, options) {
|
|
2477
|
+
const versionId = csm.getVersionId(publishedId, releaseId);
|
|
2478
|
+
return rxjs.lastValueFrom(
|
|
2479
|
+
_unpublishVersion(this, this.#httpRequest, versionId, publishedId, options)
|
|
2480
|
+
);
|
|
2481
|
+
}
|
|
1737
2482
|
mutate(operations, options) {
|
|
1738
2483
|
return rxjs.lastValueFrom(_mutate(this, this.#httpRequest, operations, options));
|
|
1739
2484
|
}
|