Sanity Library Reference Docs
    Preparing search index...
    Index

    Constructors

    Methods - Releases

    • 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 Observable<ReleaseDocument | undefined>

      An observable that resolves to the release document ReleaseDocument.

      client.observable.releases.get({releaseId: 'my-release'}).pipe(
      tap((release) => console.log(release)),
      // {
      // _id: '_.releases.my-release',
      // name: 'my-release'
      // _type: 'system.release',
      // metadata: {releaseType: 'asap'},
      // _createdAt: '2021-01-01T00:00:00.000Z',
      // ...
      // }
      ).subscribe()
    • Creates a new release under the given id, with metadata.

      Parameters

      • options: BaseActionOptions

        Additional action options.

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

      An observable 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 = 'my-release'
      const metadata: ReleaseDocument['metadata'] = {
      releaseType: 'asap',
      }

      client.observable.releases.create({releaseId, metadata}).pipe(
      tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
      // {
      // transactionId: 'transaction-id',
      // releaseId: 'my-release',
      // metadata: {releaseType: 'asap'},
      // }
      ).subscribe()
      client.observable.releases.create().pipe(
      tap(({metadata}) => console.log(metadata)),
      // {
      // metadata: {releaseType: 'undecided'},
      // }
      ).subscribe()
      client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
      tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
      // {
      // transactionId: 'my-transaction-id',
      // metadata: {releaseType: 'undecided'},
      // }
      ).subscribe()
    • Creates a new release under the given id, with metadata.

      Parameters

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

        Additional action options.

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

      An observable 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 = 'my-release'
      const metadata: ReleaseDocument['metadata'] = {
      releaseType: 'asap',
      }

      client.observable.releases.create({releaseId, metadata}).pipe(
      tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
      // {
      // transactionId: 'transaction-id',
      // releaseId: 'my-release',
      // metadata: {releaseType: 'asap'},
      // }
      ).subscribe()
      client.observable.releases.create().pipe(
      tap(({metadata}) => console.log(metadata)),
      // {
      // metadata: {releaseType: 'undecided'},
      // }
      ).subscribe()
      client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
      tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
      // {
      // transactionId: 'my-transaction-id',
      // metadata: {releaseType: 'undecided'},
      // }
      ).subscribe()
    • Edits an existing release, updating the metadata.

      Parameters

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

        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 Observable<SingleActionResult>

      An observable that resolves to the transactionId.

    • 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 Observable<SingleActionResult>

      An observable that resolves to the transactionId.

    • 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 Observable<SingleActionResult>

      An observable 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 Observable<SingleActionResult>

      An observable 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: { releaseId: string; publishAt: 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 Observable<SingleActionResult>

      An observable 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 Observable<SingleActionResult>

      An observable that resolves to the transactionId.

    • 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 Observable<SingleActionResult>

      An observable that resolves to the transactionId.

    • Fetch the documents in a release by release id.

      Parameters

      • params: { releaseId: string }

        Release action parameters:

        • releaseId - The id of the release to fetch documents for.
      • Optionaloptions: BaseMutationOptions

        Additional mutation options BaseMutationOptions.

      Returns Observable<RawQueryResponse<SanityDocument[]>>

      An observable that resolves to the documents in the release.