@measurequick/measurequick-report-generator 1.5.205 → 1.5.207

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measurequick/measurequick-report-generator",
3
- "version": "1.5.205",
3
+ "version": "1.5.207",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,7 @@
1
1
  import * as base64 from "../base-64/icons.js";
2
+ import { PDFDocument } from "pdf-lib";
3
+ import * as notesSummaryPage from "./notes-summary-page.js";
4
+ import * as util from "../util.js";
2
5
 
3
6
  let doc,
4
7
  globalVars,
@@ -1595,7 +1598,7 @@ export async function getReport(payload) {
1595
1598
  testo_size,
1596
1599
  testo_size
1597
1600
  );
1598
- } else if (testObj.source["voltage" + src] == "iDVM550") {
1601
+ } else if (testObj.source["voltage" + src] == "iDVM550" || testObj.source["voltage" + src] == "iDVM-550") {
1599
1602
  doc.addImage(
1600
1603
  base64.iconRedfish550,
1601
1604
  "PNG",
@@ -1649,7 +1652,7 @@ export async function getReport(payload) {
1649
1652
  testo_size,
1650
1653
  testo_size
1651
1654
  );
1652
- } else if (testObj.source["amperage" + src] == "iDVM550") {
1655
+ } else if (testObj.source["amperage" + src] == "iDVM550" || testObj.source["amperage" + src] == "iDVM-550") {
1653
1656
  doc.addImage(
1654
1657
  base64.iconRedfish550,
1655
1658
  "PNG",
@@ -1704,7 +1707,7 @@ export async function getReport(payload) {
1704
1707
  testo_size,
1705
1708
  testo_size
1706
1709
  );
1707
- } else if (testObj.source.power_factor == "iDVM550") {
1710
+ } else if (testObj.source.power_factor == "iDVM550" || testObj.source.power_factor == "iDVM-550") {
1708
1711
  doc.addImage(
1709
1712
  base64.iconRedfish550,
1710
1713
  "PNG",
@@ -1751,7 +1754,7 @@ export async function getReport(payload) {
1751
1754
  testo_size,
1752
1755
  testo_size
1753
1756
  );
1754
- } else if (testObj.source.power_condenser == "iDVM550") {
1757
+ } else if (testObj.source.power_condenser == "iDVM550" || testObj.source.power_condenser == "iDVM-550") {
1755
1758
  doc.addImage(
1756
1759
  base64.iconRedfish550,
1757
1760
  "PNG",
@@ -2421,7 +2424,7 @@ export async function getReport(payload) {
2421
2424
  text = vd;
2422
2425
  position = alignRight(text, pos_right, 8);
2423
2426
  doc.text(text, position, pos_vert); //page width,page height
2424
- if (testObj.source.voltage_l1_ahu == "iDVM550") {
2427
+ if (testObj.source.voltage_l1_ahu == "iDVM550" || testObj.source.voltage_l1_ahu == "iDVM-550") {
2425
2428
  doc.addImage(
2426
2429
  base64.iconRedfish550,
2427
2430
  "PNG",
@@ -2475,7 +2478,7 @@ export async function getReport(payload) {
2475
2478
  text = ad;
2476
2479
  position = alignRight(text, pos_right, 8);
2477
2480
  doc.text(text, position, pos_vert); //page width,page height
2478
- if (testObj.source.amperage_l1_ahu == "iDVM550") {
2481
+ if (testObj.source.amperage_l1_ahu == "iDVM550" || testObj.source.amperage_l1_ahu == "iDVM-550") {
2479
2482
  doc.addImage(
2480
2483
  base64.iconRedfish550,
2481
2484
  "PNG",
@@ -2530,7 +2533,7 @@ export async function getReport(payload) {
2530
2533
  : "--";
2531
2534
  position = alignRight(text, pos_right, 8);
2532
2535
  doc.text(text, position, pos_vert); //page width,page height
2533
- if (testObj.source.power_factor_ahu == "iDVM550") {
2536
+ if (testObj.source.power_factor_ahu == "iDVM550" || testObj.source.power_factor_ahu == "iDVM-550") {
2534
2537
  doc.addImage(
2535
2538
  base64.iconRedfish550,
2536
2539
  "PNG",
@@ -2586,7 +2589,7 @@ export async function getReport(payload) {
2586
2589
  testo_size,
2587
2590
  testo_size
2588
2591
  );
2589
- } else if (testObj.source.power_ahu == "iDVM550") {
2592
+ } else if (testObj.source.power_ahu == "iDVM550" || testObj.source.power_ahu == "iDVM-550") {
2590
2593
  doc.addImage(
2591
2594
  base64.iconRedfish550,
2592
2595
  "PNG",
@@ -7065,7 +7068,33 @@ export async function getReport(payload) {
7065
7068
  );
7066
7069
  }
7067
7070
 
7068
- return { status: 200, data: await doc.output("datauristring") };
7071
+ // Get jsPDF output as base64
7072
+ const jsPdfOutput = await doc.output("datauristring");
7073
+
7074
+ // Add AI summary pages if available
7075
+ const aiSummary = util.getAiSummary ? util.getAiSummary(payload) : null;
7076
+ const notes = util.getAiNotes ? util.getAiNotes(payload) : null;
7077
+
7078
+ if (aiSummary || notes) {
7079
+ try {
7080
+ // Convert jsPDF output to pdf-lib format
7081
+ const base64Data = jsPdfOutput.split(",")[1];
7082
+ const pdfBytes = util._base64ToArrayBuffer(base64Data);
7083
+ const pdfDoc = await PDFDocument.load(pdfBytes);
7084
+
7085
+ // Add AI summary pages
7086
+ await notesSummaryPage.addNotesSummaryPages(pdfDoc, payload);
7087
+
7088
+ // Return combined PDF
7089
+ return { status: 200, data: await pdfDoc.saveAsBase64({ dataUri: true }) };
7090
+ } catch (aiError) {
7091
+ // If AI summary fails, return original PDF without it
7092
+ console.error("Failed to add AI summary pages:", aiError);
7093
+ return { status: 200, data: jsPdfOutput };
7094
+ }
7095
+ }
7096
+
7097
+ return { status: 200, data: jsPdfOutput };
7069
7098
  } catch (error) {
7070
7099
  return { status: 400, data: error };
7071
7100
  }
@@ -7135,6 +7164,7 @@ function drawManufacturerIcon(field) {
7135
7164
  case "iDVM510":
7136
7165
  return base64.iconRedfish510;
7137
7166
  case "iDVM550":
7167
+ case "iDVM-550":
7138
7168
  return base64.iconRedfish550;
7139
7169
  case "VOLT-100":
7140
7170
  return base64.iconVolt100;
package/util.js CHANGED
@@ -164,10 +164,22 @@ export function capitalizeFirstLetter(string) {
164
164
 
165
165
  export function getToolIcon(test, ref, embeddedIcons) {
166
166
  let toolIcon;
167
+ // Get source value, with fallback for L2/L3 to use L1 source (3-phase systems often only set L1 source)
168
+ let sourceValue = test.source[ref];
169
+ if (!sourceValue && ref) {
170
+ // Try L1 fallback for L2/L3 measurements
171
+ if (ref.includes("_l2") || ref.includes("_l3")) {
172
+ const l1Ref = ref.replace(/_l[23]/, "_l1");
173
+ sourceValue = test.source[l1Ref];
174
+ } else if (ref.includes("_l2_") || ref.includes("_l3_")) {
175
+ const l1Ref = ref.replace(/_l[23]_/, "_l1_");
176
+ sourceValue = test.source[l1Ref];
177
+ }
178
+ }
167
179
  if (test.data.calculated && test.data.calculated[ref])
168
180
  toolIcon = embeddedIcons.iconCalculator;
169
181
  else {
170
- switch (test.source[ref]) {
182
+ switch (sourceValue) {
171
183
  case "Testo":
172
184
  toolIcon = embeddedIcons.iconTesto;
173
185
  break;
@@ -209,6 +221,7 @@ export function getToolIcon(test, ref, embeddedIcons) {
209
221
  toolIcon = embeddedIcons.iconRedfish510;
210
222
  break;
211
223
  case "iDVM550":
224
+ case "iDVM-550":
212
225
  toolIcon = embeddedIcons.iconRedfish550;
213
226
  break;
214
227
  case "VOLT-100":
@@ -237,7 +250,7 @@ export function getToolIcon(test, ref, embeddedIcons) {
237
250
  break;
238
251
  }
239
252
  }
240
- if (test.source[ref] == "iDVM510" && ref.includes("amperage"))
253
+ if (sourceValue == "iDVM510" && ref.includes("amperage"))
241
254
  toolIcon = embeddedIcons.iconRedfish510333;
242
255
  return toolIcon;
243
256
  }
@@ -354,7 +367,7 @@ export function getElectricalData(test, suffix, embeddedIcons) {
354
367
  if (vDisplay) {
355
368
  if (test.source["voltage" + src] == "ComfortGuard")
356
369
  vIcon = embeddedIcons.iconSensi;
357
- else if (test.source["voltage" + src] == "iDVM550")
370
+ else if (test.source["voltage" + src] == "iDVM550" || test.source["voltage" + src] == "iDVM-550")
358
371
  vIcon = embeddedIcons.iconRedfish550;
359
372
  else if (test.source["voltage" + src] == "VOLT-100")
360
373
  vIcon = embeddedIcons.iconVolt100;
@@ -366,7 +379,7 @@ export function getElectricalData(test, suffix, embeddedIcons) {
366
379
  if (aDisplay) {
367
380
  if (test.source["amperage" + src] == "ComfortGuard")
368
381
  aIcon = embeddedIcons.iconSensi;
369
- else if (test.source["amperage" + src] == "iDVM550")
382
+ else if (test.source["amperage" + src] == "iDVM550" || test.source["amperage" + src] == "iDVM-550")
370
383
  aIcon = embeddedIcons.iconRedfish550;
371
384
  else if (test.source["amperage" + src] == "VOLT-100")
372
385
  aIcon = embeddedIcons.iconVolt100;