@finsys/core 3.3.0 → 3.5.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/data/form-field-base-specs.json +1 -1
- package/dist/data/form-field-display-names.json +0 -1
- package/dist/index.cjs +158 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -1
- package/dist/index.d.ts +100 -1
- package/dist/index.js +150 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -148,7 +148,6 @@
|
|
|
148
148
|
"companyRegNo": "Company Registration No.",
|
|
149
149
|
"ssmCompanyName": "Company Name (SSM)",
|
|
150
150
|
"ssmCompanyRegNo": "Registration No. (SSM)",
|
|
151
|
-
"ssmIncorporatedDate": "Incorporated Date (SSM)",
|
|
152
151
|
"ssmCompanyEntityType": "Entity Type (SSM)",
|
|
153
152
|
"ssmPaidUpCapital": "Paid-Up Capital (SSM)",
|
|
154
153
|
"businessCommencementDate": "Business Commencement Date",
|
package/dist/index.cjs
CHANGED
|
@@ -57,12 +57,16 @@ __export(index_exports, {
|
|
|
57
57
|
applyAggregation: () => applyAggregation,
|
|
58
58
|
applyDynamicTitles: () => applyDynamicTitles,
|
|
59
59
|
assertAdapterCategory: () => assertAdapterCategory,
|
|
60
|
+
buildDocumentRows: () => buildDocumentRows,
|
|
60
61
|
buildFileFieldTables: () => buildFileFieldTables,
|
|
61
62
|
categoryFieldsOf: () => categoryFieldsOf,
|
|
62
63
|
categoryForField: () => categoryForField,
|
|
63
64
|
categorySchemaOf: () => categorySchemaOf,
|
|
64
65
|
evaluateExpression: () => evaluateExpression,
|
|
65
66
|
extractTimePeriods: () => extractTimePeriods,
|
|
67
|
+
formatDocumentSize: () => formatDocumentSize,
|
|
68
|
+
formatDocumentType: () => formatDocumentType,
|
|
69
|
+
formatDocumentUploaded: () => formatDocumentUploaded,
|
|
66
70
|
generateRHFSchema: () => generateRHFSchema,
|
|
67
71
|
generateSurveyJson: () => generateSurveyJson,
|
|
68
72
|
getBaseCategories: () => getBaseCategories,
|
|
@@ -72,9 +76,12 @@ __export(index_exports, {
|
|
|
72
76
|
getCategoryName: () => getCategoryName,
|
|
73
77
|
getDisplayName: () => getDisplayName,
|
|
74
78
|
getDisplayNames: () => getDisplayNames,
|
|
79
|
+
getDocDisplayNames: () => getDocDisplayNames,
|
|
80
|
+
getExtractableDocTypes: () => getExtractableDocTypes,
|
|
75
81
|
getGroupDisplayNames: () => getGroupDisplayNames,
|
|
76
82
|
getPastMonthLabel: () => getPastMonthLabel,
|
|
77
83
|
getPastYearLabel: () => getPastYearLabel,
|
|
84
|
+
getReuploadableDocTypes: () => getReuploadableDocTypes,
|
|
78
85
|
getStepDefaultValues: () => getStepDefaultValues,
|
|
79
86
|
getStepSchema: () => getStepSchema,
|
|
80
87
|
groupColumnsByTimePeriod: () => groupColumnsByTimePeriod,
|
|
@@ -85,6 +92,7 @@ __export(index_exports, {
|
|
|
85
92
|
isFailureIhsStatus: () => isFailureIhsStatus,
|
|
86
93
|
isTerminalIhsStatus: () => isTerminalIhsStatus,
|
|
87
94
|
isValidIhsStatus: () => isValidIhsStatus,
|
|
95
|
+
parseFileField: () => parseFileField,
|
|
88
96
|
processIhsDetails: () => processIhsDetails,
|
|
89
97
|
resolveExtractionStatus: () => resolveExtractionStatus,
|
|
90
98
|
resolvePageFields: () => resolvePageFields,
|
|
@@ -8485,7 +8493,7 @@ var form_field_base_specs_default = {
|
|
|
8485
8493
|
ihs_column_names: [
|
|
8486
8494
|
"ssmCompanyName",
|
|
8487
8495
|
"ssmCompanyRegNo",
|
|
8488
|
-
"
|
|
8496
|
+
"incorporatedDate",
|
|
8489
8497
|
"businessCommencementDate",
|
|
8490
8498
|
"businessNature",
|
|
8491
8499
|
"ssmCompanyEntityType",
|
|
@@ -9334,7 +9342,6 @@ var form_field_display_names_default = {
|
|
|
9334
9342
|
companyRegNo: "Company Registration No.",
|
|
9335
9343
|
ssmCompanyName: "Company Name (SSM)",
|
|
9336
9344
|
ssmCompanyRegNo: "Registration No. (SSM)",
|
|
9337
|
-
ssmIncorporatedDate: "Incorporated Date (SSM)",
|
|
9338
9345
|
ssmCompanyEntityType: "Entity Type (SSM)",
|
|
9339
9346
|
ssmPaidUpCapital: "Paid-Up Capital (SSM)",
|
|
9340
9347
|
businessCommencementDate: "Business Commencement Date",
|
|
@@ -9547,6 +9554,147 @@ function buildFileFieldTables(ihsData, fieldProvenance) {
|
|
|
9547
9554
|
}
|
|
9548
9555
|
return tables;
|
|
9549
9556
|
}
|
|
9557
|
+
var DOC_DISPLAY_NAMES = {
|
|
9558
|
+
bankStatements: "Bank Statements",
|
|
9559
|
+
financialStatements: "Financial Statements",
|
|
9560
|
+
form9: "Form 9",
|
|
9561
|
+
epfStatements: "EPF Statements",
|
|
9562
|
+
payslips: "Payslips",
|
|
9563
|
+
ssm: "SSM Company Profile",
|
|
9564
|
+
ic: "Identity Card",
|
|
9565
|
+
ssm_registration_documents: "Form 9",
|
|
9566
|
+
ic_documents: "Identity Documents (Supplementary)",
|
|
9567
|
+
consentForm: "Consent Form",
|
|
9568
|
+
supplementaryDoc: "Supplementary Documents",
|
|
9569
|
+
coreIncomeDoc: "Core Income Document",
|
|
9570
|
+
incomeSupportingDoc: "Income Supporting Document",
|
|
9571
|
+
incomeEPF_iakaun: "EPF i-Akaun",
|
|
9572
|
+
photocopyRegistrationCard: "Registration Card",
|
|
9573
|
+
bankStatementOrSavingPassbook: "Bank Passbook",
|
|
9574
|
+
tnbBills: "TNB Bills"
|
|
9575
|
+
};
|
|
9576
|
+
var EXTRACTABLE_DOC_TYPES = /* @__PURE__ */ new Set([
|
|
9577
|
+
"bankStatements",
|
|
9578
|
+
"financialStatements",
|
|
9579
|
+
"form9",
|
|
9580
|
+
"epfStatements",
|
|
9581
|
+
"payslips",
|
|
9582
|
+
"ssm",
|
|
9583
|
+
"ic",
|
|
9584
|
+
"ssm_registration_documents",
|
|
9585
|
+
"ic_documents"
|
|
9586
|
+
]);
|
|
9587
|
+
var REUPLOADABLE_DOC_TYPES = /* @__PURE__ */ new Set(["bankStatements", "financialStatements"]);
|
|
9588
|
+
function getDocDisplayNames() {
|
|
9589
|
+
return DOC_DISPLAY_NAMES;
|
|
9590
|
+
}
|
|
9591
|
+
function getExtractableDocTypes() {
|
|
9592
|
+
return EXTRACTABLE_DOC_TYPES;
|
|
9593
|
+
}
|
|
9594
|
+
function getReuploadableDocTypes() {
|
|
9595
|
+
return REUPLOADABLE_DOC_TYPES;
|
|
9596
|
+
}
|
|
9597
|
+
function isProbablyId(str) {
|
|
9598
|
+
if (!str) return false;
|
|
9599
|
+
const clean = str.split(".")[0];
|
|
9600
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(clean)) return true;
|
|
9601
|
+
if (/^[0-9a-f]{32,128}$/i.test(clean)) return true;
|
|
9602
|
+
return false;
|
|
9603
|
+
}
|
|
9604
|
+
function parseFileField(value) {
|
|
9605
|
+
if (!value) return [];
|
|
9606
|
+
if (Array.isArray(value)) return value;
|
|
9607
|
+
if (typeof value === "string") {
|
|
9608
|
+
try {
|
|
9609
|
+
const parsed = JSON.parse(value);
|
|
9610
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
9611
|
+
} catch {
|
|
9612
|
+
if (value.startsWith("http")) {
|
|
9613
|
+
return [{ path: value, documentId: value.split("/").pop() || void 0 }];
|
|
9614
|
+
}
|
|
9615
|
+
return [];
|
|
9616
|
+
}
|
|
9617
|
+
}
|
|
9618
|
+
return [];
|
|
9619
|
+
}
|
|
9620
|
+
function toBytes(value) {
|
|
9621
|
+
if (typeof value === "number") return Number.isNaN(value) ? null : value;
|
|
9622
|
+
if (typeof value === "string") {
|
|
9623
|
+
const n = parseInt(value, 10);
|
|
9624
|
+
return Number.isNaN(n) ? null : n;
|
|
9625
|
+
}
|
|
9626
|
+
return null;
|
|
9627
|
+
}
|
|
9628
|
+
function buildDocumentRows(ihsData) {
|
|
9629
|
+
const metaMap = ihsData.documentMetadata ?? {};
|
|
9630
|
+
const rows = [];
|
|
9631
|
+
for (const docType of Object.keys(DOC_DISPLAY_NAMES)) {
|
|
9632
|
+
const files = parseFileField(ihsData[docType]);
|
|
9633
|
+
if (files.length === 0) continue;
|
|
9634
|
+
const label = DOC_DISPLAY_NAMES[docType];
|
|
9635
|
+
const extractable = EXTRACTABLE_DOC_TYPES.has(docType);
|
|
9636
|
+
const reUploadable = extractable && REUPLOADABLE_DOC_TYPES.has(docType);
|
|
9637
|
+
files.forEach((file, index) => {
|
|
9638
|
+
const path = file.path ?? null;
|
|
9639
|
+
const meta = path ? metaMap[path] : void 0;
|
|
9640
|
+
const documentId = file.documentId || (path ? path.split("/").pop() || null : null);
|
|
9641
|
+
const timePeriod = file.month ? `T${file.month}` : file.year ? `T${file.year}` : "ALL";
|
|
9642
|
+
const rawName = file.fileName ?? meta?.fileName ?? void 0;
|
|
9643
|
+
const fileName = rawName && !isProbablyId(rawName) ? rawName : null;
|
|
9644
|
+
const rawExt = (rawName ?? "").split(".").pop();
|
|
9645
|
+
const ext = rawExt && rawExt.length <= 5 && !isProbablyId(rawExt) ? rawExt.toUpperCase() : null;
|
|
9646
|
+
const mime = file.fileType ?? meta?.fileType;
|
|
9647
|
+
const fileType = ext || (mime?.split("/").pop()?.toUpperCase() ?? null);
|
|
9648
|
+
const fileSize = toBytes(file.fileSize) ?? meta?.fileSize ?? null;
|
|
9649
|
+
const uploadedAt = file.createdAt ?? meta?.createdAt ?? null;
|
|
9650
|
+
const periodLabel = file.month && file.year ? new Date(file.year, file.month - 1).toLocaleDateString("en-MY", {
|
|
9651
|
+
year: "numeric",
|
|
9652
|
+
month: "short"
|
|
9653
|
+
}) : file.year ? `Year ${file.year}` : null;
|
|
9654
|
+
const displayName = fileName || (periodLabel ? `${label} \u2014 ${periodLabel}` : files.length > 1 ? `${label} ${index + 1}` : label);
|
|
9655
|
+
rows.push({
|
|
9656
|
+
docType,
|
|
9657
|
+
label,
|
|
9658
|
+
index,
|
|
9659
|
+
displayName,
|
|
9660
|
+
documentId,
|
|
9661
|
+
path,
|
|
9662
|
+
timePeriod,
|
|
9663
|
+
periodLabel,
|
|
9664
|
+
fileName,
|
|
9665
|
+
fileType,
|
|
9666
|
+
fileSize,
|
|
9667
|
+
uploadedAt,
|
|
9668
|
+
capabilities: {
|
|
9669
|
+
download: !!documentId,
|
|
9670
|
+
viewJson: extractable,
|
|
9671
|
+
reExtract: extractable,
|
|
9672
|
+
reUpload: reUploadable
|
|
9673
|
+
}
|
|
9674
|
+
});
|
|
9675
|
+
});
|
|
9676
|
+
}
|
|
9677
|
+
return rows;
|
|
9678
|
+
}
|
|
9679
|
+
var EM_DASH = "\u2014";
|
|
9680
|
+
function formatDocumentType(row) {
|
|
9681
|
+
return row.fileType ?? EM_DASH;
|
|
9682
|
+
}
|
|
9683
|
+
function formatDocumentSize(bytes) {
|
|
9684
|
+
if (!bytes || Number.isNaN(bytes)) return EM_DASH;
|
|
9685
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
9686
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
9687
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
9688
|
+
}
|
|
9689
|
+
function formatDocumentUploaded(row) {
|
|
9690
|
+
if (row.uploadedAt) {
|
|
9691
|
+
const d = new Date(row.uploadedAt);
|
|
9692
|
+
if (!Number.isNaN(d.getTime())) {
|
|
9693
|
+
return d.toLocaleDateString("en-MY", { year: "numeric", month: "short", day: "numeric" });
|
|
9694
|
+
}
|
|
9695
|
+
}
|
|
9696
|
+
return row.periodLabel ?? EM_DASH;
|
|
9697
|
+
}
|
|
9550
9698
|
function isFileOrFinancialColumn(fieldName, fileColumnSet) {
|
|
9551
9699
|
return fileColumnSet.has(fieldName) || fieldName.startsWith("financials") || fieldName.startsWith("bank_statement");
|
|
9552
9700
|
}
|
|
@@ -10470,12 +10618,16 @@ function assertAdapterCategory(id) {
|
|
|
10470
10618
|
applyAggregation,
|
|
10471
10619
|
applyDynamicTitles,
|
|
10472
10620
|
assertAdapterCategory,
|
|
10621
|
+
buildDocumentRows,
|
|
10473
10622
|
buildFileFieldTables,
|
|
10474
10623
|
categoryFieldsOf,
|
|
10475
10624
|
categoryForField,
|
|
10476
10625
|
categorySchemaOf,
|
|
10477
10626
|
evaluateExpression,
|
|
10478
10627
|
extractTimePeriods,
|
|
10628
|
+
formatDocumentSize,
|
|
10629
|
+
formatDocumentType,
|
|
10630
|
+
formatDocumentUploaded,
|
|
10479
10631
|
generateRHFSchema,
|
|
10480
10632
|
generateSurveyJson,
|
|
10481
10633
|
getBaseCategories,
|
|
@@ -10485,9 +10637,12 @@ function assertAdapterCategory(id) {
|
|
|
10485
10637
|
getCategoryName,
|
|
10486
10638
|
getDisplayName,
|
|
10487
10639
|
getDisplayNames,
|
|
10640
|
+
getDocDisplayNames,
|
|
10641
|
+
getExtractableDocTypes,
|
|
10488
10642
|
getGroupDisplayNames,
|
|
10489
10643
|
getPastMonthLabel,
|
|
10490
10644
|
getPastYearLabel,
|
|
10645
|
+
getReuploadableDocTypes,
|
|
10491
10646
|
getStepDefaultValues,
|
|
10492
10647
|
getStepSchema,
|
|
10493
10648
|
groupColumnsByTimePeriod,
|
|
@@ -10498,6 +10653,7 @@ function assertAdapterCategory(id) {
|
|
|
10498
10653
|
isFailureIhsStatus,
|
|
10499
10654
|
isTerminalIhsStatus,
|
|
10500
10655
|
isValidIhsStatus,
|
|
10656
|
+
parseFileField,
|
|
10501
10657
|
processIhsDetails,
|
|
10502
10658
|
resolveExtractionStatus,
|
|
10503
10659
|
resolvePageFields,
|