Remove the versioning logic from the dmp_updater.rb in the Lambda layer and into its own dmp_versioner.rb.
This new file should have 2 methods.
new_version(dmp:) - Input should be the JSON of the latest version of the DMP:
Clone the latest version.
Update the clone's SK and add a {"descriptor": "is_previous_version_of", "work_type": "output_management_plan", "type": "doi", "identifier": "https://doi.org/10.12345/ABC123"} to the dmproadmap_related_identifiers
Save the new Clone to Dynamo
versions(PK:) - Input should be the DMP ID as a PK string (e.g. DMP#doi.org/10.12345/ABC123)
Query the index to fetch the version Sis
Return the versions as and array of dates (sorted Desc) and URLs (e.g. [{"timestamp":"2022-10-05T11:12:13+00:00", "url": "https://my.domain.edu/api/v0/dmps/10.12345/ABC123?version=2022-10-05T11:35:21+00:00"}])
Modify the getDmp Lambda function to call versions and append the results to a dmphub_versions section of the root of the DMP JSON.
Remove the versioning logic from the
dmp_updater.rb
in the Lambda layer and into its owndmp_versioner.rb
.This new file should have 2 methods.
new_version(dmp:)
- Input should be the JSON of the latest version of the DMP:SK
and add a{"descriptor": "is_previous_version_of", "work_type": "output_management_plan", "type": "doi", "identifier": "https://doi.org/10.12345/ABC123"}
to thedmproadmap_related_identifiers
versions(PK:)
- Input should be the DMP ID as a PK string (e.g.DMP#doi.org/10.12345/ABC123
)[{"timestamp":"2022-10-05T11:12:13+00:00", "url": "https://my.domain.edu/api/v0/dmps/10.12345/ABC123?version=2022-10-05T11:35:21+00:00"}]
)Modify the getDmp Lambda function to call
versions
and append the results to admphub_versions
section of the root of the DMP JSON.