getDocumentVersions

The getDocumentVersions method enables version control and returns a list of document versions.

Return Value

Promise<{ versions: DocumentVersion[] }>

See DocumentVersion for details.

This method takes a document ID and should return an array of DocumentVersion objects for that document.

It is not required that a document object be attached to each version. Some content sources only list versions in the API response and it is not necessary to query again for the document. Instead, when a version is selected, the getDocumentForVersion method is called to retrieve the document for the selected version.

Parameters

documentId

string

ID value of the document you need versions for

Example

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
async function getDocumentVersions({
  documentId,
}: {
  documentId: string
}): Promise<{ versions: DocumentVersion[] }> {
  this.logger.debug('getDocumentVersions', { documentId })
  const versions = await fetchEntityVersions(this.plainClient, {
    environment: this.environment,
    entityId: documentId,
  })
  return { versions: this.convertVersions(versions.items) }
}