@finsys/core 2.1.0 → 2.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/dist/index.cjs +126 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +123 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
BASE_FIELD_SPECS: () => BASE_FIELD_SPECS,
|
|
34
34
|
BasicFormField: () => BasicFormField,
|
|
35
35
|
DEFAULT_VALIDATOR_DEFINITIONS: () => DEFAULT_VALIDATOR_DEFINITIONS,
|
|
36
|
+
DocExtractionStatus: () => DocExtractionStatus,
|
|
36
37
|
ExtractionFileType: () => ExtractionFileType,
|
|
37
38
|
ExtractionJobStatus: () => ExtractionJobStatus,
|
|
38
39
|
FIELD_TYPE_DEFINITIONS: () => FIELD_TYPE_DEFINITIONS,
|
|
@@ -58,6 +59,7 @@ __export(index_exports, {
|
|
|
58
59
|
getCategoryName: () => getCategoryName,
|
|
59
60
|
getDisplayName: () => getDisplayName,
|
|
60
61
|
getDisplayNames: () => getDisplayNames,
|
|
62
|
+
getGroupDisplayNames: () => getGroupDisplayNames,
|
|
61
63
|
getPastMonthLabel: () => getPastMonthLabel,
|
|
62
64
|
getPastYearLabel: () => getPastYearLabel,
|
|
63
65
|
getStepDefaultValues: () => getStepDefaultValues,
|
|
@@ -67,6 +69,7 @@ __export(index_exports, {
|
|
|
67
69
|
groupFieldsByCategory: () => groupFieldsByCategory,
|
|
68
70
|
groupFieldsByPattern: () => groupFieldsByPattern,
|
|
69
71
|
processIhsDetails: () => processIhsDetails,
|
|
72
|
+
resolveExtractionStatus: () => resolveExtractionStatus,
|
|
70
73
|
resolvePageFields: () => resolvePageFields,
|
|
71
74
|
validateFormConfig: () => validateFormConfig,
|
|
72
75
|
validateFormSpec: () => validateFormSpec,
|
|
@@ -9397,9 +9400,9 @@ var FIELD_GROUP_PREFIXES = [
|
|
|
9397
9400
|
["financials", "financials"],
|
|
9398
9401
|
["epf_statement", "epf_statements"],
|
|
9399
9402
|
["payslip_statement", "payslip_statements"],
|
|
9400
|
-
["ssm", "
|
|
9403
|
+
["ssm", "ssm_documents"],
|
|
9401
9404
|
["form9", "form9"],
|
|
9402
|
-
["ic", "
|
|
9405
|
+
["ic", "ic_documents"]
|
|
9403
9406
|
];
|
|
9404
9407
|
function groupFieldsByPattern(fields) {
|
|
9405
9408
|
const groups = {};
|
|
@@ -9423,9 +9426,12 @@ var GROUP_DISPLAY_NAMES = {
|
|
|
9423
9426
|
epf_statements: "EPF Statements",
|
|
9424
9427
|
payslip_statements: "Payslip Statements",
|
|
9425
9428
|
form9: "Form 9 / Section 17 / Form D",
|
|
9426
|
-
|
|
9427
|
-
|
|
9429
|
+
ssm_documents: "SSM Company Information",
|
|
9430
|
+
ic_documents: "Identification Card"
|
|
9428
9431
|
};
|
|
9432
|
+
function getGroupDisplayNames() {
|
|
9433
|
+
return GROUP_DISPLAY_NAMES;
|
|
9434
|
+
}
|
|
9429
9435
|
function isNumericField(fieldName) {
|
|
9430
9436
|
const patterns = [
|
|
9431
9437
|
"balance",
|
|
@@ -9642,11 +9648,125 @@ var ExtractionFileType = /* @__PURE__ */ ((ExtractionFileType2) => {
|
|
|
9642
9648
|
ExtractionFileType2["Ic"] = "ic";
|
|
9643
9649
|
return ExtractionFileType2;
|
|
9644
9650
|
})(ExtractionFileType || {});
|
|
9651
|
+
|
|
9652
|
+
// src/extraction-status.ts
|
|
9653
|
+
var DocExtractionStatus = /* @__PURE__ */ ((DocExtractionStatus2) => {
|
|
9654
|
+
DocExtractionStatus2["NotUploaded"] = "not_uploaded";
|
|
9655
|
+
DocExtractionStatus2["Uploaded"] = "uploaded";
|
|
9656
|
+
DocExtractionStatus2["Queued"] = "queued";
|
|
9657
|
+
DocExtractionStatus2["Processing"] = "processing";
|
|
9658
|
+
DocExtractionStatus2["Extracted"] = "extracted";
|
|
9659
|
+
DocExtractionStatus2["Failed"] = "failed";
|
|
9660
|
+
DocExtractionStatus2["Unknown"] = "unknown";
|
|
9661
|
+
return DocExtractionStatus2;
|
|
9662
|
+
})(DocExtractionStatus || {});
|
|
9663
|
+
var FILE_TYPE_TO_GROUP = {
|
|
9664
|
+
["bankStatements" /* BankStatement */]: "bank_statements",
|
|
9665
|
+
["financialStatements" /* FinancialStatement */]: "financials",
|
|
9666
|
+
["epfStatements" /* Epf */]: "epf_statements",
|
|
9667
|
+
["payslips" /* Payslip */]: "payslip_statements",
|
|
9668
|
+
["ssm" /* Ssm */]: "ssm_documents",
|
|
9669
|
+
["form9" /* Form9 */]: "form9",
|
|
9670
|
+
["ic" /* Ic */]: "ic_documents"
|
|
9671
|
+
};
|
|
9672
|
+
var _specs = getBaseFieldSpecs();
|
|
9673
|
+
var _fileFields = _specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
|
|
9674
|
+
var _grouped = groupFieldsByPattern(_fileFields);
|
|
9675
|
+
var _groupDisplayNames = getGroupDisplayNames();
|
|
9676
|
+
function isPopulated(value) {
|
|
9677
|
+
if (value === null || value === void 0 || value === "") return false;
|
|
9678
|
+
if (value === "Not Specified") return false;
|
|
9679
|
+
return true;
|
|
9680
|
+
}
|
|
9681
|
+
function hasUploadedFile(fields, ihsRecord) {
|
|
9682
|
+
return fields.some((field) => {
|
|
9683
|
+
if (!field.name) return false;
|
|
9684
|
+
return isPopulated(ihsRecord[field.name]);
|
|
9685
|
+
});
|
|
9686
|
+
}
|
|
9687
|
+
function getExtractionColumns(fields) {
|
|
9688
|
+
const columns = [];
|
|
9689
|
+
for (const field of fields) {
|
|
9690
|
+
if (field.ihs_column_names) {
|
|
9691
|
+
columns.push(...field.ihs_column_names);
|
|
9692
|
+
}
|
|
9693
|
+
}
|
|
9694
|
+
return columns;
|
|
9695
|
+
}
|
|
9696
|
+
function getPopulatedColumns(columns, ihsRecord) {
|
|
9697
|
+
return columns.filter((col) => isPopulated(ihsRecord[col]));
|
|
9698
|
+
}
|
|
9699
|
+
function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
9700
|
+
const documents = [];
|
|
9701
|
+
for (const fileType of Object.values(ExtractionFileType)) {
|
|
9702
|
+
const groupName = FILE_TYPE_TO_GROUP[fileType];
|
|
9703
|
+
const fields = _grouped[groupName] ?? [];
|
|
9704
|
+
const displayName = _groupDisplayNames[groupName] ?? fileType;
|
|
9705
|
+
const uploaded = fields.length > 0 && hasUploadedFile(fields, ihsRecord);
|
|
9706
|
+
const allColumns = getExtractionColumns(fields);
|
|
9707
|
+
const populated = getPopulatedColumns(allColumns, ihsRecord);
|
|
9708
|
+
const hasExtractedData = populated.length > 0;
|
|
9709
|
+
let status;
|
|
9710
|
+
let errorMessage;
|
|
9711
|
+
if (!uploaded) {
|
|
9712
|
+
status = "not_uploaded" /* NotUploaded */;
|
|
9713
|
+
} else if (jobRecords) {
|
|
9714
|
+
const job = jobRecords.find((j) => j.fileType === fileType);
|
|
9715
|
+
if (job) {
|
|
9716
|
+
if (job.status === "queued" /* Queued */) {
|
|
9717
|
+
status = "queued" /* Queued */;
|
|
9718
|
+
} else if (job.status === "processing" /* Processing */) {
|
|
9719
|
+
status = "processing" /* Processing */;
|
|
9720
|
+
} else if (job.status === "failed" /* Failed */) {
|
|
9721
|
+
if (hasExtractedData) {
|
|
9722
|
+
status = "extracted" /* Extracted */;
|
|
9723
|
+
errorMessage = job.errorMessage;
|
|
9724
|
+
} else {
|
|
9725
|
+
status = "failed" /* Failed */;
|
|
9726
|
+
errorMessage = job.errorMessage;
|
|
9727
|
+
}
|
|
9728
|
+
} else if (job.status === "succeeded" /* Succeeded */ || hasExtractedData) {
|
|
9729
|
+
status = "extracted" /* Extracted */;
|
|
9730
|
+
} else {
|
|
9731
|
+
status = "uploaded" /* Uploaded */;
|
|
9732
|
+
}
|
|
9733
|
+
} else if (hasExtractedData) {
|
|
9734
|
+
status = "extracted" /* Extracted */;
|
|
9735
|
+
} else {
|
|
9736
|
+
status = "uploaded" /* Uploaded */;
|
|
9737
|
+
}
|
|
9738
|
+
} else if (hasExtractedData) {
|
|
9739
|
+
status = "extracted" /* Extracted */;
|
|
9740
|
+
} else {
|
|
9741
|
+
status = "unknown" /* Unknown */;
|
|
9742
|
+
}
|
|
9743
|
+
documents.push({
|
|
9744
|
+
fileType,
|
|
9745
|
+
status,
|
|
9746
|
+
displayName,
|
|
9747
|
+
populatedColumns: populated,
|
|
9748
|
+
totalColumns: allColumns.length,
|
|
9749
|
+
errorMessage
|
|
9750
|
+
});
|
|
9751
|
+
}
|
|
9752
|
+
const summary = documents.reduce(
|
|
9753
|
+
(acc, d) => {
|
|
9754
|
+
if (d.status === "extracted" /* Extracted */) acc.extracted++;
|
|
9755
|
+
else if (d.status === "failed" /* Failed */) acc.failed++;
|
|
9756
|
+
else if (d.status === "not_uploaded" /* NotUploaded */) acc.notUploaded++;
|
|
9757
|
+
else acc.pending++;
|
|
9758
|
+
return acc;
|
|
9759
|
+
},
|
|
9760
|
+
{ total: documents.length, extracted: 0, failed: 0, pending: 0, notUploaded: 0 }
|
|
9761
|
+
);
|
|
9762
|
+
return { documents, summary };
|
|
9763
|
+
}
|
|
9645
9764
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9646
9765
|
0 && (module.exports = {
|
|
9647
9766
|
BASE_FIELD_SPECS,
|
|
9648
9767
|
BasicFormField,
|
|
9649
9768
|
DEFAULT_VALIDATOR_DEFINITIONS,
|
|
9769
|
+
DocExtractionStatus,
|
|
9650
9770
|
ExtractionFileType,
|
|
9651
9771
|
ExtractionJobStatus,
|
|
9652
9772
|
FIELD_TYPE_DEFINITIONS,
|
|
@@ -9672,6 +9792,7 @@ var ExtractionFileType = /* @__PURE__ */ ((ExtractionFileType2) => {
|
|
|
9672
9792
|
getCategoryName,
|
|
9673
9793
|
getDisplayName,
|
|
9674
9794
|
getDisplayNames,
|
|
9795
|
+
getGroupDisplayNames,
|
|
9675
9796
|
getPastMonthLabel,
|
|
9676
9797
|
getPastYearLabel,
|
|
9677
9798
|
getStepDefaultValues,
|
|
@@ -9681,6 +9802,7 @@ var ExtractionFileType = /* @__PURE__ */ ((ExtractionFileType2) => {
|
|
|
9681
9802
|
groupFieldsByCategory,
|
|
9682
9803
|
groupFieldsByPattern,
|
|
9683
9804
|
processIhsDetails,
|
|
9805
|
+
resolveExtractionStatus,
|
|
9684
9806
|
resolvePageFields,
|
|
9685
9807
|
validateFormConfig,
|
|
9686
9808
|
validateFormSpec,
|