@raytio/decrypt-helper 5.1.3 → 6.1.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 +5 -1
- package/package.json +32 -23
- package/CHANGELOG.md +0 -221
- package/dist/api/authedFetch.d.ts +0 -1
- package/dist/api/authedFetch.js +0 -32
- package/dist/api/fetchAA.d.ts +0 -3
- package/dist/api/fetchAA.js +0 -19
- package/dist/api/fetchEnvConfig.d.ts +0 -6
- package/dist/api/fetchEnvConfig.js +0 -39
- package/dist/api/fetchInstanceData.d.ts +0 -3
- package/dist/api/fetchInstanceData.js +0 -21
- package/dist/api/getFiles.d.ts +0 -4
- package/dist/api/getFiles.js +0 -82
- package/dist/api/getLookupOption.d.ts +0 -2
- package/dist/api/getLookupOption.js +0 -32
- package/dist/api/getSchema.d.ts +0 -3
- package/dist/api/getSchema.js +0 -31
- package/dist/api/index.d.ts +0 -9
- package/dist/api/index.js +0 -25
- package/dist/api/resolveVerificationDetails.d.ts +0 -9
- package/dist/api/resolveVerificationDetails.js +0 -35
- package/dist/api/signIn.d.ts +0 -7
- package/dist/api/signIn.js +0 -56
- package/dist/api/updateInstanceData.d.ts +0 -2
- package/dist/api/updateInstanceData.js +0 -19
- package/dist/configureEnv.d.ts +0 -1
- package/dist/configureEnv.js +0 -16
- package/dist/constants.d.ts +0 -23
- package/dist/constants.js +0 -45
- package/dist/helpers/file.d.ts +0 -13
- package/dist/helpers/file.js +0 -17
- package/dist/helpers/formatOutput.d.ts +0 -28
- package/dist/helpers/formatOutput.js +0 -92
- package/dist/helpers/index.d.ts +0 -6
- package/dist/helpers/index.js +0 -22
- package/dist/helpers/json2csv.d.ts +0 -2
- package/dist/helpers/json2csv.js +0 -24
- package/dist/helpers/lookup.d.ts +0 -2
- package/dist/helpers/lookup.js +0 -22
- package/dist/helpers/setupMaxcryptor.d.ts +0 -4
- package/dist/helpers/setupMaxcryptor.js +0 -28
- package/dist/helpers/splitPOAndVers.d.ts +0 -2
- package/dist/helpers/splitPOAndVers.js +0 -11
- package/dist/helpers/types.d.ts +0 -1
- package/dist/helpers/types.js +0 -9
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -16
- package/dist/locales/index.d.ts +0 -44
- package/dist/locales/index.js +0 -21
- package/dist/locales/translations/en.json +0 -33
- package/dist/pdf/components/FieldVerificationBadge.d.ts +0 -6
- package/dist/pdf/components/FieldVerificationBadge.js +0 -19
- package/dist/pdf/components/Images.d.ts +0 -6
- package/dist/pdf/components/Images.js +0 -19
- package/dist/pdf/components/InnerTableRows.d.ts +0 -11
- package/dist/pdf/components/InnerTableRows.js +0 -37
- package/dist/pdf/components/POVerificationBadge.d.ts +0 -8
- package/dist/pdf/components/POVerificationBadge.js +0 -41
- package/dist/pdf/components/Report.d.ts +0 -14
- package/dist/pdf/components/Report.js +0 -95
- package/dist/pdf/components/Subheader.d.ts +0 -2
- package/dist/pdf/components/Subheader.js +0 -28
- package/dist/pdf/components/Table.d.ts +0 -9
- package/dist/pdf/components/Table.js +0 -47
- package/dist/pdf/components/TableTitle.d.ts +0 -5
- package/dist/pdf/components/TableTitle.js +0 -17
- package/dist/pdf/components/ValidationDisplay.d.ts +0 -5
- package/dist/pdf/components/ValidationDisplay.js +0 -29
- package/dist/pdf/components/VerifyBox.d.ts +0 -9
- package/dist/pdf/components/VerifyBox.js +0 -16
- package/dist/pdf/components/pieChart.d.ts +0 -6
- package/dist/pdf/components/pieChart.js +0 -27
- package/dist/pdf/constants.d.ts +0 -2
- package/dist/pdf/constants.js +0 -11
- package/dist/pdf/helpers/general.d.ts +0 -8
- package/dist/pdf/helpers/general.js +0 -37
- package/dist/pdf/helpers/transform.d.ts +0 -4
- package/dist/pdf/helpers/transform.js +0 -39
- package/dist/pdf/style.d.ts +0 -10
- package/dist/pdf/style.js +0 -24
- package/dist/public-methods/generatePDF.d.ts +0 -4
- package/dist/public-methods/generatePDF.js +0 -62
- package/dist/public-methods/getAndValidateConfig.d.ts +0 -8
- package/dist/public-methods/getAndValidateConfig.js +0 -20
- package/dist/public-methods/processSubmission.d.ts +0 -48
- package/dist/public-methods/processSubmission.js +0 -124
- package/dist/public-methods/saveToS3Bucket.d.ts +0 -2
- package/dist/public-methods/saveToS3Bucket.js +0 -58
package/dist/locales/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.$$ = exports.isValidLocale = void 0;
|
|
7
|
-
const en_json_1 = __importDefault(require("./translations/en.json"));
|
|
8
|
-
const locales = { en: en_json_1.default };
|
|
9
|
-
const isValidLocale = (lang) => lang in locales;
|
|
10
|
-
exports.isValidLocale = isValidLocale;
|
|
11
|
-
const $$ = (key, variables) => {
|
|
12
|
-
const strings = locales[global.lang || "en"];
|
|
13
|
-
const replaceWithVariable = (_, varName) => {
|
|
14
|
-
const value = variables === null || variables === void 0 ? void 0 : variables[varName];
|
|
15
|
-
if (!value)
|
|
16
|
-
throw new Error(`[i18n] variable '${varName}' not defined`);
|
|
17
|
-
return `${value}`;
|
|
18
|
-
};
|
|
19
|
-
return strings[key].replace(/{([^}]+)}/g, replaceWithVariable);
|
|
20
|
-
};
|
|
21
|
-
exports.$$ = $$;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"FieldVerification.Expired": "Expired",
|
|
3
|
-
"FieldVerification.NotVerified": "Not Verified",
|
|
4
|
-
"FieldVerification.Verified": "Verified",
|
|
5
|
-
"FieldVerification.VerifiedFalse": "Verified False",
|
|
6
|
-
"Images.file-not-found": "File not found",
|
|
7
|
-
"POVerification.Encrypted": "Encrypted",
|
|
8
|
-
"POVerification.Expired": "Expired",
|
|
9
|
-
"POVerification.FullyVerified": "Fully Verified",
|
|
10
|
-
"POVerification.Loading": "Loading...",
|
|
11
|
-
"POVerification.NotVerified": "Not Verified",
|
|
12
|
-
"POVerification.PartiallyVerified": "Partially Verified",
|
|
13
|
-
"POVerification.VerifiedFalse": "Verified False",
|
|
14
|
-
"POVerificationBadge.safe-harbour-no": "Not Safe Harbour Compliant",
|
|
15
|
-
"POVerificationBadge.safe-harbour-yes": "Safe Harbour Compliant",
|
|
16
|
-
"POVerificationBadge.verified-by": "by {verifiedBy}",
|
|
17
|
-
"Report.footer-private": "Private and Confidential",
|
|
18
|
-
"Report.header": "{appName} Verification Report",
|
|
19
|
-
"Report.meta.title": "{appName} Verification Report - {iId}",
|
|
20
|
-
"Report.pagecount": "{currentPage} of {pageCount}",
|
|
21
|
-
"ValidationDisplay.text": "Score: {n}/10",
|
|
22
|
-
"VerifyBox.text": "To verify this submission, scan the QR Code or click here",
|
|
23
|
-
"constants.confirmation_code": "Code",
|
|
24
|
-
"constants.end_date": "Expiry Date",
|
|
25
|
-
"constants.i_id": "Submission ID",
|
|
26
|
-
"constants.reference": "Reference",
|
|
27
|
-
"constants.score": "Score",
|
|
28
|
-
"constants.score-category": "Score Category",
|
|
29
|
-
"constants.start_date": "Date Shared",
|
|
30
|
-
"field.boolean.no": "No",
|
|
31
|
-
"field.boolean.yes": "Yes",
|
|
32
|
-
"field.undefined": "N/A"
|
|
33
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FieldVerificationBadge = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const types_1 = require("@raytio/types");
|
|
9
|
-
const general_1 = require("../helpers/general");
|
|
10
|
-
const FieldVerificationBadge = ({ status, width, }) => {
|
|
11
|
-
if (status === types_1.FieldVerification.VerifiedFalse) {
|
|
12
|
-
return (jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)("verified_false_small.svg"), width: width }));
|
|
13
|
-
}
|
|
14
|
-
if (status === types_1.FieldVerification.Verified) {
|
|
15
|
-
return jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)("verified_tick_small.svg"), width: width });
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
};
|
|
19
|
-
exports.FieldVerificationBadge = FieldVerificationBadge;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Images = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const locales_1 = require("../../locales");
|
|
9
|
-
const helpers_1 = require("../../helpers");
|
|
10
|
-
const Images = ({ nIds, files, }) => {
|
|
11
|
-
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null, nIds.map((nId) => {
|
|
12
|
-
var _a;
|
|
13
|
-
const file = (_a = files[nId]) === null || _a === void 0 ? void 0 : _a[0];
|
|
14
|
-
if (file)
|
|
15
|
-
(0, helpers_1.assertSafeProperty)(file);
|
|
16
|
-
return file ? (jsx_pdf_1.default.createElement("image", { src: file, width: 300 })) : (jsx_pdf_1.default.createElement("text", null, (0, locales_1.$$)("Images.file-not-found")));
|
|
17
|
-
})));
|
|
18
|
-
};
|
|
19
|
-
exports.Images = Images;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="jsx-pdf" />
|
|
2
|
-
import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
3
|
-
import { PdfConfig } from "../types";
|
|
4
|
-
export declare const InnerTableRows: ({ key, value, imageFieldNames, config, files, color, }: {
|
|
5
|
-
key: string;
|
|
6
|
-
value: any;
|
|
7
|
-
files: ProcessSubmissionOutput["files"];
|
|
8
|
-
config: PdfConfig;
|
|
9
|
-
color: string;
|
|
10
|
-
imageFieldNames: string[];
|
|
11
|
-
}) => JSX.Element;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.InnerTableRows = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
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, }) => {
|
|
14
|
-
if (typeof value === "object" &&
|
|
15
|
-
value &&
|
|
16
|
-
"score" in value &&
|
|
17
|
-
"breakdown" in value) {
|
|
18
|
-
return jsx_pdf_1.default.createElement(ValidationDisplay_1.ValidationDisplay, { value: value });
|
|
19
|
-
}
|
|
20
|
-
const text = (0, transform_1.transform)(key, value, config, imageFieldNames);
|
|
21
|
-
if (typeof text !== "string" && text === transform_1.IS_IMAGE) {
|
|
22
|
-
return jsx_pdf_1.default.createElement(Images_1.Images, { files: files, nIds: [value.n_id] });
|
|
23
|
-
}
|
|
24
|
-
if (typeof text !== "string" && text === transform_1.IS_ARRAY_OF_OBJECTS) {
|
|
25
|
-
const headers = [(0, ramda_1.uniq)(value.flatMap(Object.keys))];
|
|
26
|
-
const tableValues = [...headers, ...value];
|
|
27
|
-
return (jsx_pdf_1.default.createElement("table", { headerRows: 1, layout: "headerLineOnly" }, tableValues.map((data, tableValueIndex) => {
|
|
28
|
-
return (jsx_pdf_1.default.createElement("row", null, headers[0].map((header) => {
|
|
29
|
-
(0, helpers_1.assertSafeProperty)(header);
|
|
30
|
-
return (jsx_pdf_1.default.createElement("cell", null,
|
|
31
|
-
jsx_pdf_1.default.createElement(exports.InnerTableRows, { key: header, value: data[header] || (tableValueIndex === 0 ? header : "-"), files: files, config: config, color: color, imageFieldNames: imageFieldNames })));
|
|
32
|
-
})));
|
|
33
|
-
})));
|
|
34
|
-
}
|
|
35
|
-
return jsx_pdf_1.default.createElement("text", { color: color }, text.slice(0, 100));
|
|
36
|
-
};
|
|
37
|
-
exports.InnerTableRows = InnerTableRows;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="jsx-pdf" />
|
|
2
|
-
import { POVerification } from "@raytio/types";
|
|
3
|
-
import { FlatPO } from "../../helpers";
|
|
4
|
-
export declare const FILE_MAP: Record<POVerification, string>;
|
|
5
|
-
export declare const POVerificationBadge: ({ width, POs, }: {
|
|
6
|
-
width: number;
|
|
7
|
-
POs: FlatPO[];
|
|
8
|
-
}) => JSX.Element;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.POVerificationBadge = exports.FILE_MAP = 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 general_1 = require("../helpers/general");
|
|
11
|
-
const constants_1 = require("../../constants");
|
|
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",
|
|
18
|
-
// not possible but included here for completeness
|
|
19
|
-
[types_1.POVerification.Encrypted]: "not_verified_big",
|
|
20
|
-
[types_1.POVerification.Loading]: "not_verified_big",
|
|
21
|
-
};
|
|
22
|
-
const POVerificationBadge = ({ width, POs, }) => {
|
|
23
|
-
// TODO: this won't work if multiple POs of the same schema are shared
|
|
24
|
-
const { $badges, $verification_details, $shouldBeVerifiedFields } = POs[0];
|
|
25
|
-
const verifiedBy = $verification_details === null || $verification_details === void 0 ? void 0 : $verification_details.verifier_id;
|
|
26
|
-
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
27
|
-
$shouldBeVerifiedFields && (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
28
|
-
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$badges.verified.code]}.svg`), width: width }),
|
|
29
|
-
jsx_pdf_1.default.createElement("text", { alignment: "center" }, constants_1.PO_VER_TEXT_MAP[$badges.verified.code]),
|
|
30
|
-
verifiedBy && (jsx_pdf_1.default.createElement("text", { alignment: "center" }, (0, locales_1.$$)("POVerificationBadge.verified-by", { verifiedBy }))))),
|
|
31
|
-
$badges.safeHarbour && (jsx_pdf_1.default.createElement("columns", { columnGap: 10 },
|
|
32
|
-
jsx_pdf_1.default.createElement("column", { width: width / 3 },
|
|
33
|
-
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$badges.safeHarbour.code
|
|
34
|
-
? types_1.POVerification.FullyVerified
|
|
35
|
-
: types_1.POVerification.VerifiedFalse]}.svg`), width: width / 3 })),
|
|
36
|
-
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
37
|
-
jsx_pdf_1.default.createElement("text", { alignment: "center" }, $badges.safeHarbour.code
|
|
38
|
-
? (0, locales_1.$$)("POVerificationBadge.safe-harbour-yes")
|
|
39
|
-
: (0, locales_1.$$)("POVerificationBadge.safe-harbour-no")))))));
|
|
40
|
-
};
|
|
41
|
-
exports.POVerificationBadge = POVerificationBadge;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="jsx-pdf" />
|
|
2
|
-
import type { AId } from "@raytio/types";
|
|
3
|
-
import { PdfConfig } from "../types";
|
|
4
|
-
import { EnvConfig } from "../../api";
|
|
5
|
-
import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
6
|
-
export declare const Report: ({ data, files, config, aId, clientUrl, envConfig, version, }: {
|
|
7
|
-
data: ProcessSubmissionOutput["json"];
|
|
8
|
-
files: ProcessSubmissionOutput["files"];
|
|
9
|
-
config: PdfConfig;
|
|
10
|
-
aId: AId;
|
|
11
|
-
clientUrl: string;
|
|
12
|
-
envConfig: EnvConfig;
|
|
13
|
-
version: string;
|
|
14
|
-
}) => JSX.Element;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Report = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const crypto_1 = require("crypto");
|
|
9
|
-
const core_1 = require("@raytio/core");
|
|
10
|
-
const locales_1 = require("../../locales");
|
|
11
|
-
const POVerificationBadge_1 = require("./POVerificationBadge");
|
|
12
|
-
const Subheader_1 = require("./Subheader");
|
|
13
|
-
const TableTitle_1 = require("./TableTitle");
|
|
14
|
-
const Table_1 = require("./Table");
|
|
15
|
-
const style_1 = require("../style");
|
|
16
|
-
const general_1 = require("../helpers/general");
|
|
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 Report = ({ data, files, config, aId, clientUrl, envConfig, version, }) => {
|
|
22
|
-
// The PDF is read only; there's no reason why anyone would ever need to unlock it.
|
|
23
|
-
const randomToken = (0, crypto_1.randomBytes)(32).toString("base64");
|
|
24
|
-
const schemas = Object.values(data.profile_objects).sort(
|
|
25
|
-
// sort it so that the person schema comes first
|
|
26
|
-
(a, b) => {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
return +(((_a = b[0]) === null || _a === void 0 ? void 0 : _a.$schemaName) === constants_2.SCHEMA.PERSON) -
|
|
29
|
-
+(((_b = a[0]) === null || _b === void 0 ? void 0 : _b.$schemaName) === constants_2.SCHEMA.PERSON);
|
|
30
|
-
});
|
|
31
|
-
const appName = envConfig.app_name;
|
|
32
|
-
return (jsx_pdf_1.default.createElement("document", { defaultStyle: { font: "Lato", fontSize: 12 }, info: {
|
|
33
|
-
title: (0, locales_1.$$)("Report.meta.title", { appName, iId: data.i_id }),
|
|
34
|
-
creator: appName,
|
|
35
|
-
producer: "Raytio",
|
|
36
|
-
subject: version,
|
|
37
|
-
},
|
|
38
|
-
// @ts-expect-error -- waiting on bpampuch/pdfmake#2453
|
|
39
|
-
lang: global.lang, ownerPassword: randomToken, permissions: {
|
|
40
|
-
printing: "highResolution",
|
|
41
|
-
copying: true, // allow copy/paste
|
|
42
|
-
}, pageSize: "A4", styles: style_1.classes, images: {
|
|
43
|
-
raytioLogo: envConfig.logo_url
|
|
44
|
-
? (0, general_1.asset)("custom-logo.png")
|
|
45
|
-
: (0, general_1.asset)("logo.png"),
|
|
46
|
-
} },
|
|
47
|
-
jsx_pdf_1.default.createElement("header", null, (currentPage) => currentPage !== 1 && (jsx_pdf_1.default.createElement("stack", { color: "#333", fontSize: 10 },
|
|
48
|
-
jsx_pdf_1.default.createElement("text", { margin: 16 },
|
|
49
|
-
jsx_pdf_1.default.createElement("text", { bold: true },
|
|
50
|
-
(0, locales_1.$$)("Report.header", { appName }),
|
|
51
|
-
" - "),
|
|
52
|
-
jsx_pdf_1.default.createElement("text", null, data.i_id))))),
|
|
53
|
-
jsx_pdf_1.default.createElement("content", null,
|
|
54
|
-
jsx_pdf_1.default.createElement("image", { src: "raytioLogo", width: 150, alignment: "center" }),
|
|
55
|
-
jsx_pdf_1.default.createElement("text", { style: ["header", "marginBottom"], alignment: "center" }, (0, locales_1.$$)("Report.header", { appName })),
|
|
56
|
-
jsx_pdf_1.default.createElement("columns", { columnGap: 10 },
|
|
57
|
-
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
58
|
-
jsx_pdf_1.default.createElement("text", { style: ["subheader", "marginBottom"] },
|
|
59
|
-
Object.entries(constants_1.SUBMISSION_DATA)
|
|
60
|
-
.map(([id, label]) => `${label}: ${(0, transform_1.transform)(id, data[id], config)}`)
|
|
61
|
-
.join("\n"),
|
|
62
|
-
(0, core_1.isScoreResultValid)(data.score)
|
|
63
|
-
? [
|
|
64
|
-
"",
|
|
65
|
-
`${(0, locales_1.$$)("constants.score")}: ${data.score.score}`,
|
|
66
|
-
`${(0, locales_1.$$)("constants.score-category")}: ${data.score.category}`,
|
|
67
|
-
].join("\n")
|
|
68
|
-
: ""),
|
|
69
|
-
jsx_pdf_1.default.createElement(Subheader_1.Subheader, { data: data, config: config })),
|
|
70
|
-
jsx_pdf_1.default.createElement("column", { width: "*" },
|
|
71
|
-
jsx_pdf_1.default.createElement("text", null, " ")),
|
|
72
|
-
jsx_pdf_1.default.createElement("column", { width: 150 },
|
|
73
|
-
jsx_pdf_1.default.createElement(VerifyBox_1.VerifyBox, { aId: aId, iId: data.i_id, clientUrl: clientUrl }))),
|
|
74
|
-
schemas.map((POs) => {
|
|
75
|
-
// for each schema
|
|
76
|
-
return (jsx_pdf_1.default.createElement("stack", {
|
|
77
|
-
// unbreakable is off because it crashes if its too big for one page
|
|
78
|
-
// This is a 7-year-old issue in pdfmake (https://github.com/bpampuch/pdfmake/issues/207)
|
|
79
|
-
unbreakable: false, style: "marginY" },
|
|
80
|
-
jsx_pdf_1.default.createElement(TableTitle_1.TableTitle, { POs: POs }),
|
|
81
|
-
jsx_pdf_1.default.createElement("columns", { columnGap: 15 },
|
|
82
|
-
jsx_pdf_1.default.createElement("column", { width: 80 },
|
|
83
|
-
jsx_pdf_1.default.createElement(POVerificationBadge_1.POVerificationBadge, { width: 80, POs: POs })),
|
|
84
|
-
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
85
|
-
jsx_pdf_1.default.createElement(Table_1.Table, { POs: POs, files: files, config: config })))));
|
|
86
|
-
})),
|
|
87
|
-
jsx_pdf_1.default.createElement("footer", null, (currentPage, pageCount, pageSize) => (jsx_pdf_1.default.createElement("stack", { bold: true, color: "#333", fontSize: 10 },
|
|
88
|
-
jsx_pdf_1.default.createElement("text", { margin: 16 },
|
|
89
|
-
jsx_pdf_1.default.createElement("text", null,
|
|
90
|
-
(0, locales_1.$$)("Report.header", { appName }),
|
|
91
|
-
" - "),
|
|
92
|
-
jsx_pdf_1.default.createElement("text", { color: "#fb7171" }, (0, locales_1.$$)("Report.footer-private"))),
|
|
93
|
-
jsx_pdf_1.default.createElement("text", { absolutePosition: { x: pageSize.width - 50, y: 15 } }, (0, locales_1.$$)("Report.pagecount", { currentPage, pageCount })))))));
|
|
94
|
-
};
|
|
95
|
-
exports.Report = Report;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
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,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="jsx-pdf" />
|
|
2
|
-
import { PdfConfig } from "../types";
|
|
3
|
-
import { FlatPO } from "../../helpers";
|
|
4
|
-
import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
5
|
-
export declare const Table: ({ POs, files, config, }: {
|
|
6
|
-
POs: FlatPO[];
|
|
7
|
-
files: ProcessSubmissionOutput["files"];
|
|
8
|
-
config: PdfConfig;
|
|
9
|
-
}) => JSX.Element;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Table = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
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, }) => {
|
|
14
|
-
/** every fieldName in these profile object */
|
|
15
|
-
const fieldNames = [
|
|
16
|
-
...new Set(POs.flatMap((PO) => Object.keys(PO.$properties))),
|
|
17
|
-
];
|
|
18
|
-
// some or all POs in this schema are files themselves. So render the file, assuming it's an image
|
|
19
|
-
const fileNIds = POs.filter(helpers_1.isPOFile).map((x) => x.$nId);
|
|
20
|
-
if (fileNIds.length)
|
|
21
|
-
return jsx_pdf_1.default.createElement(Images_1.Images, { nIds: fileNIds, files: files });
|
|
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(helpers_1.isFieldValueFile));
|
|
23
|
-
return (jsx_pdf_1.default.createElement("table", { layout: "noBorders" }, fieldNames.map((fieldName) => {
|
|
24
|
-
var _a;
|
|
25
|
-
return (jsx_pdf_1.default.createElement("row", null,
|
|
26
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
27
|
-
jsx_pdf_1.default.createElement("text", { color: "#12130e" }, ((_a = POs.find((PO) => PO.$properties[fieldName])) === null || _a === void 0 ? void 0 : _a.$properties[fieldName].title) || fieldName)),
|
|
28
|
-
POs.flatMap((PO) => {
|
|
29
|
-
(0, helpers_1.assertSafeProperty)(fieldName);
|
|
30
|
-
// if we're sharing multiple POs in this schema, and this field doesn't exist on this paticular PO,
|
|
31
|
-
// then just render some empty cells
|
|
32
|
-
if (!PO.$properties[fieldName]) {
|
|
33
|
-
return [jsx_pdf_1.default.createElement("cell", null, " "), jsx_pdf_1.default.createElement("cell", null, " ")];
|
|
34
|
-
}
|
|
35
|
-
const { value, formatted_value, verification } = PO.$properties[fieldName];
|
|
36
|
-
const color = (0, general_1.verifyColour)(verification);
|
|
37
|
-
// jsx-pdf currently doesn't support fragments, will make a PR at some point
|
|
38
|
-
return [
|
|
39
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
40
|
-
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: verification })),
|
|
41
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
42
|
-
jsx_pdf_1.default.createElement(InnerTableRows_1.InnerTableRows, { key: fieldName, value: formatted_value || value, files: files, config: config, color: color, imageFieldNames: imageFieldNames })),
|
|
43
|
-
];
|
|
44
|
-
})));
|
|
45
|
-
})));
|
|
46
|
-
};
|
|
47
|
-
exports.Table = Table;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
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 }) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const schemaTitle = POs[0].$schemaTitle;
|
|
12
|
-
const maybeFileName = POs.some(helpers_1.isPOFile)
|
|
13
|
-
? (_a = POs[0].$properties.title) === null || _a === void 0 ? void 0 : _a.value
|
|
14
|
-
: undefined;
|
|
15
|
-
return (jsx_pdf_1.default.createElement("text", { bold: true, fontSize: 14, style: "marginBottom" }, maybeFileName || schemaTitle));
|
|
16
|
-
};
|
|
17
|
-
exports.TableTitle = TableTitle;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
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");
|
|
11
|
-
const SEVERITY_COLOURS = {
|
|
12
|
-
low: "#2e8bc0",
|
|
13
|
-
medium: "#ff9800",
|
|
14
|
-
high: "#fb7171",
|
|
15
|
-
};
|
|
16
|
-
const ValidationDisplay = ({ value, }) => {
|
|
17
|
-
const colour = value.score > 0.5 ? "#c2d887" : "#fb7171";
|
|
18
|
-
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
19
|
-
jsx_pdf_1.default.createElement("svg", { content: (0, pieChart_1.pieChart)(colour, value.score * 100), width: 50 }),
|
|
20
|
-
(0, locales_1.$$)("ValidationDisplay.text", { n: value.score * 10 }),
|
|
21
|
-
Object.values(value.breakdown)
|
|
22
|
-
.filter((x) => x.severity && x.reason)
|
|
23
|
-
.map((x) => {
|
|
24
|
-
const key = x.severity;
|
|
25
|
-
(0, helpers_1.assertSafeProperty)(key);
|
|
26
|
-
return jsx_pdf_1.default.createElement("text", { color: SEVERITY_COLOURS[key] }, x.reason);
|
|
27
|
-
})));
|
|
28
|
-
};
|
|
29
|
-
exports.ValidationDisplay = ValidationDisplay;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.VerifyBox = void 0;
|
|
7
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
-
const locales_1 = require("../../locales");
|
|
9
|
-
const VerifyBox = ({ aId, iId, clientUrl }) => {
|
|
10
|
-
const url = `${clientUrl}/apps/s/${aId}/i/${iId}`;
|
|
11
|
-
return (jsx_pdf_1.default.createElement("stack", { alignment: "center" },
|
|
12
|
-
jsx_pdf_1.default.createElement("text", { link: url }, (0, locales_1.$$)("VerifyBox.text")),
|
|
13
|
-
jsx_pdf_1.default.createElement("qr", { content: url, fit: 150 }),
|
|
14
|
-
jsx_pdf_1.default.createElement("text", { color: "#1e90ff", fontSize: 9, link: url, alignment: "left" }, url)));
|
|
15
|
-
};
|
|
16
|
-
exports.VerifyBox = VerifyBox;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pieChart = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A semi-cirle pie chart
|
|
6
|
-
* (!) generates a SVG string, not a JSX component.
|
|
7
|
-
* @param percentage a number from 0 to 100
|
|
8
|
-
*/
|
|
9
|
-
function pieChart(colour, percentage) {
|
|
10
|
-
return `
|
|
11
|
-
<svg height="70" width="140" viewBox="0 -5 20 15">
|
|
12
|
-
<circle r="10" cx="10" cy="10" fill="bisque" />
|
|
13
|
-
<circle
|
|
14
|
-
r="5"
|
|
15
|
-
cx="10"
|
|
16
|
-
cy="10"
|
|
17
|
-
fill="white"
|
|
18
|
-
stroke="${colour}"
|
|
19
|
-
stroke-width="10"
|
|
20
|
-
stroke-dasharray="${(((percentage / 2) * 31.42) / 100).toFixed(2 // NOTE: css calc() doesn't work in PDFs
|
|
21
|
-
)} 31.42"
|
|
22
|
-
transform="rotate(-180) translate(-20, -20)"
|
|
23
|
-
/>
|
|
24
|
-
</svg>
|
|
25
|
-
`;
|
|
26
|
-
}
|
|
27
|
-
exports.pieChart = pieChart;
|
package/dist/pdf/constants.d.ts
DELETED
package/dist/pdf/constants.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUBMISSION_DATA = void 0;
|
|
4
|
-
const locales_1 = require("../locales");
|
|
5
|
-
exports.SUBMISSION_DATA = {
|
|
6
|
-
confirmation_code: (0, locales_1.$$)("constants.confirmation_code"),
|
|
7
|
-
i_id: (0, locales_1.$$)("constants.i_id"),
|
|
8
|
-
reference: (0, locales_1.$$)("constants.reference"),
|
|
9
|
-
start_date: (0, locales_1.$$)("constants.start_date"),
|
|
10
|
-
end_date: (0, locales_1.$$)("constants.end_date"),
|
|
11
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FieldVerification, POVerification } from "@raytio/types";
|
|
2
|
-
export declare const asset: (name: string) => string;
|
|
3
|
-
export declare const loadAsset: (name: string) => string;
|
|
4
|
-
export declare const verifyColour: (x: FieldVerification | POVerification) => string;
|
|
5
|
-
/**
|
|
6
|
-
* Produces a date with a long month
|
|
7
|
-
*/
|
|
8
|
-
export declare const formatDate: (d: Date, locale: string, timeZone: string) => string;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatDate = exports.verifyColour = exports.loadAsset = exports.asset = void 0;
|
|
4
|
-
const types_1 = require("@raytio/types");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const asset = (name) => {
|
|
8
|
-
if (name.match(/[^A-Za-z\-_.]/) || name.includes("..")) {
|
|
9
|
-
throw new Error("Invalid asset name");
|
|
10
|
-
}
|
|
11
|
-
return (0, path_1.join)(__dirname, "../../../assets/", name);
|
|
12
|
-
};
|
|
13
|
-
exports.asset = asset;
|
|
14
|
-
const loadAsset = (name) => (0, fs_1.readFileSync)((0, exports.asset)(name), { encoding: "utf-8" });
|
|
15
|
-
exports.loadAsset = loadAsset;
|
|
16
|
-
const verifyColour = (x) => {
|
|
17
|
-
if (x === types_1.FieldVerification.Verified)
|
|
18
|
-
return "#12130e";
|
|
19
|
-
if (x === types_1.FieldVerification.VerifiedFalse ||
|
|
20
|
-
x === types_1.POVerification.VerifiedFalse) {
|
|
21
|
-
return "#fb7171";
|
|
22
|
-
}
|
|
23
|
-
return "#000";
|
|
24
|
-
};
|
|
25
|
-
exports.verifyColour = verifyColour;
|
|
26
|
-
/**
|
|
27
|
-
* Produces a date with a long month
|
|
28
|
-
*/
|
|
29
|
-
const formatDate = (d, locale, timeZone) => new Intl.DateTimeFormat(locale, {
|
|
30
|
-
day: "2-digit",
|
|
31
|
-
month: "long",
|
|
32
|
-
year: "numeric",
|
|
33
|
-
hour: "numeric",
|
|
34
|
-
minute: "numeric",
|
|
35
|
-
timeZone,
|
|
36
|
-
}).format(d);
|
|
37
|
-
exports.formatDate = formatDate;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PdfConfig } from "../types";
|
|
2
|
-
export declare const IS_IMAGE: unique symbol;
|
|
3
|
-
export declare const IS_ARRAY_OF_OBJECTS: unique symbol;
|
|
4
|
-
export declare function transform(key: string, value: unknown, pdfConfig: PdfConfig, imageFieldNames?: string[]): string | typeof IS_IMAGE | typeof IS_ARRAY_OF_OBJECTS;
|