@finsys/core 2.3.0 → 2.4.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 +158 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -1
- package/dist/index.d.ts +60 -1
- package/dist/index.js +151 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,10 @@ __export(index_exports, {
|
|
|
44
44
|
FormFieldCategory: () => FormFieldCategory,
|
|
45
45
|
FormFieldValidator: () => FormFieldValidator,
|
|
46
46
|
FormSpec: () => FormSpec,
|
|
47
|
+
IHS_FAILURE_STATUSES: () => IHS_FAILURE_STATUSES,
|
|
48
|
+
IHS_TERMINAL_STATUSES: () => IHS_TERMINAL_STATUSES,
|
|
49
|
+
IHS_VALID_STATUSES: () => IHS_VALID_STATUSES,
|
|
50
|
+
IhsStatus: () => IhsStatus,
|
|
47
51
|
IhsValueFormat: () => IhsValueFormat,
|
|
48
52
|
Role: () => Role,
|
|
49
53
|
applyDynamicTitles: () => applyDynamicTitles,
|
|
@@ -68,6 +72,9 @@ __export(index_exports, {
|
|
|
68
72
|
groupDetailsByCategory: () => groupDetailsByCategory,
|
|
69
73
|
groupFieldsByCategory: () => groupFieldsByCategory,
|
|
70
74
|
groupFieldsByPattern: () => groupFieldsByPattern,
|
|
75
|
+
isFailureIhsStatus: () => isFailureIhsStatus,
|
|
76
|
+
isTerminalIhsStatus: () => isTerminalIhsStatus,
|
|
77
|
+
isValidIhsStatus: () => isValidIhsStatus,
|
|
71
78
|
processIhsDetails: () => processIhsDetails,
|
|
72
79
|
resolveExtractionStatus: () => resolveExtractionStatus,
|
|
73
80
|
resolvePageFields: () => resolvePageFields,
|
|
@@ -9574,9 +9581,12 @@ function processIhsDetails(ihsData) {
|
|
|
9574
9581
|
const specs = getBaseFieldSpecs();
|
|
9575
9582
|
const fileColumnSet = /* @__PURE__ */ new Set();
|
|
9576
9583
|
for (const field of specs) {
|
|
9577
|
-
if (field.type === "file"
|
|
9578
|
-
|
|
9579
|
-
|
|
9584
|
+
if (field.type === "file") {
|
|
9585
|
+
if (field.name) fileColumnSet.add(field.name);
|
|
9586
|
+
if (field.ihs_column_names) {
|
|
9587
|
+
for (const col of field.ihs_column_names) {
|
|
9588
|
+
fileColumnSet.add(col);
|
|
9589
|
+
}
|
|
9580
9590
|
}
|
|
9581
9591
|
}
|
|
9582
9592
|
}
|
|
@@ -9649,6 +9659,53 @@ var ExtractionFileType = /* @__PURE__ */ ((ExtractionFileType2) => {
|
|
|
9649
9659
|
return ExtractionFileType2;
|
|
9650
9660
|
})(ExtractionFileType || {});
|
|
9651
9661
|
|
|
9662
|
+
// src/ihs-status.ts
|
|
9663
|
+
var IhsStatus = /* @__PURE__ */ ((IhsStatus2) => {
|
|
9664
|
+
IhsStatus2["CreatingApplication"] = "CREATING_APPLICATION";
|
|
9665
|
+
IhsStatus2["ApplicationFinalized"] = "APPLICATION_FINALIZED";
|
|
9666
|
+
IhsStatus2["LenderEvaluation"] = "LENDER_EVALUATION";
|
|
9667
|
+
IhsStatus2["Approved"] = "APPROVED";
|
|
9668
|
+
IhsStatus2["LouDelivered"] = "LOU_DELIVERED";
|
|
9669
|
+
IhsStatus2["AwaitingDisbursement"] = "AWAITING_DISBURSEMENT";
|
|
9670
|
+
IhsStatus2["Disbursement"] = "DISBURSEMENT";
|
|
9671
|
+
IhsStatus2["Declined"] = "DECLINED";
|
|
9672
|
+
IhsStatus2["Expired"] = "EXPIRED";
|
|
9673
|
+
IhsStatus2["Canceled"] = "CANCELED";
|
|
9674
|
+
return IhsStatus2;
|
|
9675
|
+
})(IhsStatus || {});
|
|
9676
|
+
var IHS_VALID_STATUSES = [
|
|
9677
|
+
"CREATING_APPLICATION" /* CreatingApplication */,
|
|
9678
|
+
"APPLICATION_FINALIZED" /* ApplicationFinalized */,
|
|
9679
|
+
"LENDER_EVALUATION" /* LenderEvaluation */,
|
|
9680
|
+
"APPROVED" /* Approved */,
|
|
9681
|
+
"LOU_DELIVERED" /* LouDelivered */,
|
|
9682
|
+
"AWAITING_DISBURSEMENT" /* AwaitingDisbursement */,
|
|
9683
|
+
"DISBURSEMENT" /* Disbursement */,
|
|
9684
|
+
"DECLINED" /* Declined */,
|
|
9685
|
+
"EXPIRED" /* Expired */,
|
|
9686
|
+
"CANCELED" /* Canceled */
|
|
9687
|
+
];
|
|
9688
|
+
var IHS_TERMINAL_STATUSES = [
|
|
9689
|
+
"DISBURSEMENT" /* Disbursement */,
|
|
9690
|
+
"DECLINED" /* Declined */,
|
|
9691
|
+
"EXPIRED" /* Expired */,
|
|
9692
|
+
"CANCELED" /* Canceled */
|
|
9693
|
+
];
|
|
9694
|
+
var IHS_FAILURE_STATUSES = [
|
|
9695
|
+
"DECLINED" /* Declined */,
|
|
9696
|
+
"EXPIRED" /* Expired */,
|
|
9697
|
+
"CANCELED" /* Canceled */
|
|
9698
|
+
];
|
|
9699
|
+
function isValidIhsStatus(status) {
|
|
9700
|
+
return typeof status === "string" && IHS_VALID_STATUSES.includes(status);
|
|
9701
|
+
}
|
|
9702
|
+
function isTerminalIhsStatus(status) {
|
|
9703
|
+
return typeof status === "string" && IHS_TERMINAL_STATUSES.includes(status);
|
|
9704
|
+
}
|
|
9705
|
+
function isFailureIhsStatus(status) {
|
|
9706
|
+
return typeof status === "string" && IHS_FAILURE_STATUSES.includes(status);
|
|
9707
|
+
}
|
|
9708
|
+
|
|
9652
9709
|
// src/extraction-status.ts
|
|
9653
9710
|
var DocExtractionStatus = /* @__PURE__ */ ((DocExtractionStatus2) => {
|
|
9654
9711
|
DocExtractionStatus2["NotUploaded"] = "not_uploaded";
|
|
@@ -9678,59 +9735,45 @@ function isPopulated(value) {
|
|
|
9678
9735
|
if (value === "Not Specified") return false;
|
|
9679
9736
|
return true;
|
|
9680
9737
|
}
|
|
9681
|
-
function
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
if (field.ihs_column_names) {
|
|
9691
|
-
columns.push(...field.ihs_column_names);
|
|
9738
|
+
function countUploadedFiles(ihsRecord, aggregateKey) {
|
|
9739
|
+
const raw = ihsRecord[aggregateKey];
|
|
9740
|
+
if (!raw) return 0;
|
|
9741
|
+
if (typeof raw === "string") {
|
|
9742
|
+
try {
|
|
9743
|
+
const parsed = JSON.parse(raw);
|
|
9744
|
+
if (Array.isArray(parsed)) return parsed.length;
|
|
9745
|
+
} catch {
|
|
9746
|
+
return 1;
|
|
9692
9747
|
}
|
|
9693
9748
|
}
|
|
9694
|
-
return
|
|
9749
|
+
if (Array.isArray(raw)) return raw.length;
|
|
9750
|
+
return 1;
|
|
9695
9751
|
}
|
|
9696
9752
|
function getPopulatedColumns(columns, ihsRecord) {
|
|
9697
9753
|
return columns.filter((col) => isPopulated(ihsRecord[col]));
|
|
9698
9754
|
}
|
|
9699
|
-
function
|
|
9700
|
-
const
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
status
|
|
9713
|
-
|
|
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) {
|
|
9755
|
+
function resolveDocStatus(columns, ihsRecord, uploaded, jobRecord, hasJobRecords) {
|
|
9756
|
+
const populated = getPopulatedColumns(columns, ihsRecord);
|
|
9757
|
+
const hasExtractedData = populated.length > 0;
|
|
9758
|
+
let status;
|
|
9759
|
+
let errorMessage;
|
|
9760
|
+
if (!uploaded) {
|
|
9761
|
+
status = "not_uploaded" /* NotUploaded */;
|
|
9762
|
+
} else if (hasJobRecords) {
|
|
9763
|
+
if (jobRecord) {
|
|
9764
|
+
if (jobRecord.status === "queued" /* Queued */) {
|
|
9765
|
+
status = "queued" /* Queued */;
|
|
9766
|
+
} else if (jobRecord.status === "processing" /* Processing */) {
|
|
9767
|
+
status = "processing" /* Processing */;
|
|
9768
|
+
} else if (jobRecord.status === "failed" /* Failed */) {
|
|
9769
|
+
if (hasExtractedData) {
|
|
9729
9770
|
status = "extracted" /* Extracted */;
|
|
9771
|
+
errorMessage = jobRecord.errorMessage;
|
|
9730
9772
|
} else {
|
|
9731
|
-
status = "
|
|
9773
|
+
status = "failed" /* Failed */;
|
|
9774
|
+
errorMessage = jobRecord.errorMessage;
|
|
9732
9775
|
}
|
|
9733
|
-
} else if (hasExtractedData) {
|
|
9776
|
+
} else if (jobRecord.status === "succeeded" /* Succeeded */ || hasExtractedData) {
|
|
9734
9777
|
status = "extracted" /* Extracted */;
|
|
9735
9778
|
} else {
|
|
9736
9779
|
status = "uploaded" /* Uploaded */;
|
|
@@ -9738,16 +9781,68 @@ function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
|
9738
9781
|
} else if (hasExtractedData) {
|
|
9739
9782
|
status = "extracted" /* Extracted */;
|
|
9740
9783
|
} else {
|
|
9741
|
-
status = "
|
|
9784
|
+
status = "uploaded" /* Uploaded */;
|
|
9785
|
+
}
|
|
9786
|
+
} else if (hasExtractedData) {
|
|
9787
|
+
status = "extracted" /* Extracted */;
|
|
9788
|
+
} else {
|
|
9789
|
+
status = "unknown" /* Unknown */;
|
|
9790
|
+
}
|
|
9791
|
+
return { status, errorMessage };
|
|
9792
|
+
}
|
|
9793
|
+
function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
9794
|
+
const documents = [];
|
|
9795
|
+
const hasJobRecords = jobRecords !== void 0;
|
|
9796
|
+
for (const fileType of Object.values(ExtractionFileType)) {
|
|
9797
|
+
const groupName = FILE_TYPE_TO_GROUP[fileType];
|
|
9798
|
+
const fields = _grouped[groupName] ?? [];
|
|
9799
|
+
const displayName = _groupDisplayNames[groupName] ?? fileType;
|
|
9800
|
+
const uploadedCount = countUploadedFiles(ihsRecord, fileType);
|
|
9801
|
+
const isUploaded = uploadedCount > 0 || fields.some((f) => f.name && isPopulated(ihsRecord[f.name]));
|
|
9802
|
+
const matchingJobs = jobRecords?.filter((j) => j.fileType === fileType) ?? [];
|
|
9803
|
+
if (fields.length <= 1) {
|
|
9804
|
+
const field = fields[0];
|
|
9805
|
+
const columns = field?.ihs_column_names ?? [];
|
|
9806
|
+
const populated = getPopulatedColumns(columns, ihsRecord);
|
|
9807
|
+
const { status, errorMessage } = resolveDocStatus(
|
|
9808
|
+
columns,
|
|
9809
|
+
ihsRecord,
|
|
9810
|
+
isUploaded,
|
|
9811
|
+
matchingJobs[0],
|
|
9812
|
+
hasJobRecords
|
|
9813
|
+
);
|
|
9814
|
+
documents.push({
|
|
9815
|
+
fileType,
|
|
9816
|
+
status,
|
|
9817
|
+
displayName,
|
|
9818
|
+
populatedColumns: populated,
|
|
9819
|
+
totalColumns: columns.length,
|
|
9820
|
+
errorMessage
|
|
9821
|
+
});
|
|
9822
|
+
} else {
|
|
9823
|
+
const count = Math.max(uploadedCount, 1);
|
|
9824
|
+
for (let idx = 0; idx < count; idx++) {
|
|
9825
|
+
const field = fields[idx];
|
|
9826
|
+
const columns = field?.ihs_column_names ?? [];
|
|
9827
|
+
const populated = getPopulatedColumns(columns, ihsRecord);
|
|
9828
|
+
const fileUploaded = idx < uploadedCount;
|
|
9829
|
+
const { status, errorMessage } = resolveDocStatus(
|
|
9830
|
+
columns,
|
|
9831
|
+
ihsRecord,
|
|
9832
|
+
fileUploaded,
|
|
9833
|
+
matchingJobs[idx],
|
|
9834
|
+
hasJobRecords
|
|
9835
|
+
);
|
|
9836
|
+
documents.push({
|
|
9837
|
+
fileType,
|
|
9838
|
+
status,
|
|
9839
|
+
displayName,
|
|
9840
|
+
populatedColumns: populated,
|
|
9841
|
+
totalColumns: columns.length,
|
|
9842
|
+
errorMessage
|
|
9843
|
+
});
|
|
9844
|
+
}
|
|
9742
9845
|
}
|
|
9743
|
-
documents.push({
|
|
9744
|
-
fileType,
|
|
9745
|
-
status,
|
|
9746
|
-
displayName,
|
|
9747
|
-
populatedColumns: populated,
|
|
9748
|
-
totalColumns: allColumns.length,
|
|
9749
|
-
errorMessage
|
|
9750
|
-
});
|
|
9751
9846
|
}
|
|
9752
9847
|
const summary = documents.reduce(
|
|
9753
9848
|
(acc, d) => {
|
|
@@ -9777,6 +9872,10 @@ function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
|
9777
9872
|
FormFieldCategory,
|
|
9778
9873
|
FormFieldValidator,
|
|
9779
9874
|
FormSpec,
|
|
9875
|
+
IHS_FAILURE_STATUSES,
|
|
9876
|
+
IHS_TERMINAL_STATUSES,
|
|
9877
|
+
IHS_VALID_STATUSES,
|
|
9878
|
+
IhsStatus,
|
|
9780
9879
|
IhsValueFormat,
|
|
9781
9880
|
Role,
|
|
9782
9881
|
applyDynamicTitles,
|
|
@@ -9801,6 +9900,9 @@ function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
|
9801
9900
|
groupDetailsByCategory,
|
|
9802
9901
|
groupFieldsByCategory,
|
|
9803
9902
|
groupFieldsByPattern,
|
|
9903
|
+
isFailureIhsStatus,
|
|
9904
|
+
isTerminalIhsStatus,
|
|
9905
|
+
isValidIhsStatus,
|
|
9804
9906
|
processIhsDetails,
|
|
9805
9907
|
resolveExtractionStatus,
|
|
9806
9908
|
resolvePageFields,
|