@finsys/core 2.3.0 → 2.3.1
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 +97 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +97 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -9574,9 +9574,12 @@ function processIhsDetails(ihsData) {
|
|
|
9574
9574
|
const specs = getBaseFieldSpecs();
|
|
9575
9575
|
const fileColumnSet = /* @__PURE__ */ new Set();
|
|
9576
9576
|
for (const field of specs) {
|
|
9577
|
-
if (field.type === "file"
|
|
9578
|
-
|
|
9579
|
-
|
|
9577
|
+
if (field.type === "file") {
|
|
9578
|
+
if (field.name) fileColumnSet.add(field.name);
|
|
9579
|
+
if (field.ihs_column_names) {
|
|
9580
|
+
for (const col of field.ihs_column_names) {
|
|
9581
|
+
fileColumnSet.add(col);
|
|
9582
|
+
}
|
|
9580
9583
|
}
|
|
9581
9584
|
}
|
|
9582
9585
|
}
|
|
@@ -9678,59 +9681,45 @@ function isPopulated(value) {
|
|
|
9678
9681
|
if (value === "Not Specified") return false;
|
|
9679
9682
|
return true;
|
|
9680
9683
|
}
|
|
9681
|
-
function
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
if (field.ihs_column_names) {
|
|
9691
|
-
columns.push(...field.ihs_column_names);
|
|
9684
|
+
function countUploadedFiles(ihsRecord, aggregateKey) {
|
|
9685
|
+
const raw = ihsRecord[aggregateKey];
|
|
9686
|
+
if (!raw) return 0;
|
|
9687
|
+
if (typeof raw === "string") {
|
|
9688
|
+
try {
|
|
9689
|
+
const parsed = JSON.parse(raw);
|
|
9690
|
+
if (Array.isArray(parsed)) return parsed.length;
|
|
9691
|
+
} catch {
|
|
9692
|
+
return 1;
|
|
9692
9693
|
}
|
|
9693
9694
|
}
|
|
9694
|
-
return
|
|
9695
|
+
if (Array.isArray(raw)) return raw.length;
|
|
9696
|
+
return 1;
|
|
9695
9697
|
}
|
|
9696
9698
|
function getPopulatedColumns(columns, ihsRecord) {
|
|
9697
9699
|
return columns.filter((col) => isPopulated(ihsRecord[col]));
|
|
9698
9700
|
}
|
|
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) {
|
|
9701
|
+
function resolveDocStatus(columns, ihsRecord, uploaded, jobRecord, hasJobRecords) {
|
|
9702
|
+
const populated = getPopulatedColumns(columns, ihsRecord);
|
|
9703
|
+
const hasExtractedData = populated.length > 0;
|
|
9704
|
+
let status;
|
|
9705
|
+
let errorMessage;
|
|
9706
|
+
if (!uploaded) {
|
|
9707
|
+
status = "not_uploaded" /* NotUploaded */;
|
|
9708
|
+
} else if (hasJobRecords) {
|
|
9709
|
+
if (jobRecord) {
|
|
9710
|
+
if (jobRecord.status === "queued" /* Queued */) {
|
|
9711
|
+
status = "queued" /* Queued */;
|
|
9712
|
+
} else if (jobRecord.status === "processing" /* Processing */) {
|
|
9713
|
+
status = "processing" /* Processing */;
|
|
9714
|
+
} else if (jobRecord.status === "failed" /* Failed */) {
|
|
9715
|
+
if (hasExtractedData) {
|
|
9729
9716
|
status = "extracted" /* Extracted */;
|
|
9717
|
+
errorMessage = jobRecord.errorMessage;
|
|
9730
9718
|
} else {
|
|
9731
|
-
status = "
|
|
9719
|
+
status = "failed" /* Failed */;
|
|
9720
|
+
errorMessage = jobRecord.errorMessage;
|
|
9732
9721
|
}
|
|
9733
|
-
} else if (hasExtractedData) {
|
|
9722
|
+
} else if (jobRecord.status === "succeeded" /* Succeeded */ || hasExtractedData) {
|
|
9734
9723
|
status = "extracted" /* Extracted */;
|
|
9735
9724
|
} else {
|
|
9736
9725
|
status = "uploaded" /* Uploaded */;
|
|
@@ -9738,16 +9727,68 @@ function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
|
9738
9727
|
} else if (hasExtractedData) {
|
|
9739
9728
|
status = "extracted" /* Extracted */;
|
|
9740
9729
|
} else {
|
|
9741
|
-
status = "
|
|
9730
|
+
status = "uploaded" /* Uploaded */;
|
|
9731
|
+
}
|
|
9732
|
+
} else if (hasExtractedData) {
|
|
9733
|
+
status = "extracted" /* Extracted */;
|
|
9734
|
+
} else {
|
|
9735
|
+
status = "unknown" /* Unknown */;
|
|
9736
|
+
}
|
|
9737
|
+
return { status, errorMessage };
|
|
9738
|
+
}
|
|
9739
|
+
function resolveExtractionStatus(ihsRecord, jobRecords) {
|
|
9740
|
+
const documents = [];
|
|
9741
|
+
const hasJobRecords = jobRecords !== void 0;
|
|
9742
|
+
for (const fileType of Object.values(ExtractionFileType)) {
|
|
9743
|
+
const groupName = FILE_TYPE_TO_GROUP[fileType];
|
|
9744
|
+
const fields = _grouped[groupName] ?? [];
|
|
9745
|
+
const displayName = _groupDisplayNames[groupName] ?? fileType;
|
|
9746
|
+
const uploadedCount = countUploadedFiles(ihsRecord, fileType);
|
|
9747
|
+
const isUploaded = uploadedCount > 0 || fields.some((f) => f.name && isPopulated(ihsRecord[f.name]));
|
|
9748
|
+
const matchingJobs = jobRecords?.filter((j) => j.fileType === fileType) ?? [];
|
|
9749
|
+
if (fields.length <= 1) {
|
|
9750
|
+
const field = fields[0];
|
|
9751
|
+
const columns = field?.ihs_column_names ?? [];
|
|
9752
|
+
const populated = getPopulatedColumns(columns, ihsRecord);
|
|
9753
|
+
const { status, errorMessage } = resolveDocStatus(
|
|
9754
|
+
columns,
|
|
9755
|
+
ihsRecord,
|
|
9756
|
+
isUploaded,
|
|
9757
|
+
matchingJobs[0],
|
|
9758
|
+
hasJobRecords
|
|
9759
|
+
);
|
|
9760
|
+
documents.push({
|
|
9761
|
+
fileType,
|
|
9762
|
+
status,
|
|
9763
|
+
displayName,
|
|
9764
|
+
populatedColumns: populated,
|
|
9765
|
+
totalColumns: columns.length,
|
|
9766
|
+
errorMessage
|
|
9767
|
+
});
|
|
9768
|
+
} else {
|
|
9769
|
+
const count = Math.max(uploadedCount, 1);
|
|
9770
|
+
for (let idx = 0; idx < count; idx++) {
|
|
9771
|
+
const field = fields[idx];
|
|
9772
|
+
const columns = field?.ihs_column_names ?? [];
|
|
9773
|
+
const populated = getPopulatedColumns(columns, ihsRecord);
|
|
9774
|
+
const fileUploaded = idx < uploadedCount;
|
|
9775
|
+
const { status, errorMessage } = resolveDocStatus(
|
|
9776
|
+
columns,
|
|
9777
|
+
ihsRecord,
|
|
9778
|
+
fileUploaded,
|
|
9779
|
+
matchingJobs[idx],
|
|
9780
|
+
hasJobRecords
|
|
9781
|
+
);
|
|
9782
|
+
documents.push({
|
|
9783
|
+
fileType,
|
|
9784
|
+
status,
|
|
9785
|
+
displayName,
|
|
9786
|
+
populatedColumns: populated,
|
|
9787
|
+
totalColumns: columns.length,
|
|
9788
|
+
errorMessage
|
|
9789
|
+
});
|
|
9790
|
+
}
|
|
9742
9791
|
}
|
|
9743
|
-
documents.push({
|
|
9744
|
-
fileType,
|
|
9745
|
-
status,
|
|
9746
|
-
displayName,
|
|
9747
|
-
populatedColumns: populated,
|
|
9748
|
-
totalColumns: allColumns.length,
|
|
9749
|
-
errorMessage
|
|
9750
|
-
});
|
|
9751
9792
|
}
|
|
9752
9793
|
const summary = documents.reduce(
|
|
9753
9794
|
(acc, d) => {
|