@raytio/decrypt-helper 6.2.0 → 6.3.0
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/README.md +2 -2
- package/dist/api/authedFetch.js +1 -5
- package/dist/api/fetchAA.d.ts +2 -2
- package/dist/api/fetchAA.js +3 -7
- package/dist/api/fetchEnvConfig.js +2 -6
- package/dist/api/fetchInstanceData.d.ts +3 -3
- package/dist/api/fetchInstanceData.js +3 -8
- package/dist/api/getFiles.d.ts +2 -2
- package/dist/api/getFiles.js +59 -26
- package/dist/api/getLookupOption.d.ts +1 -1
- package/dist/api/getLookupOption.js +3 -7
- package/dist/api/getSchema.d.ts +1 -1
- package/dist/api/getSchema.js +5 -9
- package/dist/api/index.js +9 -25
- package/dist/api/resolveVerificationDetails.d.ts +1 -1
- package/dist/api/resolveVerificationDetails.js +2 -7
- package/dist/api/signIn.d.ts +2 -2
- package/dist/api/signIn.js +10 -14
- package/dist/api/updateInstanceData.d.ts +7 -2
- package/dist/api/updateInstanceData.js +7 -7
- package/dist/api/uploadToObjectStore.d.ts +1 -1
- package/dist/api/uploadToObjectStore.js +3 -7
- package/dist/api/videoToImage.d.ts +1 -1
- package/dist/api/videoToImage.js +5 -9
- package/dist/configureEnv.js +3 -29
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +20 -23
- package/dist/helpers/file.d.ts +4 -0
- package/dist/helpers/file.js +8 -9
- package/dist/helpers/formatOutput.d.ts +2 -2
- package/dist/helpers/formatOutput.js +24 -28
- package/dist/helpers/index.js +6 -22
- package/dist/helpers/json2csv.js +11 -15
- package/dist/helpers/lookup.d.ts +1 -1
- package/dist/helpers/lookup.js +3 -7
- package/dist/helpers/setupMaxcryptor.d.ts +2 -2
- package/dist/helpers/setupMaxcryptor.js +7 -11
- package/dist/helpers/splitPOAndVers.js +4 -8
- package/dist/helpers/types.js +1 -5
- package/dist/index.js +7 -16
- package/dist/locales/index.js +4 -12
- package/dist/pdf/components/FieldVerificationBadge.d.ts +0 -1
- package/dist/pdf/components/FieldVerificationBadge.js +8 -15
- package/dist/pdf/components/Images.d.ts +1 -2
- package/dist/pdf/components/Images.js +7 -14
- package/dist/pdf/components/InnerTableRows.d.ts +2 -3
- package/dist/pdf/components/InnerTableRows.js +19 -26
- package/dist/pdf/components/POVerificationBadge.d.ts +1 -2
- package/dist/pdf/components/POVerificationBadge.js +28 -35
- package/dist/pdf/components/Report.d.ts +3 -4
- package/dist/pdf/components/Report.js +61 -68
- package/dist/pdf/components/Subheader.d.ts +0 -1
- package/dist/pdf/components/Subheader.js +20 -27
- package/dist/pdf/components/Table.d.ts +3 -4
- package/dist/pdf/components/Table.js +21 -28
- package/dist/pdf/components/TableTitle.d.ts +1 -2
- package/dist/pdf/components/TableTitle.js +5 -12
- package/dist/pdf/components/ValidationDisplay.d.ts +1 -2
- package/dist/pdf/components/ValidationDisplay.js +10 -17
- package/dist/pdf/components/VerifyBox.d.ts +0 -1
- package/dist/pdf/components/VerifyBox.js +9 -16
- package/dist/pdf/components/pieChart.js +1 -5
- package/dist/pdf/constants.js +8 -11
- package/dist/pdf/helpers/general.js +11 -18
- package/dist/pdf/helpers/transform.d.ts +1 -1
- package/dist/pdf/helpers/transform.js +11 -15
- package/dist/pdf/style.d.ts +1 -1
- package/dist/pdf/style.js +7 -10
- package/dist/public-methods/generatePDF.d.ts +2 -2
- package/dist/public-methods/generatePDF.js +14 -22
- package/dist/public-methods/getAndValidateConfig.d.ts +1 -1
- package/dist/public-methods/getAndValidateConfig.js +3 -7
- package/dist/public-methods/processSubmission.d.ts +4 -4
- package/dist/public-methods/processSubmission.js +37 -33
- package/dist/public-methods/saveToS3Bucket.d.ts +1 -1
- package/dist/public-methods/saveToS3Bucket.js +6 -13
- package/dist/public-methods/version.js +7 -10
- package/package.json +33 -63
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const ramda_1 = require("ramda");
|
|
9
|
-
const helpers_1 = require("../../helpers");
|
|
10
|
-
const transform_1 = require("../helpers/transform");
|
|
11
|
-
const Images_1 = require("./Images");
|
|
12
|
-
const ValidationDisplay_1 = require("./ValidationDisplay");
|
|
13
|
-
const InnerTableRows = ({ key, value, imageFieldNames, config, files, color, }) => {
|
|
1
|
+
import JsxPdf from "jsx-pdf";
|
|
2
|
+
import { uniq } from "ramda";
|
|
3
|
+
import { assertSafeProperty } from "../../helpers";
|
|
4
|
+
import { IS_ARRAY_OF_OBJECTS, IS_IMAGE, transform } from "../helpers/transform";
|
|
5
|
+
import { Images } from "./Images";
|
|
6
|
+
import { ValidationDisplay } from "./ValidationDisplay";
|
|
7
|
+
export const InnerTableRows = ({ key, value, imageFieldNames, config, files, color, }) => {
|
|
14
8
|
if (typeof value === "object" &&
|
|
15
9
|
value &&
|
|
16
10
|
"score" in value &&
|
|
17
11
|
"breakdown" in value) {
|
|
18
|
-
return
|
|
12
|
+
return JsxPdf.createElement(ValidationDisplay, { value: value });
|
|
19
13
|
}
|
|
20
|
-
const text =
|
|
21
|
-
if (typeof text !== "string" && text ===
|
|
22
|
-
return
|
|
14
|
+
const text = transform(key, value, config, imageFieldNames);
|
|
15
|
+
if (typeof text !== "string" && text === IS_IMAGE) {
|
|
16
|
+
return JsxPdf.createElement(Images, { files: files, nIds: [value.n_id] });
|
|
23
17
|
}
|
|
24
|
-
if (typeof text !== "string" && text ===
|
|
25
|
-
const headers = [
|
|
18
|
+
if (typeof text !== "string" && text === IS_ARRAY_OF_OBJECTS) {
|
|
19
|
+
const headers = [uniq(value.flatMap(Object.keys))];
|
|
26
20
|
const tableValues = [...headers, ...value];
|
|
27
|
-
return (
|
|
28
|
-
return (
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
|
|
21
|
+
return (JsxPdf.createElement("table", { headerRows: 1, layout: "headerLineOnly" }, tableValues.map((data, tableValueIndex) => {
|
|
22
|
+
return (JsxPdf.createElement("row", null, headers[0].map((header) => {
|
|
23
|
+
assertSafeProperty(header);
|
|
24
|
+
return (JsxPdf.createElement("cell", null,
|
|
25
|
+
JsxPdf.createElement(InnerTableRows, { key: header, value: data[header] || (tableValueIndex === 0 ? header : "-"), files: files, config: config, color: color, imageFieldNames: imageFieldNames })));
|
|
32
26
|
})));
|
|
33
27
|
})));
|
|
34
28
|
}
|
|
35
|
-
return
|
|
29
|
+
return JsxPdf.createElement("text", { color: color }, text.slice(0, 100));
|
|
36
30
|
};
|
|
37
|
-
exports.InnerTableRows = InnerTableRows;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="jsx-pdf" />
|
|
2
1
|
import { POVerification } from "@raytio/types";
|
|
3
|
-
import { FlatPO } from "../../helpers";
|
|
2
|
+
import type { FlatPO } from "../../helpers";
|
|
4
3
|
export declare const FILE_MAP: Record<POVerification, string>;
|
|
5
4
|
export declare const POVerificationBadge: ({ width, POs, }: {
|
|
6
5
|
width: number;
|
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.FILE_MAP = {
|
|
13
|
-
[types_1.POVerification.FullyVerified]: "verified_user_big",
|
|
14
|
-
[types_1.POVerification.PartiallyVerified]: "verified_partial_big",
|
|
15
|
-
[types_1.POVerification.NotVerified]: "not_verified_big",
|
|
16
|
-
[types_1.POVerification.Expired]: "not_verified_big",
|
|
17
|
-
[types_1.POVerification.VerifiedFalse]: "false_verified_user_big",
|
|
1
|
+
import { POVerification } from "@raytio/types";
|
|
2
|
+
import JsxPdf from "jsx-pdf";
|
|
3
|
+
import { $$ } from "../../locales";
|
|
4
|
+
import { loadAsset } from "../helpers/general";
|
|
5
|
+
import { PO_VER_TEXT_MAP } from "../../constants";
|
|
6
|
+
export const FILE_MAP = {
|
|
7
|
+
[POVerification.FullyVerified]: "verified_user_big",
|
|
8
|
+
[POVerification.PartiallyVerified]: "verified_partial_big",
|
|
9
|
+
[POVerification.NotVerified]: "not_verified_big",
|
|
10
|
+
[POVerification.Expired]: "not_verified_big",
|
|
11
|
+
[POVerification.VerifiedFalse]: "false_verified_user_big",
|
|
18
12
|
// not possible but included here for completeness
|
|
19
|
-
[
|
|
20
|
-
[
|
|
13
|
+
[POVerification.Encrypted]: "not_verified_big",
|
|
14
|
+
[POVerification.Loading]: "not_verified_big",
|
|
21
15
|
};
|
|
22
|
-
const POVerificationBadge = ({ width, POs, }) => {
|
|
16
|
+
export const POVerificationBadge = ({ width, POs, }) => {
|
|
23
17
|
// TODO: this won't work if multiple POs of the same schema are shared
|
|
24
18
|
const { $badges, $verification_details, $shouldBeVerifiedFields } = POs[0];
|
|
25
19
|
const verifiedBy = $verification_details === null || $verification_details === void 0 ? void 0 : $verification_details.verifier_id;
|
|
26
|
-
return (
|
|
27
|
-
$shouldBeVerifiedFields && (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
verifiedBy && (
|
|
31
|
-
$badges.safeHarbour && (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
?
|
|
35
|
-
:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
? (
|
|
39
|
-
: (
|
|
20
|
+
return (JsxPdf.createElement(JsxPdf.Fragment, null,
|
|
21
|
+
$shouldBeVerifiedFields && (JsxPdf.createElement(JsxPdf.Fragment, null,
|
|
22
|
+
JsxPdf.createElement("svg", { content: loadAsset(`${FILE_MAP[$badges.verified.code]}.svg`), width: width }),
|
|
23
|
+
JsxPdf.createElement("text", { alignment: "center" }, PO_VER_TEXT_MAP[$badges.verified.code]),
|
|
24
|
+
verifiedBy && (JsxPdf.createElement("text", { alignment: "center" }, $$("POVerificationBadge.verified-by", { verifiedBy }))))),
|
|
25
|
+
$badges.safeHarbour && (JsxPdf.createElement("columns", { columnGap: 10 },
|
|
26
|
+
JsxPdf.createElement("column", { width: width / 3 },
|
|
27
|
+
JsxPdf.createElement("svg", { content: loadAsset(`${FILE_MAP[$badges.safeHarbour.code
|
|
28
|
+
? POVerification.FullyVerified
|
|
29
|
+
: POVerification.VerifiedFalse]}.svg`), width: width / 3 })),
|
|
30
|
+
JsxPdf.createElement("column", { width: "auto" },
|
|
31
|
+
JsxPdf.createElement("text", { alignment: "center" }, $badges.safeHarbour.code
|
|
32
|
+
? $$("POVerificationBadge.safe-harbour-yes")
|
|
33
|
+
: $$("POVerificationBadge.safe-harbour-no")))))));
|
|
40
34
|
};
|
|
41
|
-
exports.POVerificationBadge = POVerificationBadge;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="jsx-pdf" />
|
|
2
1
|
import type { AId } from "@raytio/types";
|
|
3
|
-
import { PdfConfig } from "../types";
|
|
4
|
-
import { EnvConfig } from "../../api";
|
|
5
|
-
import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
2
|
+
import type { PdfConfig } from "../types";
|
|
3
|
+
import type { EnvConfig } from "../../api";
|
|
4
|
+
import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
6
5
|
export declare const Report: ({ data, files, config, aId, clientUrl, envConfig, }: {
|
|
7
6
|
data: ProcessSubmissionOutput["json"];
|
|
8
7
|
files: ProcessSubmissionOutput["files"];
|
|
@@ -1,98 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const VerifyBox_1 = require("./VerifyBox");
|
|
18
|
-
const constants_1 = require("../constants");
|
|
19
|
-
const transform_1 = require("../helpers/transform");
|
|
20
|
-
const constants_2 = require("../../constants");
|
|
21
|
-
const version_1 = require("../../public-methods/version");
|
|
22
|
-
const Report = ({ data, files, config, aId, clientUrl, envConfig, }) => {
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import JsxPdf from "jsx-pdf";
|
|
3
|
+
import { isScoreResultValid } from "@raytio/core";
|
|
4
|
+
import { $$ } from "../../locales";
|
|
5
|
+
import { classes } from "../style";
|
|
6
|
+
import { asset } from "../helpers/general";
|
|
7
|
+
import { NULL_I_ID, SUBMISSION_DATA } from "../constants";
|
|
8
|
+
import { transform } from "../helpers/transform";
|
|
9
|
+
import { SCHEMA } from "../../constants";
|
|
10
|
+
import { version } from "../../public-methods/version";
|
|
11
|
+
import { VerifyBox } from "./VerifyBox";
|
|
12
|
+
import { Table } from "./Table";
|
|
13
|
+
import { TableTitle } from "./TableTitle";
|
|
14
|
+
import { Subheader } from "./Subheader";
|
|
15
|
+
import { POVerificationBadge } from "./POVerificationBadge";
|
|
16
|
+
export const Report = ({ data, files, config, aId, clientUrl, envConfig, }) => {
|
|
23
17
|
// The PDF is read only; there's no reason why anyone would ever need to unlock it.
|
|
24
|
-
const randomToken =
|
|
18
|
+
const randomToken = randomBytes(32).toString("base64");
|
|
25
19
|
const schemas = Object.values(data.profile_objects).sort(
|
|
26
20
|
// sort it so that the person schema comes first
|
|
27
21
|
(a, b) => {
|
|
28
22
|
var _a, _b;
|
|
29
|
-
return +(((_a = b[0]) === null || _a === void 0 ? void 0 : _a.$schemaName) ===
|
|
30
|
-
+(((_b = a[0]) === null || _b === void 0 ? void 0 : _b.$schemaName) ===
|
|
23
|
+
return +(((_a = b[0]) === null || _a === void 0 ? void 0 : _a.$schemaName) === SCHEMA.PERSON) -
|
|
24
|
+
+(((_b = a[0]) === null || _b === void 0 ? void 0 : _b.$schemaName) === SCHEMA.PERSON);
|
|
31
25
|
});
|
|
32
26
|
const appName = envConfig.app_name;
|
|
33
|
-
const iId = data.
|
|
34
|
-
return (
|
|
35
|
-
title: (
|
|
27
|
+
const iId = data.id === NULL_I_ID ? "" : data.id;
|
|
28
|
+
return (JsxPdf.createElement("document", { defaultStyle: { font: "Lato", fontSize: 12 }, info: {
|
|
29
|
+
title: $$("Report.meta.title", { appName, iId }),
|
|
36
30
|
creator: appName,
|
|
37
|
-
producer: "Raytio",
|
|
38
|
-
subject:
|
|
31
|
+
producer: "Raytio", // don't whitelabel
|
|
32
|
+
subject: version,
|
|
39
33
|
},
|
|
40
34
|
// @ts-expect-error -- waiting on bpampuch/pdfmake#2453
|
|
41
35
|
lang: global.lang, ownerPassword: randomToken, permissions: {
|
|
42
36
|
printing: "highResolution",
|
|
43
37
|
copying: true, // allow copy/paste
|
|
44
|
-
}, pageSize: "A4", styles:
|
|
38
|
+
}, pageSize: "A4", styles: classes, images: {
|
|
45
39
|
raytioLogo: envConfig.logo_url
|
|
46
|
-
?
|
|
47
|
-
:
|
|
40
|
+
? asset("custom-logo.png")
|
|
41
|
+
: asset("logo.png"),
|
|
48
42
|
} },
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
(
|
|
43
|
+
JsxPdf.createElement("header", null, (currentPage) => currentPage !== 1 && (JsxPdf.createElement("stack", { color: "#333", fontSize: 10 },
|
|
44
|
+
JsxPdf.createElement("text", { margin: 16 },
|
|
45
|
+
JsxPdf.createElement("text", { bold: true },
|
|
46
|
+
$$("Report.header", { appName }),
|
|
53
47
|
" - "),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
JsxPdf.createElement("text", null, iId))))),
|
|
49
|
+
JsxPdf.createElement("content", null,
|
|
50
|
+
JsxPdf.createElement("image", { src: "raytioLogo", width: 150, alignment: "center" }),
|
|
51
|
+
JsxPdf.createElement("text", { style: ["header", "marginBottom"], alignment: "center" }, $$("Report.header", { appName })),
|
|
52
|
+
JsxPdf.createElement("columns", { columnGap: 10 },
|
|
53
|
+
JsxPdf.createElement("column", { width: "auto" },
|
|
54
|
+
JsxPdf.createElement("text", { style: ["subheader", "marginBottom"] },
|
|
61
55
|
iId &&
|
|
62
|
-
Object.entries(
|
|
63
|
-
.map(([id, label]) => `${label}: ${
|
|
56
|
+
Object.entries(SUBMISSION_DATA)
|
|
57
|
+
.map(([id, label]) => `${label}: ${transform(id, data[id], config)}`)
|
|
64
58
|
.join("\n"),
|
|
65
|
-
|
|
59
|
+
isScoreResultValid(data.score)
|
|
66
60
|
? [
|
|
67
61
|
"",
|
|
68
|
-
`${(
|
|
69
|
-
`${(
|
|
62
|
+
`${$$("constants.score")}: ${data.score.score}`,
|
|
63
|
+
`${$$("constants.score-category")}: ${data.score.category}`,
|
|
70
64
|
].join("\n")
|
|
71
65
|
: ""),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
JsxPdf.createElement(Subheader, { data: data, config: config })),
|
|
67
|
+
JsxPdf.createElement("column", { width: "*" },
|
|
68
|
+
JsxPdf.createElement("text", null, " ")),
|
|
69
|
+
JsxPdf.createElement("column", { width: 150 },
|
|
70
|
+
JsxPdf.createElement(VerifyBox, { aId: aId, iId: data.id, clientUrl: clientUrl }))),
|
|
77
71
|
schemas.map((POs) => {
|
|
78
72
|
// for each schema
|
|
79
|
-
return (
|
|
73
|
+
return (JsxPdf.createElement("stack", {
|
|
80
74
|
// unbreakable is off because it crashes if its too big for one page
|
|
81
75
|
// This is a 7-year-old issue in pdfmake (https://github.com/bpampuch/pdfmake/issues/207)
|
|
82
76
|
unbreakable: false, style: "marginY" },
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
JsxPdf.createElement(TableTitle, { POs: POs }),
|
|
78
|
+
JsxPdf.createElement("columns", { columnGap: 15 },
|
|
79
|
+
JsxPdf.createElement("column", { width: 80 },
|
|
80
|
+
JsxPdf.createElement(POVerificationBadge, { width: 80, POs: POs })),
|
|
81
|
+
JsxPdf.createElement("column", { width: "auto" },
|
|
82
|
+
JsxPdf.createElement(Table, { POs: POs, files: files, config: config })))));
|
|
89
83
|
})),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
(
|
|
84
|
+
JsxPdf.createElement("footer", null, (currentPage, pageCount, pageSize) => (JsxPdf.createElement("stack", { bold: true, color: "#333", fontSize: 10 },
|
|
85
|
+
JsxPdf.createElement("text", { margin: 16 },
|
|
86
|
+
JsxPdf.createElement("text", null,
|
|
87
|
+
$$("Report.header", { appName }),
|
|
94
88
|
" - "),
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
JsxPdf.createElement("text", { color: "#fb7171" }, $$("Report.footer-private"))),
|
|
90
|
+
JsxPdf.createElement("text", { absolutePosition: { x: pageSize.width - 50, y: 15 } }, $$("Report.pagecount", { currentPage, pageCount })))))));
|
|
97
91
|
};
|
|
98
|
-
exports.Report = Report;
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { FieldVerification } from "@raytio/types";
|
|
2
|
+
import JsxPdf from "jsx-pdf";
|
|
3
|
+
import { $$ } from "../../locales";
|
|
4
|
+
import { FieldVerificationBadge } from "./FieldVerificationBadge";
|
|
5
|
+
export const Subheader = () => {
|
|
6
|
+
return (JsxPdf.createElement(JsxPdf.Fragment, null,
|
|
7
|
+
JsxPdf.createElement("text", { bold: true, style: "marginBottom" }, "Key:"),
|
|
8
|
+
JsxPdf.createElement("table", { layout: "noBorders" },
|
|
9
|
+
JsxPdf.createElement("row", null,
|
|
10
|
+
JsxPdf.createElement("cell", null,
|
|
11
|
+
JsxPdf.createElement(FieldVerificationBadge, { width: 10, status: FieldVerification.Verified })),
|
|
12
|
+
JsxPdf.createElement("cell", null, $$("FieldVerification.Verified"))),
|
|
13
|
+
JsxPdf.createElement("row", null,
|
|
14
|
+
JsxPdf.createElement("cell", null,
|
|
15
|
+
JsxPdf.createElement(FieldVerificationBadge, { width: 10, status: FieldVerification.NotVerified })),
|
|
16
|
+
JsxPdf.createElement("cell", null, $$("FieldVerification.NotVerified"))),
|
|
17
|
+
JsxPdf.createElement("row", null,
|
|
18
|
+
JsxPdf.createElement("cell", null,
|
|
19
|
+
JsxPdf.createElement(FieldVerificationBadge, { width: 10, status: FieldVerification.VerifiedFalse })),
|
|
20
|
+
JsxPdf.createElement("cell", null, $$("FieldVerification.VerifiedFalse"))))));
|
|
4
21
|
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Subheader = void 0;
|
|
7
|
-
const types_1 = require("@raytio/types");
|
|
8
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
9
|
-
const locales_1 = require("../../locales");
|
|
10
|
-
const FieldVerificationBadge_1 = require("./FieldVerificationBadge");
|
|
11
|
-
const Subheader = () => {
|
|
12
|
-
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
13
|
-
jsx_pdf_1.default.createElement("text", { bold: true, style: "marginBottom" }, "Key:"),
|
|
14
|
-
jsx_pdf_1.default.createElement("table", { layout: "noBorders" },
|
|
15
|
-
jsx_pdf_1.default.createElement("row", null,
|
|
16
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
17
|
-
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: types_1.FieldVerification.Verified })),
|
|
18
|
-
jsx_pdf_1.default.createElement("cell", null, (0, locales_1.$$)("FieldVerification.Verified"))),
|
|
19
|
-
jsx_pdf_1.default.createElement("row", null,
|
|
20
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
21
|
-
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: types_1.FieldVerification.NotVerified })),
|
|
22
|
-
jsx_pdf_1.default.createElement("cell", null, (0, locales_1.$$)("FieldVerification.NotVerified"))),
|
|
23
|
-
jsx_pdf_1.default.createElement("row", null,
|
|
24
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
25
|
-
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: types_1.FieldVerification.VerifiedFalse })),
|
|
26
|
-
jsx_pdf_1.default.createElement("cell", null, (0, locales_1.$$)("FieldVerification.VerifiedFalse"))))));
|
|
27
|
-
};
|
|
28
|
-
exports.Subheader = Subheader;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
1
|
+
import type { PdfConfig } from "../types";
|
|
2
|
+
import { type FlatPO } from "../../helpers";
|
|
3
|
+
import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
5
4
|
export declare const Table: ({ POs, files, config, }: {
|
|
6
5
|
POs: FlatPO[];
|
|
7
6
|
files: ProcessSubmissionOutput["files"];
|
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const general_1 = require("../helpers/general");
|
|
9
|
-
const FieldVerificationBadge_1 = require("./FieldVerificationBadge");
|
|
10
|
-
const Images_1 = require("./Images");
|
|
11
|
-
const InnerTableRows_1 = require("./InnerTableRows");
|
|
12
|
-
const helpers_1 = require("../../helpers");
|
|
13
|
-
const Table = ({ POs, files, config, }) => {
|
|
1
|
+
import JsxPdf from "jsx-pdf";
|
|
2
|
+
import { verifyColour } from "../helpers/general";
|
|
3
|
+
import { assertSafeProperty, isFieldValueFile, isPOFile, } from "../../helpers";
|
|
4
|
+
import { FieldVerificationBadge } from "./FieldVerificationBadge";
|
|
5
|
+
import { Images } from "./Images";
|
|
6
|
+
import { InnerTableRows } from "./InnerTableRows";
|
|
7
|
+
export const Table = ({ POs, files, config, }) => {
|
|
14
8
|
/** every fieldName in these profile object */
|
|
15
9
|
const fieldNames = [
|
|
16
10
|
...new Set(POs.flatMap((PO) => Object.keys(PO.$properties))),
|
|
17
11
|
];
|
|
18
12
|
// some or all POs in this schema are files themselves. So render the file, assuming it's an image
|
|
19
|
-
const fileNIds = POs.filter(
|
|
13
|
+
const fileNIds = POs.filter(isPOFile).map((x) => x.$nId);
|
|
20
14
|
if (fileNIds.length)
|
|
21
|
-
return
|
|
22
|
-
const imageFieldNames = fieldNames.filter((fieldName) => POs.map((PO) => { var _a; return (_a = PO.$properties[fieldName]) === null || _a === void 0 ? void 0 : _a.value; }).some(
|
|
23
|
-
return (
|
|
15
|
+
return JsxPdf.createElement(Images, { nIds: fileNIds, files: files });
|
|
16
|
+
const imageFieldNames = fieldNames.filter((fieldName) => POs.map((PO) => { var _a; return (_a = PO.$properties[fieldName]) === null || _a === void 0 ? void 0 : _a.value; }).some(isFieldValueFile));
|
|
17
|
+
return (JsxPdf.createElement("table", { layout: "noBorders" }, fieldNames.map((fieldName) => {
|
|
24
18
|
var _a;
|
|
25
|
-
return (
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
return (JsxPdf.createElement("row", null,
|
|
20
|
+
JsxPdf.createElement("cell", null,
|
|
21
|
+
JsxPdf.createElement("text", { color: "#12130e" }, ((_a = POs.find((PO) => PO.$properties[fieldName])) === null || _a === void 0 ? void 0 : _a.$properties[fieldName].title) || fieldName)),
|
|
28
22
|
POs.flatMap((PO) => {
|
|
29
|
-
|
|
23
|
+
assertSafeProperty(fieldName);
|
|
30
24
|
// if we're sharing multiple POs in this schema, and this field doesn't exist on this paticular PO,
|
|
31
25
|
// then just render some empty cells
|
|
32
26
|
if (!PO.$properties[fieldName]) {
|
|
33
|
-
return [
|
|
27
|
+
return [JsxPdf.createElement("cell", null, " "), JsxPdf.createElement("cell", null, " ")];
|
|
34
28
|
}
|
|
35
29
|
const { value, formatted_value, verification } = PO.$properties[fieldName];
|
|
36
|
-
const color =
|
|
30
|
+
const color = verifyColour(verification);
|
|
37
31
|
// jsx-pdf currently doesn't support fragments, will make a PR at some point
|
|
38
32
|
return [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
JsxPdf.createElement("cell", null,
|
|
34
|
+
JsxPdf.createElement(FieldVerificationBadge, { width: 10, status: verification })),
|
|
35
|
+
JsxPdf.createElement("cell", null,
|
|
36
|
+
JsxPdf.createElement(InnerTableRows, { key: fieldName, value: formatted_value || value, files: files, config: config, color: color, imageFieldNames: imageFieldNames })),
|
|
43
37
|
];
|
|
44
38
|
})));
|
|
45
39
|
})));
|
|
46
40
|
};
|
|
47
|
-
exports.Table = Table;
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TableTitle = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const helpers_1 = require("../../helpers");
|
|
9
|
-
const TableTitle = ({ POs }) => {
|
|
1
|
+
import JsxPdf from "jsx-pdf";
|
|
2
|
+
import { isPOFile } from "../../helpers";
|
|
3
|
+
export const TableTitle = ({ POs }) => {
|
|
10
4
|
var _a;
|
|
11
5
|
const schemaTitle = POs[0].$schemaTitle;
|
|
12
|
-
const maybeFileName = POs.some(
|
|
6
|
+
const maybeFileName = POs.some(isPOFile)
|
|
13
7
|
? (_a = POs[0].$properties.title) === null || _a === void 0 ? void 0 : _a.value
|
|
14
8
|
: undefined;
|
|
15
|
-
return (
|
|
9
|
+
return (JsxPdf.createElement("text", { bold: true, fontSize: 14, style: "marginBottom" }, maybeFileName || schemaTitle));
|
|
16
10
|
};
|
|
17
|
-
exports.TableTitle = TableTitle;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ValidationDisplay = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const locales_1 = require("../../locales");
|
|
9
|
-
const pieChart_1 = require("./pieChart");
|
|
10
|
-
const helpers_1 = require("../../helpers");
|
|
1
|
+
import JsxPdf from "jsx-pdf";
|
|
2
|
+
import { $$ } from "../../locales";
|
|
3
|
+
import { assertSafeProperty } from "../../helpers";
|
|
4
|
+
import { pieChart } from "./pieChart";
|
|
11
5
|
const SEVERITY_COLOURS = {
|
|
12
6
|
low: "#2e8bc0",
|
|
13
7
|
medium: "#ff9800",
|
|
14
8
|
high: "#fb7171",
|
|
15
9
|
};
|
|
16
|
-
const ValidationDisplay = ({ value, }) => {
|
|
10
|
+
export const ValidationDisplay = ({ value, }) => {
|
|
17
11
|
const colour = value.score > 0.5 ? "#c2d887" : "#fb7171";
|
|
18
|
-
return (
|
|
19
|
-
|
|
20
|
-
(
|
|
12
|
+
return (JsxPdf.createElement(JsxPdf.Fragment, null,
|
|
13
|
+
JsxPdf.createElement("svg", { content: pieChart(colour, value.score * 100), width: 50 }),
|
|
14
|
+
$$("ValidationDisplay.text", { n: value.score * 10 }),
|
|
21
15
|
Object.values(value.breakdown)
|
|
22
16
|
.filter((x) => x.severity && x.reason)
|
|
23
17
|
.map((x) => {
|
|
24
18
|
const key = x.severity;
|
|
25
|
-
|
|
26
|
-
return
|
|
19
|
+
assertSafeProperty(key);
|
|
20
|
+
return JsxPdf.createElement("text", { color: SEVERITY_COLOURS[key] }, x.reason);
|
|
27
21
|
})));
|
|
28
22
|
};
|
|
29
|
-
exports.ValidationDisplay = ValidationDisplay;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
exports.VerifyBox = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const locales_1 = require("../../locales");
|
|
9
|
-
const constants_1 = require("../constants");
|
|
10
|
-
const VerifyBox = ({ aId, iId, clientUrl }) => {
|
|
11
|
-
if (iId === constants_1.NULL_I_ID)
|
|
1
|
+
import JsxPdf from "jsx-pdf";
|
|
2
|
+
import { $$ } from "../../locales";
|
|
3
|
+
import { NULL_I_ID } from "../constants";
|
|
4
|
+
export const VerifyBox = ({ aId, iId, clientUrl }) => {
|
|
5
|
+
if (iId === NULL_I_ID)
|
|
12
6
|
return null;
|
|
13
7
|
const url = `${clientUrl}/apps/s/${aId}/i/${iId}`;
|
|
14
|
-
return (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
return (JsxPdf.createElement("stack", { alignment: "center" },
|
|
9
|
+
JsxPdf.createElement("text", { link: url }, $$("VerifyBox.text")),
|
|
10
|
+
JsxPdf.createElement("qr", { content: url, fit: 150 }),
|
|
11
|
+
JsxPdf.createElement("text", { color: "#1e90ff", fontSize: 9, link: url, alignment: "left" }, url)));
|
|
18
12
|
};
|
|
19
|
-
exports.VerifyBox = VerifyBox;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pieChart = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* A semi-cirle pie chart
|
|
6
3
|
* (!) generates a SVG string, not a JSX component.
|
|
7
4
|
* @param percentage a number from 0 to 100
|
|
8
5
|
*/
|
|
9
|
-
function pieChart(colour, percentage) {
|
|
6
|
+
export function pieChart(colour, percentage) {
|
|
10
7
|
return `
|
|
11
8
|
<svg height="70" width="140" viewBox="0 -5 20 15">
|
|
12
9
|
<circle r="10" cx="10" cy="10" fill="bisque" />
|
|
@@ -24,4 +21,3 @@ function pieChart(colour, percentage) {
|
|
|
24
21
|
</svg>
|
|
25
22
|
`;
|
|
26
23
|
}
|
|
27
|
-
exports.pieChart = pieChart;
|