@dmptool/utils 1.0.7 → 1.0.9
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/maDMP.js +19 -1
- package/package.json +1 -1
package/dist/maDMP.js
CHANGED
|
@@ -348,6 +348,7 @@ const loadRelatedWorksInfo = async (rdsConnectionParams, projectId) => {
|
|
|
348
348
|
* @returns the DMP Tool Narrative extension for the DMP
|
|
349
349
|
*/
|
|
350
350
|
const loadNarrativeTemplateInfo = async (rdsConnectionParams, planId) => {
|
|
351
|
+
var _a, _b, _c, _d, _e, _f;
|
|
351
352
|
// Fetch the template, sections, questions and answers all at once
|
|
352
353
|
const sql = `
|
|
353
354
|
SELECT t.id templateId, t.name templateTitle, t.description templateDescription,
|
|
@@ -370,9 +371,16 @@ const loadNarrativeTemplateInfo = async (rdsConnectionParams, planId) => {
|
|
|
370
371
|
if (resp && Array.isArray(resp.results) && resp.results.length > 0) {
|
|
371
372
|
results = resp.results.filter((row) => !(0, general_1.isNullOrUndefined)(row));
|
|
372
373
|
}
|
|
373
|
-
if (!Array.isArray(results) || results.length === 0
|
|
374
|
+
if (!Array.isArray(results) || results.length === 0
|
|
375
|
+
|| !Array.isArray(results[0].section) || results[0].section.length === 0) {
|
|
374
376
|
return undefined;
|
|
375
377
|
}
|
|
378
|
+
rdsConnectionParams.logger.debug({
|
|
379
|
+
planId,
|
|
380
|
+
nbrRsults: results.length,
|
|
381
|
+
sectionCount: (_b = (_a = results === null || results === void 0 ? void 0 : results[0]) === null || _a === void 0 ? void 0 : _a.section) === null || _b === void 0 ? void 0 : _b.length,
|
|
382
|
+
questionCount: (_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results[0]) === null || _c === void 0 ? void 0 : _c.section) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.question) === null || _f === void 0 ? void 0 : _f.length
|
|
383
|
+
}, 'Loaded narrative information');
|
|
376
384
|
// Sort the questions by display order
|
|
377
385
|
results[0].section.forEach((section) => {
|
|
378
386
|
section.question.sort((a, b) => a.questionOrder - b.questionOrder);
|
|
@@ -387,12 +395,20 @@ const loadNarrativeTemplateInfo = async (rdsConnectionParams, planId) => {
|
|
|
387
395
|
description: results[0].templateDescription,
|
|
388
396
|
version: results[0].templateVersion,
|
|
389
397
|
section: results[0].section.map((section) => {
|
|
398
|
+
rdsConnectionParams.logger.debug({
|
|
399
|
+
sectionId: section.sectionId,
|
|
400
|
+
questionCount: section.question.length
|
|
401
|
+
}, 'Loaded narrative section information');
|
|
390
402
|
return {
|
|
391
403
|
id: section.sectionId,
|
|
392
404
|
title: section.sectionTitle,
|
|
393
405
|
description: section.sectionDescription,
|
|
394
406
|
order: section.sectionOrder,
|
|
395
407
|
question: section.question.map((question) => {
|
|
408
|
+
rdsConnectionParams.logger.debug({
|
|
409
|
+
questionId: question.questionId,
|
|
410
|
+
answerId: question.answerId
|
|
411
|
+
}, 'Loaded narrative question information');
|
|
396
412
|
return {
|
|
397
413
|
id: question.questionId,
|
|
398
414
|
order: question.questionOrder,
|
|
@@ -846,6 +862,7 @@ const validateRDACommonStandard = (logger, dmp) => {
|
|
|
846
862
|
if (validationErrors.length > 0) {
|
|
847
863
|
const msg = `Invalid RDA Common Standard: ${validationErrors.join('; ')}`;
|
|
848
864
|
logger.warn({ dmpId: (_b = (_a = dmp === null || dmp === void 0 ? void 0 : dmp.dmp) === null || _a === void 0 ? void 0 : _a.dmp_id) === null || _b === void 0 ? void 0 : _b.identifier }, msg);
|
|
865
|
+
logger.warn({ dmp: dmp === null || dmp === void 0 ? void 0 : dmp.dmp }, 'Full DMP');
|
|
849
866
|
throw new DMPValidationError(msg);
|
|
850
867
|
}
|
|
851
868
|
return dmp;
|
|
@@ -871,6 +888,7 @@ const validateDMPToolExtensions = (logger, dmpId, dmp) => {
|
|
|
871
888
|
if (validationErrors.length > 0) {
|
|
872
889
|
const msg = `Invalid DMP Tool extensions: ${validationErrors.join('; ')}`;
|
|
873
890
|
logger.warn({ dmpId }, msg);
|
|
891
|
+
logger.warn({ dmp }, 'Full DMP Tool extensions');
|
|
874
892
|
throw new DMPValidationError(msg);
|
|
875
893
|
}
|
|
876
894
|
return dmp;
|
package/package.json
CHANGED