Common libraries and shared code used across Transfer Digital Records (TDR) services.
This is a multi-module sbt project written in Scala 2.13. It provides reusable utilities that are published to Maven Central under the uk.gov.nationalarchives organisation for consumption by other TDR services.
| Module | Artifact | Description |
|---|---|---|
| authorisation | tdr-authorisation |
Authorisation logic for TDR transfers |
| objectkeycontext | tdr-object-key-context |
S3 object key parsing and context extraction |
| serviceinputs | tdr-service-inputs |
Input models for triggering TDR services |
| statuses | tdr-statuses |
Status type and value definitions for TDR workflows |
Provides a generic Authorisation trait and a concrete ConsignmentAuthorisation implementation that checks whether a user has access to a given consignment via the TDR GraphQL API.
Key types:
Authorisation[T]— trait defininghasAccess(input: T): IO[AuthorisationResult]ConsignmentAuthorisation— checks consignment access using the TDR GraphQL clientAuthorisationResult— sealed trait withAllow/Denycase objects
Dependencies: Cats Effect, TDR GraphQL Client, TDR Auth Utils
Parses AWS S3 object keys into structured context objects. Supports two key formats:
- Default key:
{consignmentId}/{object} - Upload key:
{userId}/{assetSource}/{consignmentId}/{objectCategory}/{object}
Key types:
ObjectKeyContext— case class containing parsed key fields (userId,transferId,assetSource,category,objectType,objectName)ObjectTypes—Csv,Error,Metadata,RecordObjectCategories—DryRunMetadata,Metadata,RecordsAssetSources—Droid,HardDrive,NetworkDrive,SharePoint
Defines case classes for inputs used to trigger TDR backend services (e.g. Step Functions), with Circe JSON encoders.
Key types:
BackendChecksInput— triggers backend file checks (consignmentId,s3SourceBucketPrefix)ExportInput— triggers export (consignmentId)MetadataValidationInput— triggers metadata validation (consignmentId,fileName)
Dependencies: Circe Core, Circe Generic
Defines the status types and values used throughout the TDR workflow.
Status types: Series, Upload, TransferAgreement, ClientChecks, ServerAntivirus, ServerChecksum, ServerFFID, ServerRedaction, ConfirmTransfer, Export, DraftMetadata, MetadataReview, DraftMetadataUpload
Status values: Completed, CompletedWithIssues, InProgress, Failed
Metadata review statuses: Requested, Rejected, Approved, Transferred
The MetadataReviewStatus object provides a dedicated enum for metadata review workflow states:
import uk.gov.nationalarchives.tdr.common.utils.statuses.MetadataReviewStatus
MetadataReviewStatus.Requested.value // "Requested"
MetadataReviewStatus.Rejected.value // "Rejected"
MetadataReviewStatus.Approved.value // "Approved"
MetadataReviewStatus.Transferred.value // "Transferred"
// Parse from a string:
MetadataReviewStatus.MetadataReviewStatus("Approved")Metadata review log actions: Submission, Rejection, Approval, Confirmation
The MetadataReviewLogAction object provides an enum for metadata review log actions. Each action has a reviewStatus field that links it to the corresponding MetadataReviewStatus:
| Action | reviewStatus |
|---|---|
Submission |
MetadataReviewStatus.Requested |
Rejection |
MetadataReviewStatus.Rejected |
Approval |
MetadataReviewStatus.Approved |
Confirmation |
MetadataReviewStatus.Transferred |
import uk.gov.nationalarchives.tdr.common.utils.statuses.MetadataReviewLogAction
val action = MetadataReviewLogAction.MetadataReviewLogAction("Submission")
action.value // "Submission"
action.reviewStatus // MetadataReviewStatus.Requested
action.reviewStatus.value // "Requested"- Java 11+
- sbt 1.11.7+ (defined in
project/build.properties)
sbt compilesbt testTo create a snapshot version locally for use with local development:
sbt publishLocalThe snapshot version can then be imported into local development environments.
Add the relevant module as a dependency in your build.sbt:
libraryDependencies += "uk.gov.nationalarchives" %% "tdr-authorisation" % "<version>"
libraryDependencies += "uk.gov.nationalarchives" %% "tdr-object-key-context" % "<version>"
libraryDependencies += "uk.gov.nationalarchives" %% "tdr-service-inputs" % "<version>"
libraryDependencies += "uk.gov.nationalarchives" %% "tdr-statuses" % "<version>"Releases are automated via GitHub Actions. When a pull request is merged to main, the pipeline will:
- Check for snapshot dependencies
- Clean and run tests
- Set and commit the release version
- Tag the release
- Publish signed artefacts
- Release to Maven Central via Sonatype
- Set and commit the next snapshot version
- Push changes
This project is licensed under the MIT License.