@dmptool/utils 1.0.7 → 1.0.8

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 +17 -1
  2. 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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmptool/utils",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
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",