@dmptool/utils 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dynamo.d.ts +2 -1
- package/dist/dynamo.js +7 -7
- package/package.json +1 -1
package/dist/dynamo.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export declare const createDMP: (dynamoConnectionParams: DynamoConnectionParams,
|
|
|
85
85
|
*
|
|
86
86
|
* @param dynamoConnectionParams the DynamoDB connection parameters
|
|
87
87
|
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
88
|
+
* @param dmpId the DMP ID (e.g. 'doi.org/11.12345/A1B2C3D4')
|
|
88
89
|
* @param dmp The DMP metadata record to persist as either an RDA Common Standard
|
|
89
90
|
* or the standard with DMP Tool specific extensions.
|
|
90
91
|
* @param gracePeriodInMS The grace period in milliseconds to wait before creating
|
|
@@ -94,7 +95,7 @@ export declare const createDMP: (dynamoConnectionParams: DynamoConnectionParams,
|
|
|
94
95
|
* metadata record with the DMP Tool specific extensions merged in.
|
|
95
96
|
* @throws DMPToolDynamoError if the record could not be persisted
|
|
96
97
|
*/
|
|
97
|
-
export declare const updateDMP: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmp: DMPToolDMPType, gracePeriodInMS?: number, // 2 hours in milliseconds
|
|
98
|
+
export declare const updateDMP: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmpId: string, dmp: DMPToolDMPType, gracePeriodInMS?: number, // 2 hours in milliseconds
|
|
98
99
|
includeExtensions?: boolean) => Promise<DMPToolDMPType>;
|
|
99
100
|
/**
|
|
100
101
|
* Create a Tombstone for the specified DMP metadata record
|
package/dist/dynamo.js
CHANGED
|
@@ -378,6 +378,7 @@ const createDMPExtensions = async (dynamoConnectionParams, dmpId, dmp, version =
|
|
|
378
378
|
*
|
|
379
379
|
* @param dynamoConnectionParams the DynamoDB connection parameters
|
|
380
380
|
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
381
|
+
* @param dmpId the DMP ID (e.g. 'doi.org/11.12345/A1B2C3D4')
|
|
381
382
|
* @param dmp The DMP metadata record to persist as either an RDA Common Standard
|
|
382
383
|
* or the standard with DMP Tool specific extensions.
|
|
383
384
|
* @param gracePeriodInMS The grace period in milliseconds to wait before creating
|
|
@@ -387,16 +388,15 @@ const createDMPExtensions = async (dynamoConnectionParams, dmpId, dmp, version =
|
|
|
387
388
|
* metadata record with the DMP Tool specific extensions merged in.
|
|
388
389
|
* @throws DMPToolDynamoError if the record could not be persisted
|
|
389
390
|
*/
|
|
390
|
-
const updateDMP = async (dynamoConnectionParams, domainName, dmp, gracePeriodInMS = 7200000, // 2 hours in milliseconds
|
|
391
|
+
const updateDMP = async (dynamoConnectionParams, domainName, dmpId, dmp, gracePeriodInMS = 7200000, // 2 hours in milliseconds
|
|
391
392
|
includeExtensions = true) => {
|
|
392
|
-
var _a, _b, _c, _d
|
|
393
|
-
const dmpId = (_b = (_a = dmp.dmp) === null || _a === void 0 ? void 0 : _a.dmp_id) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
393
|
+
var _a, _b, _c, _d;
|
|
394
394
|
if (!dynamoConnectionParams || !dmp || !dmpId) {
|
|
395
395
|
throw new DMPToolDynamoError('Missing Dynamo config, DMP ID or DMP metadata record');
|
|
396
396
|
}
|
|
397
397
|
try {
|
|
398
398
|
// If the metadata is nested in a top level 'dmp' property, then unwrap it
|
|
399
|
-
const innerMetadata = (
|
|
399
|
+
const innerMetadata = (_a = dmp === null || dmp === void 0 ? void 0 : dmp.dmp) !== null && _a !== void 0 ? _a : dmp;
|
|
400
400
|
// Separate the RDA Common Standard metadata from the DMP Tool specific extensions
|
|
401
401
|
const dmptoolExtension = pick(innerMetadata, [...EXTENSION_KEYS]);
|
|
402
402
|
const rdaCommonStandard = pick(innerMetadata, Object.keys(innerMetadata).filter(k => !EXTENSION_KEYS.includes(k)));
|
|
@@ -407,11 +407,11 @@ includeExtensions = true) => {
|
|
|
407
407
|
// Or if the incoming modified timestamp is newer than the latest version's
|
|
408
408
|
// modified timestamp (collision)
|
|
409
409
|
if ((0, general_1.isNullOrUndefined)(latest)
|
|
410
|
-
|| ((
|
|
411
|
-
|| ((
|
|
410
|
+
|| ((_b = latest.dmp) === null || _b === void 0 ? void 0 : _b.tombstoned)
|
|
411
|
+
|| ((_c = latest.dmp) === null || _c === void 0 ? void 0 : _c.modified) > innerMetadata.modified) {
|
|
412
412
|
throw new DMPToolDynamoError(`Cannot update a historical DMP id: ${dmpId}, ver: ${exports.DMP_LATEST_VERSION}`);
|
|
413
413
|
}
|
|
414
|
-
const lastModified = new Date((
|
|
414
|
+
const lastModified = new Date((_d = latest.dmp) === null || _d === void 0 ? void 0 : _d.modified).getTime();
|
|
415
415
|
const now = Date.now();
|
|
416
416
|
const gracePeriod = gracePeriodInMS ? Number(gracePeriodInMS) : 7200000;
|
|
417
417
|
// We need to version the DMP if the provenance doesn't match or the modified
|
package/package.json
CHANGED