@dmptool/utils 1.0.13 → 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 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, _e, _f;
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 = (_c = dmp === null || dmp === void 0 ? void 0 : dmp.dmp) !== null && _c !== void 0 ? _c : dmp;
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
- || ((_d = latest.dmp) === null || _d === void 0 ? void 0 : _d.tombstoned)
411
- || ((_e = latest.dmp) === null || _e === void 0 ? void 0 : _e.modified) > innerMetadata.modified) {
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((_f = latest.dmp) === null || _f === void 0 ? void 0 : _f.modified).getTime();
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/dist/maDMP.js CHANGED
@@ -574,7 +574,7 @@ const buildDMPToolExtensions = async (rdsConnectionParams, applicationName, doma
574
574
  // Define the Funder's project number if applicable. project_id and funder_id
575
575
  // are used to help tie the project_identifier to the correct
576
576
  // project[?].funding[?] in the RDA Common Standard.
577
- if (funding.funderProjectNumber !== undefined) {
577
+ if (funding.funderProjectNumber) {
578
578
  funderProject = {
579
579
  project_id: projectId,
580
580
  funder_id: funderId,
@@ -589,7 +589,7 @@ const buildDMPToolExtensions = async (rdsConnectionParams, applicationName, doma
589
589
  // Define the Funder's opportunity number if applicable. project_id and
590
590
  // funder_id are used to help tie the opportunity_identifier to the correct
591
591
  // project[?].funding[?] in the RDA Common Standard.
592
- if (funding.funderOpportunityNumber !== undefined) {
592
+ if (funding.funderOpportunityNumber) {
593
593
  funderOpportunity = {
594
594
  project_id: projectId,
595
595
  funder_id: funderId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmptool/utils",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Helper/Utility functions for use in the DMP Tool services. Particularly AWS tooling and maDMP serialization",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",