@dmptool/utils 1.0.10 → 1.0.12

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.
Files changed (2) hide show
  1. package/dist/maDMP.js +8 -10
  2. package/package.json +1 -1
package/dist/maDMP.js CHANGED
@@ -116,7 +116,7 @@ const loadDefaultMemberRole = async (rdsConnectionParams) => {
116
116
  rdsConnectionParams.logger.debug({ sql }, 'Fetching default role');
117
117
  const resp = await (0, rds_1.queryTable)(rdsConnectionParams, sql, []);
118
118
  if (resp && Array.isArray(resp.results) && resp.results.length > 0) {
119
- return resp.results[0].id;
119
+ return resp.results[0].uri;
120
120
  }
121
121
  return undefined;
122
122
  };
@@ -312,19 +312,19 @@ const loadDatasetInfo = async (rdsConnectionParams, applicationName, projectId,
312
312
  * Builds the RDA Common Standard Related Identifier entries for the DMP
313
313
  *
314
314
  * @param rdsConnectionParams the connection parameters for the MySQL database
315
- * @param projectId the Project ID to fetch the Related Works information for
315
+ * @param planId the Plan ID to fetch the Related Works information for
316
316
  * @returns the RDA Common Standard Related Identifier entries for the DMP
317
317
  */
318
- const loadRelatedWorksInfo = async (rdsConnectionParams, projectId) => {
318
+ const loadRelatedWorksInfo = async (rdsConnectionParams, planId) => {
319
319
  const sql = `
320
320
  SELECT w.doi AS identifier, LOWER(wv.workType) AS workType
321
321
  FROM relatedWorks rw
322
322
  JOIN workVersions wv ON rw.workVersionId = wv.id
323
323
  JOIN works w ON wv.workId = w.id
324
- WHERE rw.projectId = ?;
324
+ WHERE rw.planId = ?;
325
325
  `;
326
- rdsConnectionParams.logger.debug({ projectId, sql }, 'Fetching related works information');
327
- const resp = await (0, rds_1.queryTable)(rdsConnectionParams, sql, [projectId.toString()]);
326
+ rdsConnectionParams.logger.debug({ planId, sql }, 'Fetching related works information');
327
+ const resp = await (0, rds_1.queryTable)(rdsConnectionParams, sql, [planId.toString()]);
328
328
  if (resp && Array.isArray(resp.results) && resp.results.length > 0) {
329
329
  const works = resp.results.filter((row) => !(0, general_1.isNullOrUndefined)(row));
330
330
  // Determine the identifier types
@@ -488,9 +488,7 @@ const buildContributors = (applicationName, env, planId, projectId, members, def
488
488
  }
489
489
  return members.map((member) => {
490
490
  // Make sure that we always have roles as an array
491
- const roles = member.roles && member.roles.includes('[')
492
- ? JSON.parse(member.roles)
493
- : [defaultRole];
491
+ const roles = member.roles ? JSON.parse(member.roles) : [defaultRole];
494
492
  // Combine the member's given name and surname into a single name'
495
493
  const contrib = {
496
494
  name: [member.givenName, member.surName]
@@ -974,7 +972,7 @@ async function planToDMPCommonStandard(rdsConnectionParams, applicationName, dom
974
972
  // We only allow one funding per plan at this time
975
973
  const fundings = await loadFundingInfo(rdsConnectionParams, plan.id);
976
974
  const funding = fundings.length > 0 ? fundings[0] : undefined;
977
- const works = await loadRelatedWorksInfo(rdsConnectionParams, plan.projectId);
975
+ const works = await loadRelatedWorksInfo(rdsConnectionParams, plan.id);
978
976
  const defaultRole = await loadDefaultMemberRole(rdsConnectionParams);
979
977
  // If the plan is registered, use the DOI as the identifier, otherwise convert to a URL
980
978
  const dmpId = plan.registered
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmptool/utils",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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",