@finsys/core 3.4.0 → 4.0.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",
@@ -8389,7 +8447,7 @@ var form_field_base_specs_default = {
8389
8447
  ihs_column_names: [
8390
8448
  "ssmCompanyName",
8391
8449
  "ssmCompanyRegNo",
8392
- "ssmIncorporatedDate",
8450
+ "incorporatedDate",
8393
8451
  "businessCommencementDate",
8394
8452
  "businessNature",
8395
8453
  "ssmCompanyEntityType",
@@ -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
  };
@@ -9087,6 +9201,55 @@ var FileFieldTableType = /* @__PURE__ */ ((FileFieldTableType2) => {
9087
9201
  return FileFieldTableType2;
9088
9202
  })(FileFieldTableType || {});
9089
9203
 
9204
+ // src/document-types.ts
9205
+ var cached = null;
9206
+ function buildDocumentTypeGroups() {
9207
+ const fileFields = getBaseFieldSpecs().filter(
9208
+ (f) => f.type === "file" && !!f.name
9209
+ );
9210
+ const order = [];
9211
+ const byDocumentType = /* @__PURE__ */ new Map();
9212
+ for (const f of fileFields) {
9213
+ const documentType = f.document_type ?? f.name;
9214
+ const documentGroup = f.document_group ?? documentType;
9215
+ const label = f.document_group_label ?? f.displayName ?? documentType;
9216
+ if (!byDocumentType.has(documentType)) {
9217
+ order.push(documentType);
9218
+ byDocumentType.set(documentType, {
9219
+ documentGroup,
9220
+ label,
9221
+ wireFormat: f.wire_format,
9222
+ fields: []
9223
+ });
9224
+ }
9225
+ byDocumentType.get(documentType).fields.push(f);
9226
+ }
9227
+ return order.map((documentType) => {
9228
+ const entry = byDocumentType.get(documentType);
9229
+ return {
9230
+ documentType,
9231
+ documentGroup: entry.documentGroup,
9232
+ label: entry.label,
9233
+ wireFormat: entry.wireFormat,
9234
+ fields: entry.fields
9235
+ };
9236
+ });
9237
+ }
9238
+ function getDocumentTypeGroups() {
9239
+ if (!cached) cached = buildDocumentTypeGroups();
9240
+ return cached;
9241
+ }
9242
+ function isDocumentType(id) {
9243
+ return getDocumentTypeGroups().some((g) => g.documentType === id);
9244
+ }
9245
+ function assertDocumentType(id) {
9246
+ if (!isDocumentType(id)) {
9247
+ const known = getDocumentTypeGroups().map((g) => g.documentType);
9248
+ throw new Error(`Unknown document type: "${id}". Available: ${known.join(", ")}`);
9249
+ }
9250
+ return id;
9251
+ }
9252
+
9090
9253
  // src/data/form-field-display-names.json
9091
9254
  var form_field_display_names_default = {
9092
9255
  accountHolderName: "Account Holder Name",
@@ -9238,7 +9401,6 @@ var form_field_display_names_default = {
9238
9401
  companyRegNo: "Company Registration No.",
9239
9402
  ssmCompanyName: "Company Name (SSM)",
9240
9403
  ssmCompanyRegNo: "Registration No. (SSM)",
9241
- ssmIncorporatedDate: "Incorporated Date (SSM)",
9242
9404
  ssmCompanyEntityType: "Entity Type (SSM)",
9243
9405
  ssmPaidUpCapital: "Paid-Up Capital (SSM)",
9244
9406
  businessCommencementDate: "Business Commencement Date",
@@ -9296,42 +9458,26 @@ function groupColumnsByTimePeriod(columnNames) {
9296
9458
  }
9297
9459
  return groups;
9298
9460
  }
9299
- var FIELD_GROUP_PREFIXES = [
9300
- ["bank_statement", "bank_statements"],
9301
- ["financials", "financials"],
9302
- ["epf_statement", "epf_statements"],
9303
- ["payslip_statement", "payslip_statements"],
9304
- ["ssm", "ssm_documents"],
9305
- ["form9", "form9"],
9306
- ["ic", "ic_documents"]
9307
- ];
9308
9461
  function groupFieldsByPattern(fields) {
9309
9462
  const groups = {};
9310
9463
  for (const field of fields) {
9311
9464
  if (!field.name) continue;
9312
- let groupName = field.name;
9313
- for (const [prefix, group] of FIELD_GROUP_PREFIXES) {
9314
- if (field.name.startsWith(prefix)) {
9315
- groupName = group;
9316
- break;
9317
- }
9318
- }
9465
+ const groupName = field.document_group ?? field.name;
9319
9466
  if (!groups[groupName]) groups[groupName] = [];
9320
9467
  groups[groupName].push(field);
9321
9468
  }
9322
9469
  return groups;
9323
9470
  }
9324
- var GROUP_DISPLAY_NAMES = {
9325
- bank_statements: "Bank Statements",
9326
- financials: "Audited Financial Statements",
9327
- epf_statements: "EPF Statements",
9328
- payslip_statements: "Payslip Statements",
9329
- form9: "Form 9 / Section 17 / Form D",
9330
- ssm_documents: "SSM Company Information",
9331
- ic_documents: "Identification Card"
9332
- };
9471
+ var cachedGroupDisplayNames = null;
9333
9472
  function getGroupDisplayNames() {
9334
- return GROUP_DISPLAY_NAMES;
9473
+ if (!cachedGroupDisplayNames) {
9474
+ const names = {};
9475
+ for (const group of getDocumentTypeGroups()) {
9476
+ names[group.documentGroup] = group.label;
9477
+ }
9478
+ cachedGroupDisplayNames = names;
9479
+ }
9480
+ return cachedGroupDisplayNames;
9335
9481
  }
9336
9482
  function isNumericField(fieldName) {
9337
9483
  const patterns = [
@@ -9376,7 +9522,7 @@ function buildTableForGroup(groupName, fields, ihsData, fieldProvenance) {
9376
9522
  const periods = extractTimePeriods(allColumns);
9377
9523
  const isTimeSeries = periods.length > 0;
9378
9524
  const tableType = isTimeSeries ? "timeSeries" /* TIME_SERIES */ : "keyValue" /* KEY_VALUE */;
9379
- const groupDisplayName = GROUP_DISPLAY_NAMES[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9525
+ const groupDisplayName = getGroupDisplayNames()[groupName] || fields[0]?.displayName || getDisplayName(groupName);
9380
9526
  if (isTimeSeries) {
9381
9527
  const columnGroups = groupColumnsByTimePeriod(allColumns);
9382
9528
  const items = [];
@@ -9697,16 +9843,6 @@ var ExtractionJobStatus = /* @__PURE__ */ ((ExtractionJobStatus2) => {
9697
9843
  ExtractionJobStatus2["Failed"] = "failed";
9698
9844
  return ExtractionJobStatus2;
9699
9845
  })(ExtractionJobStatus || {});
9700
- var ExtractionFileType = /* @__PURE__ */ ((ExtractionFileType2) => {
9701
- ExtractionFileType2["FinancialStatement"] = "financialStatements";
9702
- ExtractionFileType2["BankStatement"] = "bankStatements";
9703
- ExtractionFileType2["Epf"] = "epfStatements";
9704
- ExtractionFileType2["Payslip"] = "payslips";
9705
- ExtractionFileType2["Ssm"] = "ssm";
9706
- ExtractionFileType2["Form9"] = "form9";
9707
- ExtractionFileType2["Ic"] = "ic";
9708
- return ExtractionFileType2;
9709
- })(ExtractionFileType || {});
9710
9846
 
9711
9847
  // src/ihs-status.ts
9712
9848
  var IhsStatus = /* @__PURE__ */ ((IhsStatus2) => {
@@ -9766,19 +9902,6 @@ var DocExtractionStatus = /* @__PURE__ */ ((DocExtractionStatus2) => {
9766
9902
  DocExtractionStatus2["Unknown"] = "unknown";
9767
9903
  return DocExtractionStatus2;
9768
9904
  })(DocExtractionStatus || {});
9769
- var FILE_TYPE_TO_GROUP = {
9770
- ["bankStatements" /* BankStatement */]: "bank_statements",
9771
- ["financialStatements" /* FinancialStatement */]: "financials",
9772
- ["epfStatements" /* Epf */]: "epf_statements",
9773
- ["payslips" /* Payslip */]: "payslip_statements",
9774
- ["ssm" /* Ssm */]: "ssm_documents",
9775
- ["form9" /* Form9 */]: "form9",
9776
- ["ic" /* Ic */]: "ic_documents"
9777
- };
9778
- var _specs = getBaseFieldSpecs();
9779
- var _fileFields = _specs.filter((f) => f.type === "file" && f.ihs_column_names?.length);
9780
- var _grouped = groupFieldsByPattern(_fileFields);
9781
- var _groupDisplayNames = getGroupDisplayNames();
9782
9905
  function isPopulated(value) {
9783
9906
  if (value === null || value === void 0 || value === "") return false;
9784
9907
  if (value === "Not Specified") return false;
@@ -9842,10 +9965,10 @@ function resolveDocStatus(columns, ihsRecord, uploaded, jobRecord, hasJobRecords
9842
9965
  function resolveExtractionStatus(ihsRecord, jobRecords) {
9843
9966
  const documents = [];
9844
9967
  const hasJobRecords = jobRecords !== void 0;
9845
- for (const fileType of Object.values(ExtractionFileType)) {
9846
- const groupName = FILE_TYPE_TO_GROUP[fileType];
9847
- const fields = _grouped[groupName] ?? [];
9848
- const displayName = _groupDisplayNames[groupName] ?? fileType;
9968
+ for (const group of getDocumentTypeGroups()) {
9969
+ const fileType = group.documentType;
9970
+ const fields = group.fields;
9971
+ const displayName = group.label;
9849
9972
  const uploadedCount = countUploadedFiles(ihsRecord, fileType);
9850
9973
  const isUploaded = uploadedCount > 0 || fields.some((f) => f.name && isPopulated(ihsRecord[f.name]));
9851
9974
  const matchingJobs = jobRecords?.filter((j) => j.fileType === fileType) ?? [];
@@ -10494,7 +10617,6 @@ export {
10494
10617
  BasicFormField,
10495
10618
  DEFAULT_VALIDATOR_DEFINITIONS,
10496
10619
  DocExtractionStatus,
10497
- ExtractionFileType,
10498
10620
  ExtractionJobStatus,
10499
10621
  FIELD_TYPE_DEFINITIONS,
10500
10622
  FieldType,
@@ -10514,6 +10636,7 @@ export {
10514
10636
  applyAggregation,
10515
10637
  applyDynamicTitles,
10516
10638
  assertAdapterCategory,
10639
+ assertDocumentType,
10517
10640
  buildDocumentRows,
10518
10641
  buildFileFieldTables,
10519
10642
  categoryFieldsOf,
@@ -10534,6 +10657,7 @@ export {
10534
10657
  getDisplayName,
10535
10658
  getDisplayNames,
10536
10659
  getDocDisplayNames,
10660
+ getDocumentTypeGroups,
10537
10661
  getExtractableDocTypes,
10538
10662
  getGroupDisplayNames,
10539
10663
  getPastMonthLabel,
@@ -10546,6 +10670,7 @@ export {
10546
10670
  groupFieldsByCategory,
10547
10671
  groupFieldsByPattern,
10548
10672
  isAdapterCategory,
10673
+ isDocumentType,
10549
10674
  isFailureIhsStatus,
10550
10675
  isTerminalIhsStatus,
10551
10676
  isValidIhsStatus,