Sanity Library Reference Docs
    Preparing search index...

    Class ReleasesClient

    Index

    Other

    Releases

    • An archive action removes an active release. The documents that comprise the release are deleted and therefore no longer queryable.

      While the documents remain in retention the last version can still be accessed using document history endpoint.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to archive.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.

    • Creates a new release and generates an id and metadata.

      Parameters

      Returns Promise<
          SingleActionResult & {
              metadata: {
                  description?: string;
                  intendedPublishAt?: string;
                  releaseType: ReleaseType;
                  title?: string;
              };
              releaseId: string;
          },
      >

      A promise that resolves to the transactionId and the release id and metadata.

      • If no releaseId is provided, a release id will be generated.
      • If no metadata is provided, then an undecided releaseType will be used.
      const {releaseId, metadata} = await client.releases.create()
      console.log(releaseId) // 'my-release'
      console.log(metadata.releaseType) // 'undecided'
    • Creates a new release under the given id and metadata.

      Parameters

      • release: {
            metadata?: Partial<
                {
                    description?: string;
                    intendedPublishAt?: string;
                    releaseType: ReleaseType;
                    title?: string;
                },
            >;
            releaseId?: string;
        }

        Release action parameters:

        • releaseId (optional) - The id of the release to create.
        • metadata (optional) - The metadata to associate with the release ReleaseDocument.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<
          SingleActionResult & {
              metadata: {
                  description?: string;
                  intendedPublishAt?: string;
                  releaseType: ReleaseType;
                  title?: string;
              };
              releaseId: string;
          },
      >

      A promise that resolves to the transactionId and the release id and metadata.

      const releaseId = 'my-release'
      const releaseMetadata: ReleaseDocument['metadata'] = {
      releaseType: 'asap',
      }

      const result =
      await client.releases.create({releaseId, metadata: releaseMetadata})
      console.log(result)
      // {
      // transactionId: 'transaction-id',
      // releaseId: 'my-release',
      // metadata: {releaseType: 'asap'},
      // }
    • A delete action removes a published or archived release. The backing system document will be removed from the dataset.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to delete.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.

    • Edits an existing release, updating the metadata.

      Parameters

      • params: { patch: PatchOperations; releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to edit.
        • patch - The patch operation to apply on the release metadata PatchMutationOperation.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.

    • Retrieve a release by id.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to retrieve.
      • Optionaloptions: { signal?: AbortSignal; tag?: string }

        Additional query options including abort signal and query tag.

      Returns Promise<undefined | ReleaseDocument>

      A promise that resolves to the release document ReleaseDocument.

      const release = await client.releases.get({releaseId: 'my-release'})
      console.log(release)
      // {
      // _id: '_.releases.my-release',
      // name: 'my-release'
      // _type: 'system.release',
      // metadata: {releaseType: 'asap'},
      // _createdAt: '2021-01-01T00:00:00.000Z',
      // ...
      // }
    • Publishes all documents in a release at once. For larger releases the effect of the publish will be visible immediately when querying but the removal of the versions.<releasesId>.* documents and creation of the corresponding published documents with the new content may take some time.

      During this period both the source and target documents are locked and cannot be modified through any other means.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to publish.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.

    • A schedule action queues a release for publishing at the given future time. The release is locked such that no documents in the release can be modified and no documents that it references can be deleted as this would make the publish fail. At the given time, the same logic as for the publish action is triggered.

      Parameters

      • params: { publishAt: string; releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to schedule.
        • publishAt - The serialised date and time to publish the release. If the publishAt is in the past, the release will be published immediately.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.

    • An unarchive action restores an archived release and all documents with the content they had just prior to archiving.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to unarchive.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.

    • An unschedule action stops a release from being published. The documents in the release are considered unlocked and can be edited again. This may fail if another release is scheduled to be published after this one and has a reference to a document created by this one.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to unschedule.
      • Optionaloptions: BaseActionOptions

        Additional action options.

      Returns Promise<SingleActionResult>

      A promise that resolves to the transactionId.