@finsys/core 3.5.0 → 4.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/dist/index.js CHANGED
@@ -7898,7 +7898,13 @@ var form_field_base_specs_default = {
7898
7898
  "openingBalanceT1",
7899
7899
  "bankBalanceT1"
7900
7900
  ],
7901
- category: "13"
7901
+ category: "13",
7902
+ document_type: "bankStatements",
7903
+ document_group: "bank_statements",
7904
+ document_group_label: "Bank Statements",
7905
+ wire_format: "path_array",
7906
+ document_slot: 1,
7907
+ time_period_unit: "month"
7902
7908
  },
7903
7909
  {
7904
7910
  name: "bank_statement_t2",
@@ -7914,7 +7920,13 @@ var form_field_base_specs_default = {
7914
7920
  "openingBalanceT2",
7915
7921
  "bankBalanceT2"
7916
7922
  ],
7917
- category: "13"
7923
+ category: "13",
7924
+ document_type: "bankStatements",
7925
+ document_group: "bank_statements",
7926
+ document_group_label: "Bank Statements",
7927
+ wire_format: "path_array",
7928
+ document_slot: 2,
7929
+ time_period_unit: "month"
7918
7930
  },
7919
7931
  {
7920
7932
  name: "bank_statement_t3",
@@ -7930,7 +7942,13 @@ var form_field_base_specs_default = {
7930
7942
  "openingBalanceT3",
7931
7943
  "bankBalanceT3"
7932
7944
  ],
7933
- category: "13"
7945
+ category: "13",
7946
+ document_type: "bankStatements",
7947
+ document_group: "bank_statements",
7948
+ document_group_label: "Bank Statements",
7949
+ wire_format: "path_array",
7950
+ document_slot: 3,
7951
+ time_period_unit: "month"
7934
7952
  },
7935
7953
  {
7936
7954
  name: "bank_statement_t4",
@@ -7946,7 +7964,13 @@ var form_field_base_specs_default = {
7946
7964
  "openingBalanceT4",
7947
7965
  "bankBalanceT4"
7948
7966
  ],
7949
- category: "13"
7967
+ category: "13",
7968
+ document_type: "bankStatements",
7969
+ document_group: "bank_statements",
7970
+ document_group_label: "Bank Statements",
7971
+ wire_format: "path_array",
7972
+ document_slot: 4,
7973
+ time_period_unit: "month"
7950
7974
  },
7951
7975
  {
7952
7976
  name: "bank_statement_t5",
@@ -7962,7 +7986,13 @@ var form_field_base_specs_default = {
7962
7986
  "openingBalanceT5",
7963
7987
  "bankBalanceT5"
7964
7988
  ],
7965
- category: "13"
7989
+ category: "13",
7990
+ document_type: "bankStatements",
7991
+ document_group: "bank_statements",
7992
+ document_group_label: "Bank Statements",
7993
+ wire_format: "path_array",
7994
+ document_slot: 5,
7995
+ time_period_unit: "month"
7966
7996
  },
7967
7997
  {
7968
7998
  name: "bank_statement_t6",
@@ -7978,7 +8008,13 @@ var form_field_base_specs_default = {
7978
8008
  "openingBalanceT6",
7979
8009
  "bankBalanceT6"
7980
8010
  ],
7981
- category: "13"
8011
+ category: "13",
8012
+ document_type: "bankStatements",
8013
+ document_group: "bank_statements",
8014
+ document_group_label: "Bank Statements",
8015
+ wire_format: "path_array",
8016
+ document_slot: 6,
8017
+ time_period_unit: "month"
7982
8018
  },
7983
8019
  {
7984
8020
  name: "financials",
@@ -7999,7 +8035,13 @@ var form_field_base_specs_default = {
7999
8035
  "netOperatingCashFlow",
8000
8036
  "ebitda"
8001
8037
  ],
8002
- category: "13"
8038
+ category: "13",
8039
+ document_type: "financialStatements",
8040
+ document_group: "financials",
8041
+ document_group_label: "Audited Financial Statements",
8042
+ wire_format: "path_array",
8043
+ document_slot: 1,
8044
+ time_period_unit: "year"
8003
8045
  },
8004
8046
  {
8005
8047
  name: "financials_fincap_t1",
@@ -8243,7 +8285,13 @@ var form_field_base_specs_default = {
8243
8285
  "depreciationOfInvestmentSecuritiesT2",
8244
8286
  "endOfYearCashT2"
8245
8287
  ],
8246
- category: "13"
8288
+ category: "13",
8289
+ document_type: "financialStatements",
8290
+ document_group: "financials",
8291
+ document_group_label: "Audited Financial Statements",
8292
+ wire_format: "path_array",
8293
+ document_slot: 1,
8294
+ time_period_unit: "year"
8247
8295
  },
8248
8296
  {
8249
8297
  name: "financials_fincap_t2",
@@ -8369,7 +8417,13 @@ var form_field_base_specs_default = {
8369
8417
  "depreciationOfInvestmentSecuritiesT3",
8370
8418
  "endOfYearCashT3"
8371
8419
  ],
8372
- category: "13"
8420
+ category: "13",
8421
+ document_type: "financialStatements",
8422
+ document_group: "financials",
8423
+ document_group_label: "Audited Financial Statements",
8424
+ wire_format: "path_array",
8425
+ document_slot: 2,
8426
+ time_period_unit: "year"
8373
8427
  },
8374
8428
  {
8375
8429
  name: "form9",
@@ -8380,7 +8434,11 @@ var form_field_base_specs_default = {
8380
8434
  "companyName",
8381
8435
  "companyRegNo"
8382
8436
  ],
8383
- category: "13"
8437
+ category: "13",
8438
+ document_type: "form9",
8439
+ document_group: "form9",
8440
+ document_group_label: "Form 9 / Section 17 / Form D",
8441
+ wire_format: "url_string"
8384
8442
  },
8385
8443
  {
8386
8444
  name: "ssm",
@@ -8404,7 +8462,11 @@ var form_field_base_specs_default = {
8404
8462
  "businessOrigin",
8405
8463
  "registeredAddress"
8406
8464
  ],
8407
- category: "13"
8465
+ category: "13",
8466
+ document_type: "ssm",
8467
+ document_group: "ssm_documents",
8468
+ document_group_label: "SSM Company Information",
8469
+ wire_format: "url_string"
8408
8470
  },
8409
8471
  {
8410
8472
  name: "ic",
@@ -8421,7 +8483,11 @@ var form_field_base_specs_default = {
8421
8483
  "icNationality",
8422
8484
  "icRace"
8423
8485
  ],
8424
- category: "13"
8486
+ category: "13",
8487
+ document_type: "ic",
8488
+ document_group: "ic_documents",
8489
+ document_group_label: "Identification Card",
8490
+ wire_format: "url_string"
8425
8491
  },
8426
8492
  {
8427
8493
  name: "epf_statement_t1",
@@ -8438,7 +8504,13 @@ var form_field_base_specs_default = {
8438
8504
  "epfTotalContributionT1",
8439
8505
  "epfTotalCurrentContributionT1"
8440
8506
  ],
8441
- category: "13"
8507
+ category: "13",
8508
+ document_type: "epfStatements",
8509
+ document_group: "epf_statements",
8510
+ document_group_label: "EPF Statements",
8511
+ wire_format: "path_array",
8512
+ document_slot: 1,
8513
+ time_period_unit: "year"
8442
8514
  },
8443
8515
  {
8444
8516
  name: "epf_statement_t2",
@@ -8455,7 +8527,13 @@ var form_field_base_specs_default = {
8455
8527
  "epfTotalContributionT2",
8456
8528
  "epfTotalCurrentContributionT2"
8457
8529
  ],
8458
- category: "13"
8530
+ category: "13",
8531
+ document_type: "epfStatements",
8532
+ document_group: "epf_statements",
8533
+ document_group_label: "EPF Statements",
8534
+ wire_format: "path_array",
8535
+ document_slot: 2,
8536
+ time_period_unit: "year"
8459
8537
  },
8460
8538
  {
8461
8539
  name: "payslip_statement_t1",
@@ -8478,7 +8556,13 @@ var form_field_base_specs_default = {
8478
8556
  "payslipEmployeeTaxT1",
8479
8557
  "payslipOtherDeductionT1"
8480
8558
  ],
8481
- category: "13"
8559
+ category: "13",
8560
+ document_type: "payslips",
8561
+ document_group: "payslip_statements",
8562
+ document_group_label: "Payslip Statements",
8563
+ wire_format: "path_array",
8564
+ document_slot: 1,
8565
+ time_period_unit: "month"
8482
8566
  },
8483
8567
  {
8484
8568
  name: "payslip_statement_t2",
@@ -8501,7 +8585,13 @@ var form_field_base_specs_default = {
8501
8585
  "payslipEmployeeTaxT2",
8502
8586
  "payslipOtherDeductionT2"
8503
8587
  ],
8504
- category: "13"
8588
+ category: "13",
8589
+ document_type: "payslips",
8590
+ document_group: "payslip_statements",
8591
+ document_group_label: "Payslip Statements",
8592
+ wire_format: "path_array",
8593
+ document_slot: 2,
8594
+ time_period_unit: "month"
8505
8595
  },
8506
8596
  {
8507
8597
  name: "payslip_statement_t3",
@@ -8524,7 +8614,13 @@ var form_field_base_specs_default = {
8524
8614
  "payslipEmployeeTaxT3",
8525
8615
  "payslipOtherDeductionT3"
8526
8616
  ],
8527
- category: "13"
8617
+ category: "13",
8618
+ document_type: "payslips",
8619
+ document_group: "payslip_statements",
8620
+ document_group_label: "Payslip Statements",
8621
+ wire_format: "path_array",
8622
+ document_slot: 3,
8623
+ time_period_unit: "month"
8528
8624
  },
8529
8625
  {
8530
8626
  name: "payslip_statement_t4",
@@ -8547,7 +8643,13 @@ var form_field_base_specs_default = {
8547
8643
  "payslipEmployeeTaxT4",
8548
8644
  "payslipOtherDeductionT4"
8549
8645
  ],
8550
- category: "13"
8646
+ category: "13",
8647
+ document_type: "payslips",
8648
+ document_group: "payslip_statements",
8649
+ document_group_label: "Payslip Statements",
8650
+ wire_format: "path_array",
8651
+ document_slot: 4,
8652
+ time_period_unit: "month"
8551
8653
  },
8552
8654
  {
8553
8655
  name: "payslip_statement_t5",
@@ -8570,7 +8672,13 @@ var form_field_base_specs_default = {
8570
8672
  "payslipEmployeeTaxT5",
8571
8673
  "payslipOtherDeductionT5"
8572
8674
  ],
8573
- category: "13"
8675
+ category: "13",
8676
+ document_type: "payslips",
8677
+ document_group: "payslip_statements",
8678
+ document_group_label: "Payslip Statements",
8679
+ wire_format: "path_array",
8680
+ document_slot: 5,
8681
+ time_period_unit: "month"
8574
8682
  },
8575
8683
  {
8576
8684
  name: "payslip_statement_t6",
@@ -8593,7 +8701,13 @@ var form_field_base_specs_default = {
8593
8701
  "payslipEmployeeTaxT6",
8594
8702
  "payslipOtherDeductionT6"
8595
8703
  ],
8596
- category: "13"
8704
+ category: "13",
8705
+ document_type: "payslips",
8706
+ document_group: "payslip_statements",
8707
+ document_group_label: "Payslip Statements",
8708
+ wire_format: "path_array",
8709
+ document_slot: 6,
8710
+ time_period_unit: "month"
8597
8711
  }
8598
8712
  ]
8599
8713
  };
@@ -9086,6 +9200,59 @@ var FileFieldTableType = /* @__PURE__ */ ((FileFieldTableType2) => {
9086
9200
  FileFieldTableType2["KEY_VALUE"] = "keyValue";
9087
9201
  return FileFieldTableType2;
9088
9202
  })(FileFieldTableType || {});
9203
+ var IHS_FIELD_ORIGINS = ["extracted", "derived", "manual"];
9204
+ function isValidIhsFieldOrigin(origin) {
9205
+ return typeof origin === "string" && IHS_FIELD_ORIGINS.includes(origin);
9206
+ }
9207
+
9208
+ // src/document-types.ts
9209
+ var cached = null;
9210
+ function buildDocumentTypeGroups() {
9211
+ const fileFields = getBaseFieldSpecs().filter(
9212
+ (f) => f.type === "file" && !!f.name
9213
+ );
9214
+ const order = [];
9215
+ const byDocumentType = /* @__PURE__ */ new Map();
9216
+ for (const f of fileFields) {
9217
+ const documentType = f.document_type ?? f.name;
9218
+ const documentGroup = f.document_group ?? documentType;
9219
+ const label = f.document_group_label ?? f.displayName ?? documentType;
9220
+ if (!byDocumentType.has(documentType)) {
9221
+ order.push(documentType);
9222
+ byDocumentType.set(documentType, {
9223
+ documentGroup,
9224
+ label,
9225
+ wireFormat: f.wire_format,
9226
+ fields: []
9227
+ });
9228
+ }
9229
+ byDocumentType.get(documentType).fields.push(f);
9230
+ }
9231
+ return order.map((documentType) => {
9232
+ const entry = byDocumentType.get(documentType);
9233
+ return {
9234
+ documentType,
9235
+ documentGroup: entry.documentGroup,
9236
+ label: entry.label,
9237
+ wireFormat: entry.wireFormat,
9238
+ fields: entry.fields
9239
+ };
9240
+ });
9241
+ }
9242
+ function getDocumentTypeGroups() {
9243
+ if (!cached) cached = buildDocumentTypeGroups();
9244
+ return cached;
9245
+ }
9246
+ function isDocumentType(id) {
9247
+ return getDocumentTypeGroups().some((g) => g.documentType === id);
9248
+ }
9249
+ function assertDocumentType(id) {
9250
+ if (!isDocumentType(id)) {
9251
+ const known = getDocumentTypeGroups().map((g) => g.documentType);
9252
+ throw new Error(`Unknown document type: "${id}". Available: ${known.join(", ")}`);
9253
+ }
9254
+ return id;
9255
+ }
9089
9256
 
9090
9257
  // src/data/form-field-display-names.json
9091
9258
  var form_field_display_names_default = {
@@ -9295,42 +9462,26 @@ function groupColumnsByTimePeriod(columnNames) {
9295
9462
  }
9296
9463
  return groups;
9297
9464
  }
9298
- var FIELD_GROUP_PREFIXES = [
9299
- ["bank_statement", "bank_statements"],
9300
- ["financials", "financials"],
9301
- ["epf_statement", "epf_statements"],
9302
- ["payslip_statement", "payslip_statements"],
9303
- ["ssm", "ssm_documents"],
9304
- ["form9", "form9"],
9305
- ["ic", "ic_documents"]
9306
- ];
9307
9465
  function groupFieldsByPattern(fields) {
9308
9466
  const groups = {};
9309
9467
  for (const field of fields) {
9310
9468
  if (!field.name) continue;
9311
- let groupName = field.name;
9312
- for (const [prefix, group] of FIELD_GROUP_PREFIXES) {
9313
- if (field.name.startsWith(prefix)) {
9314
- groupName = group;
9315
- break;
9316
- }
9317
- }
9469
+ const groupName = field.document_group ?? field.name;
9318
9470
  if (!groups[groupName]) groups[groupName] = [];
9319
9471
  groups[groupName].push(field);
9320
9472
  }
9321
9473
  return groups;
9322
9474
  }
9323
- var GROUP_DISPLAY_NAMES = {
9324
- bank_statements: "Bank Statements",
9325
- financials: "Audited Financial Statements",
9326
- epf_statements: "EPF Statements",
9327
- payslip_statements: "Payslip Statements",
9328
- form9: "Form 9 / Section 17 / Form D",
9329
- ssm_documents: "SSM Company Information",
9330
- ic_documents: "Identification Card"
9331
- };
9475
+ var cachedGroupDisplayNames = null;
9332
9476
  function getGroupDisplayNames() {
9333
- return GROUP_DISPLAY_NAMES;
9477
+ if (!cachedGroupDisplayNames) {
9478
+ const names = {};
9479
+ for (const group of getDocumentTypeGroups()) {
9480
+ names[group.documentGroup] = group.label;
9481
+ }
9482
+ cachedGroupDisplayNames = names;
9483
+ }
9484
+ return cachedGroupDisplayNames;
9334
9485
  }
9335
9486
  function isNumericField(fieldName) {
9336
9487
  const patterns = [
@@ -9375,7 +9526,7 @@ function buildTableForGroup(groupName, fields, ihsData, fieldProvenance) {
9375
9526
  const periods = extractTimePeriods(allColumns);
9376
9527
  const isTimeSeries = periods.length > 0;
9377
9528
  const tableType = isTimeSeries ? "timeSeries" /* TIME_SERIES */ : "keyValue" /* KEY_VALUE */;
9378
- const groupDisplayName = GROUP_DISPLAY_NAMES[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9529
+ const groupDisplayName = getGroupDisplayNames()[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9379
9530
  if (isTimeSeries) {
9380
9531
  const columnGroups = groupColumnsByTimePeriod(allColumns);
9381
9532
  const items = [];
@@ -9450,6 +9601,124 @@ function buildFileFieldTables(ihsData, fieldProvenance) {
9450
9601
  }
9451
9602
  return tables;
9452
9603
  }
9604
+ function instanceColumnLabel(row) {
9605
+ const period = row.timePeriod || row.instanceKey;
9606
+ return row.sourceLabel ? `${period} \xB7 ${row.sourceLabel}` : period;
9607
+ }
9608
+ function instanceColumnLabels(rows) {
9609
+ const seenCounts = /* @__PURE__ */ new Map();
9610
+ return rows.map((row) => {
9611
+ const raw = instanceColumnLabel(row);
9612
+ const occurrence = (seenCounts.get(raw) ?? 0) + 1;
9613
+ seenCounts.set(raw, occurrence);
9614
+ return occurrence === 1 ? raw : `${raw} (${occurrence})`;
9615
+ });
9616
+ }
9617
+ function groupColumnsByInstance(baseColumnNames, instanceRows) {
9618
+ const groups = {};
9619
+ for (const baseName of baseColumnNames) {
9620
+ groups[baseName] = {};
9621
+ }
9622
+ if (!instanceRows?.length) return groups;
9623
+ const labels = instanceColumnLabels(instanceRows);
9624
+ instanceRows.forEach((row, i) => {
9625
+ const label = labels[i];
9626
+ for (const baseName of baseColumnNames) {
9627
+ if (Object.prototype.hasOwnProperty.call(row, baseName)) {
9628
+ groups[baseName][label] = row[baseName];
9629
+ }
9630
+ }
9631
+ });
9632
+ return groups;
9633
+ }
9634
+ function buildInstanceTable(groupName, baseNames, groupDisplayName, instanceRows, fieldProvenance) {
9635
+ const columnGroups = groupColumnsByInstance(baseNames, instanceRows);
9636
+ const instanceLabels = instanceColumnLabels(instanceRows);
9637
+ const items = [];
9638
+ for (const [baseName, labelMap] of Object.entries(columnGroups)) {
9639
+ const hasAny = Object.values(labelMap).some((v) => v !== null && v !== void 0 && v !== "");
9640
+ if (!hasAny) continue;
9641
+ const numeric = isNumericField(baseName);
9642
+ const data = {};
9643
+ const formattedData = {};
9644
+ const confidence = {};
9645
+ const provenance = {};
9646
+ for (const [i, row] of instanceRows.entries()) {
9647
+ const label = instanceLabels[i];
9648
+ const value = labelMap[label] ?? null;
9649
+ data[label] = value;
9650
+ formattedData[label] = formatValue(value, numeric);
9651
+ const legacyKey = row.timePeriod ? `${baseName}${row.timePeriod}` : void 0;
9652
+ const prov = legacyKey ? fieldProvenance?.[legacyKey] : void 0;
9653
+ if (prov) {
9654
+ provenance[label] = prov;
9655
+ if (prov.origin === "extracted" && typeof prov.confidence === "number" && !Number.isNaN(prov.confidence)) {
9656
+ confidence[label] = prov.confidence;
9657
+ }
9658
+ }
9659
+ }
9660
+ items.push({
9661
+ displayName: getDisplayName(baseName),
9662
+ timePeriods: instanceLabels,
9663
+ data,
9664
+ formattedData,
9665
+ type: "timeSeries" /* TIME_SERIES */,
9666
+ isNumeric: numeric,
9667
+ ...Object.keys(confidence).length ? { confidence } : {},
9668
+ ...Object.keys(provenance).length ? { provenance } : {}
9669
+ });
9670
+ }
9671
+ const hasData = items.some(
9672
+ (item) => Object.values(item.data).some((v) => v !== null && v !== void 0 && v !== "")
9673
+ );
9674
+ if (!items.length || !hasData) return null;
9675
+ return {
9676
+ name: groupName,
9677
+ displayName: groupDisplayName,
9678
+ type: "timeSeries" /* TIME_SERIES */,
9679
+ items,
9680
+ hasData
9681
+ };
9682
+ }
9683
+ function buildFileFieldTablesFromInstances(instancesByCategory = {}, fieldProvenance, categoryOverrides) {
9684
+ const specs = getBaseFieldSpecs();
9685
+ const fileFields = specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
9686
+ const grouped = groupFieldsByPattern(fileFields);
9687
+ const tables = {};
9688
+ for (const [groupName, fields] of Object.entries(grouped)) {
9689
+ const instanceRows = instancesByCategory[groupName];
9690
+ if (!instanceRows?.length) continue;
9691
+ const baseNames = /* @__PURE__ */ new Set();
9692
+ for (const field of fields) {
9693
+ for (const col of field.ihs_column_names ?? []) {
9694
+ baseNames.add(col.replace(TIME_PERIOD_REGEX, ""));
9695
+ }
9696
+ }
9697
+ const groupDisplayName = getGroupDisplayNames()[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9698
+ const table = buildInstanceTable(
9699
+ groupName,
9700
+ [...baseNames],
9701
+ groupDisplayName,
9702
+ instanceRows,
9703
+ fieldProvenance
9704
+ );
9705
+ if (table) tables[groupName] = table;
9706
+ }
9707
+ for (const [groupName, spec] of Object.entries(categoryOverrides ?? {})) {
9708
+ if (Object.prototype.hasOwnProperty.call(tables, groupName)) continue;
9709
+ const instanceRows = instancesByCategory[groupName];
9710
+ if (!instanceRows?.length) continue;
9711
+ const table = buildInstanceTable(
9712
+ groupName,
9713
+ spec.baseColumnNames,
9714
+ spec.displayName,
9715
+ instanceRows,
9716
+ fieldProvenance
9717
+ );
9718
+ if (table) tables[groupName] = table;
9719
+ }
9720
+ return tables;
9721
+ }
9453
9722
  var DOC_DISPLAY_NAMES = {
9454
9723
  bankStatements: "Bank Statements",
9455
9724
  financialStatements: "Financial Statements",
@@ -9696,22 +9965,13 @@ var ExtractionJobStatus = /* @__PURE__ */ ((ExtractionJobStatus2) => {
9696
9965
  ExtractionJobStatus2["Failed"] = "failed";
9697
9966
  return ExtractionJobStatus2;
9698
9967
  })(ExtractionJobStatus || {});
9699
- var ExtractionFileType = /* @__PURE__ */ ((ExtractionFileType2) => {
9700
- ExtractionFileType2["FinancialStatement"] = "financialStatements";
9701
- ExtractionFileType2["BankStatement"] = "bankStatements";
9702
- ExtractionFileType2["Epf"] = "epfStatements";
9703
- ExtractionFileType2["Payslip"] = "payslips";
9704
- ExtractionFileType2["Ssm"] = "ssm";
9705
- ExtractionFileType2["Form9"] = "form9";
9706
- ExtractionFileType2["Ic"] = "ic";
9707
- return ExtractionFileType2;
9708
- })(ExtractionFileType || {});
9709
9968
 
9710
9969
  // src/ihs-status.ts
9711
9970
  var IhsStatus = /* @__PURE__ */ ((IhsStatus2) => {
9712
9971
  IhsStatus2["CreatingApplication"] = "CREATING_APPLICATION";
9713
9972
  IhsStatus2["ApplicationFinalized"] = "APPLICATION_FINALIZED";
9714
9973
  IhsStatus2["LenderEvaluation"] = "LENDER_EVALUATION";
9974
+ IhsStatus2["EditingApplication"] = "EDITING_APPLICATION";
9715
9975
  IhsStatus2["Approved"] = "APPROVED";
9716
9976
  IhsStatus2["LouDelivered"] = "LOU_DELIVERED";
9717
9977
  IhsStatus2["AwaitingDisbursement"] = "AWAITING_DISBURSEMENT";
@@ -9725,6 +9985,7 @@ var IHS_VALID_STATUSES = [
9725
9985
  "CREATING_APPLICATION" /* CreatingApplication */,
9726
9986
  "APPLICATION_FINALIZED" /* ApplicationFinalized */,
9727
9987
  "LENDER_EVALUATION" /* LenderEvaluation */,
9988
+ "EDITING_APPLICATION" /* EditingApplication */,
9728
9989
  "APPROVED" /* Approved */,
9729
9990
  "LOU_DELIVERED" /* LouDelivered */,
9730
9991
  "AWAITING_DISBURSEMENT" /* AwaitingDisbursement */,
@@ -9765,19 +10026,6 @@ var DocExtractionStatus = /* @__PURE__ */ ((DocExtractionStatus2) => {
9765
10026
  DocExtractionStatus2["Unknown"] = "unknown";
9766
10027
  return DocExtractionStatus2;
9767
10028
  })(DocExtractionStatus || {});
9768
- var FILE_TYPE_TO_GROUP = {
9769
- ["bankStatements" /* BankStatement */]: "bank_statements",
9770
- ["financialStatements" /* FinancialStatement */]: "financials",
9771
- ["epfStatements" /* Epf */]: "epf_statements",
9772
- ["payslips" /* Payslip */]: "payslip_statements",
9773
- ["ssm" /* Ssm */]: "ssm_documents",
9774
- ["form9" /* Form9 */]: "form9",
9775
- ["ic" /* Ic */]: "ic_documents"
9776
- };
9777
- var _specs = getBaseFieldSpecs();
9778
- var _fileFields = _specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
9779
- var _grouped = groupFieldsByPattern(_fileFields);
9780
- var _groupDisplayNames = getGroupDisplayNames();
9781
10029
  function isPopulated(value) {
9782
10030
  if (value === null || value === void 0 || value === "") return false;
9783
10031
  if (value === "Not Specified") return false;
@@ -9841,10 +10089,10 @@ function resolveDocStatus(columns, ihsRecord, uploaded, jobRecord, hasJobRecords
9841
10089
  function resolveExtractionStatus(ihsRecord, jobRecords) {
9842
10090
  const documents = [];
9843
10091
  const hasJobRecords = jobRecords !== void 0;
9844
- for (const fileType of Object.values(ExtractionFileType)) {
9845
- const groupName = FILE_TYPE_TO_GROUP[fileType];
9846
- const fields = _grouped[groupName] ?? [];
9847
- const displayName = _groupDisplayNames[groupName] ?? fileType;
10092
+ for (const group of getDocumentTypeGroups()) {
10093
+ const fileType = group.documentType;
10094
+ const fields = group.fields;
10095
+ const displayName = group.label;
9848
10096
  const uploadedCount = countUploadedFiles(ihsRecord, fileType);
9849
10097
  const isUploaded = uploadedCount > 0 || fields.some((f) => f.name && isPopulated(ihsRecord[f.name]));
9850
10098
  const matchingJobs = jobRecords?.filter((j) => j.fileType === fileType) ?? [];
@@ -10493,7 +10741,6 @@ export {
10493
10741
  BasicFormField,
10494
10742
  DEFAULT_VALIDATOR_DEFINITIONS,
10495
10743
  DocExtractionStatus,
10496
- ExtractionFileType,
10497
10744
  ExtractionJobStatus,
10498
10745
  FIELD_TYPE_DEFINITIONS,
10499
10746
  FieldType,
@@ -10504,6 +10751,7 @@ export {
10504
10751
  FormFieldValidator,
10505
10752
  FormSpec,
10506
10753
  IHS_FAILURE_STATUSES,
10754
+ IHS_FIELD_ORIGINS,
10507
10755
  IHS_TERMINAL_STATUSES,
10508
10756
  IHS_VALID_STATUSES,
10509
10757
  IhsStatus,
@@ -10513,8 +10761,10 @@ export {
10513
10761
  applyAggregation,
10514
10762
  applyDynamicTitles,
10515
10763
  assertAdapterCategory,
10764
+ assertDocumentType,
10516
10765
  buildDocumentRows,
10517
10766
  buildFileFieldTables,
10767
+ buildFileFieldTablesFromInstances,
10518
10768
  categoryFieldsOf,
10519
10769
  categoryForField,
10520
10770
  categorySchemaOf,
@@ -10533,6 +10783,7 @@ export {
10533
10783
  getDisplayName,
10534
10784
  getDisplayNames,
10535
10785
  getDocDisplayNames,
10786
+ getDocumentTypeGroups,
10536
10787
  getExtractableDocTypes,
10537
10788
  getGroupDisplayNames,
10538
10789
  getPastMonthLabel,
@@ -10540,13 +10791,16 @@ export {
10540
10791
  getReuploadableDocTypes,
10541
10792
  getStepDefaultValues,
10542
10793
  getStepSchema,
10794
+ groupColumnsByInstance,
10543
10795
  groupColumnsByTimePeriod,
10544
10796
  groupDetailsByCategory,
10545
10797
  groupFieldsByCategory,
10546
10798
  groupFieldsByPattern,
10547
10799
  isAdapterCategory,
10800
+ isDocumentType,
10548
10801
  isFailureIhsStatus,
10549
10802
  isTerminalIhsStatus,
10803
+ isValidIhsFieldOrigin,
10550
10804
  isValidIhsStatus,
10551
10805
  parseFileField,
10552
10806
  processIhsDetails,