@measurequick/measurequick-report-generator 1.5.206 → 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 +1 -1
- package/report-gen-scripts/classic-report.js +30 -1
- package/util.js +14 -2
package/package.json
CHANGED
|
@@ -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,
|
|
@@ -7065,7 +7068,33 @@ export async function getReport(payload) {
|
|
|
7065
7068
|
);
|
|
7066
7069
|
}
|
|
7067
7070
|
|
|
7068
|
-
|
|
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
|
}
|
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 (
|
|
182
|
+
switch (sourceValue) {
|
|
171
183
|
case "Testo":
|
|
172
184
|
toolIcon = embeddedIcons.iconTesto;
|
|
173
185
|
break;
|
|
@@ -238,7 +250,7 @@ export function getToolIcon(test, ref, embeddedIcons) {
|
|
|
238
250
|
break;
|
|
239
251
|
}
|
|
240
252
|
}
|
|
241
|
-
if (
|
|
253
|
+
if (sourceValue == "iDVM510" && ref.includes("amperage"))
|
|
242
254
|
toolIcon = embeddedIcons.iconRedfish510333;
|
|
243
255
|
return toolIcon;
|
|
244
256
|
}
|