@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
package/dist/index.d.cts
CHANGED
|
@@ -449,6 +449,69 @@ interface FileFieldTableData {
|
|
|
449
449
|
items: FileFieldTableItem[];
|
|
450
450
|
hasData: boolean;
|
|
451
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Per-document File metadata attached by finsys-api `getIhsDetailsById` as the
|
|
454
|
+
* `documentMetadata` sibling map (SYS-2765), keyed by the document's raw stored
|
|
455
|
+
* path. The single source for the documents table's Type / Size / Uploaded
|
|
456
|
+
* columns — the IHS doc fields themselves carry only the path.
|
|
457
|
+
*/
|
|
458
|
+
interface DocumentFileMetadata {
|
|
459
|
+
fileName: string | null;
|
|
460
|
+
fileType: string | null;
|
|
461
|
+
fileSize: number | null;
|
|
462
|
+
createdAt: string | null;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Intrinsic, data-derived capability eligibility for a document row. Reflects
|
|
466
|
+
* ONLY what the IHS payload implies (doc type + a resolvable file); the consumer
|
|
467
|
+
* ANDs in its own runtime gates (readOnly, allowReupload, and — for viewJson —
|
|
468
|
+
* whether extraction has actually completed) before showing a control.
|
|
469
|
+
*/
|
|
470
|
+
interface DocumentRowCapabilities {
|
|
471
|
+
/** A downloadable original exists (a resolvable documentId). */
|
|
472
|
+
download: boolean;
|
|
473
|
+
/** The doc type produces extracted JSON (consumer still gates on "Extracted"). */
|
|
474
|
+
viewJson: boolean;
|
|
475
|
+
/** The doc type can be re-extracted. */
|
|
476
|
+
reExtract: boolean;
|
|
477
|
+
/** The doc type accepts a replacement upload (finsys-api /ihs/client/update/document). */
|
|
478
|
+
reUpload: boolean;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* One uploaded document, presentation-agnostic — built by `buildDocumentRows`
|
|
482
|
+
* from the IHS payload + its `documentMetadata` map. Rendered identically by
|
|
483
|
+
* FinHub (React) and finsys-client (Edge). Live extraction status + confidence
|
|
484
|
+
* are NOT payload-derived; the consumer overlays them by matching
|
|
485
|
+
* `(docType, timePeriod)`.
|
|
486
|
+
*/
|
|
487
|
+
interface DocumentRow {
|
|
488
|
+
/** IHS field key, e.g. 'bankStatements'. */
|
|
489
|
+
docType: string;
|
|
490
|
+
/** Human label for the doc-type group, e.g. 'Bank Statements'. */
|
|
491
|
+
label: string;
|
|
492
|
+
/** 0-based position within the docType group. */
|
|
493
|
+
index: number;
|
|
494
|
+
/** Best display name (resolved file name, or a label + period/index fallback). */
|
|
495
|
+
displayName: string;
|
|
496
|
+
/** Id for the download link; null when no file path is resolvable. */
|
|
497
|
+
documentId: string | null;
|
|
498
|
+
/** Raw stored path — the join key back to `documentMetadata`. */
|
|
499
|
+
path: string | null;
|
|
500
|
+
/** Extraction time-period token: 'T{month|year}' or 'ALL'. */
|
|
501
|
+
timePeriod: string;
|
|
502
|
+
/** Human period label ('Jan 2026' / 'Year 2024') or null. */
|
|
503
|
+
periodLabel: string | null;
|
|
504
|
+
/** Resolved file name; null when the stored name looks like an opaque id. */
|
|
505
|
+
fileName: string | null;
|
|
506
|
+
/** File type label (extension → MIME subtype, upper-cased) or null. */
|
|
507
|
+
fileType: string | null;
|
|
508
|
+
/** File size in bytes, or null when unknown. */
|
|
509
|
+
fileSize: number | null;
|
|
510
|
+
/** ISO upload timestamp (File.createdAt) or null. */
|
|
511
|
+
uploadedAt: string | null;
|
|
512
|
+
/** Intrinsic capability eligibility (consumer overlays its runtime gates). */
|
|
513
|
+
capabilities: DocumentRowCapabilities;
|
|
514
|
+
}
|
|
452
515
|
|
|
453
516
|
/** Returns the full display name registry (extraction column → human label). */
|
|
454
517
|
declare function getDisplayNames(): Record<string, string>;
|
|
@@ -460,6 +523,42 @@ declare function groupFieldsByPattern(fields: FieldData[]): Record<string, Field
|
|
|
460
523
|
/** Returns human-friendly display names for field groups. */
|
|
461
524
|
declare function getGroupDisplayNames(): Record<string, string>;
|
|
462
525
|
declare function buildFileFieldTables(ihsData: Record<string, unknown>, fieldProvenance?: Record<string, IhsFieldProvenance>): Record<string, FileFieldTableData>;
|
|
526
|
+
/** IHS doc-field key → human label (the fields that become document sections). */
|
|
527
|
+
declare function getDocDisplayNames(): Record<string, string>;
|
|
528
|
+
/** Doc types eligible for extraction (re-extract / view-JSON). */
|
|
529
|
+
declare function getExtractableDocTypes(): Set<string>;
|
|
530
|
+
/** Doc types eligible for a replacement upload. */
|
|
531
|
+
declare function getReuploadableDocTypes(): Set<string>;
|
|
532
|
+
interface ParsedDocFile {
|
|
533
|
+
path?: string;
|
|
534
|
+
fileName?: string;
|
|
535
|
+
documentId?: string;
|
|
536
|
+
fileSize?: number | string;
|
|
537
|
+
fileType?: string;
|
|
538
|
+
createdAt?: string;
|
|
539
|
+
month?: number;
|
|
540
|
+
year?: number;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Parse one IHS doc field into file entries. Handles the shapes the field takes:
|
|
544
|
+
* a JSON-array string (bank/financial/…, possibly inline-enriched like
|
|
545
|
+
* supplementaryDoc), an already-parsed array, or a bare URL string (ssm/form9/ic).
|
|
546
|
+
*/
|
|
547
|
+
declare function parseFileField(value: unknown): ParsedDocFile[];
|
|
548
|
+
/**
|
|
549
|
+
* Build the presentation-agnostic document rows for an IHS. Reads the doc fields
|
|
550
|
+
* named in DOC_DISPLAY_NAMES + the `documentMetadata` sibling map (SYS-2765) and
|
|
551
|
+
* emits a flat DocumentRow[] (all sections, in DOC_DISPLAY_NAMES order). Metadata
|
|
552
|
+
* is taken inline off the entry first (supplementaryDoc is enriched inline), then
|
|
553
|
+
* from `documentMetadata[path]`.
|
|
554
|
+
*/
|
|
555
|
+
declare function buildDocumentRows(ihsData: Record<string, unknown>): DocumentRow[];
|
|
556
|
+
/** Type column: the resolved type label, or em-dash. */
|
|
557
|
+
declare function formatDocumentType(row: Pick<DocumentRow, 'fileType'>): string;
|
|
558
|
+
/** Size column: human bytes (B / KB / MB), or em-dash when unknown. */
|
|
559
|
+
declare function formatDocumentSize(bytes: number | null | undefined): string;
|
|
560
|
+
/** Uploaded column: the upload date, else the period label, else em-dash. */
|
|
561
|
+
declare function formatDocumentUploaded(row: Pick<DocumentRow, 'uploadedAt' | 'periodLabel'>): string;
|
|
463
562
|
declare function processIhsDetails(ihsData: Record<string, unknown>): IhsFieldDetail[];
|
|
464
563
|
declare function groupDetailsByCategory(details: IhsFieldDetail[]): IhsDetailCategory[];
|
|
465
564
|
|
|
@@ -1249,4 +1348,4 @@ interface FieldMapEntry {
|
|
|
1249
1348
|
readonly transform?: "identity" | "pct_to_ratio01" | "to_boolean" | "to_integer";
|
|
1250
1349
|
}
|
|
1251
1350
|
|
|
1252
|
-
export { ADAPTER_CATEGORY_IDS, ALL_AGGREGATION_OPS, type AdapterCategory, AdapterError, type AdapterErrorReason, type AdapterExtraction, type AdapterManifest, type AggregationOp, type ApplicantIdentity, BASE_FIELD_SPECS, BasicFormField, type CanonicalFieldName, type CanonicalFieldSpec, type CanonicalFieldValue, type CanonicalFieldValues, type Category, type CategorySchema, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DeclarativeImplementation, type DocExtractionResult, DocExtractionStatus, type DropdownOption, type EditorValidator, ExtractionFileType, type ExtractionJobRecord, ExtractionJobStatus, type ExtractionStatusResult, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldMapEntry, type FieldReference, FieldType, type FileFieldTableData, type FileFieldTableItem, FileFieldTableType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, IHS_FAILURE_STATUSES, IHS_TERMINAL_STATUSES, IHS_VALID_STATUSES, type IhsDetailCategory, type IhsFieldDetail, type IhsFieldProvenance, IhsStatus, IhsValueFormat, type InstanceValue, type PageConfig, type RHFSchemaOutput, type RHFStep, type RawPayload, type ResolvedField, Role, type SourceAdapter, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type TypescriptImplementation, type UnifiedFormConfig, type Validator, allCategories, applyAggregation, applyDynamicTitles, assertAdapterCategory, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isAdapterCategory, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
|
1351
|
+
export { ADAPTER_CATEGORY_IDS, ALL_AGGREGATION_OPS, type AdapterCategory, AdapterError, type AdapterErrorReason, type AdapterExtraction, type AdapterManifest, type AggregationOp, type ApplicantIdentity, BASE_FIELD_SPECS, BasicFormField, type CanonicalFieldName, type CanonicalFieldSpec, type CanonicalFieldValue, type CanonicalFieldValues, type Category, type CategorySchema, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DeclarativeImplementation, type DocExtractionResult, DocExtractionStatus, type DocumentFileMetadata, type DocumentRow, type DocumentRowCapabilities, type DropdownOption, type EditorValidator, ExtractionFileType, type ExtractionJobRecord, ExtractionJobStatus, type ExtractionStatusResult, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldMapEntry, type FieldReference, FieldType, type FileFieldTableData, type FileFieldTableItem, FileFieldTableType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, IHS_FAILURE_STATUSES, IHS_TERMINAL_STATUSES, IHS_VALID_STATUSES, type IhsDetailCategory, type IhsFieldDetail, type IhsFieldProvenance, IhsStatus, IhsValueFormat, type InstanceValue, type PageConfig, type RHFSchemaOutput, type RHFStep, type RawPayload, type ResolvedField, Role, type SourceAdapter, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type TypescriptImplementation, type UnifiedFormConfig, type Validator, allCategories, applyAggregation, applyDynamicTitles, assertAdapterCategory, buildDocumentRows, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, formatDocumentSize, formatDocumentType, formatDocumentUploaded, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getDocDisplayNames, getExtractableDocTypes, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getReuploadableDocTypes, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isAdapterCategory, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, parseFileField, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -449,6 +449,69 @@ interface FileFieldTableData {
|
|
|
449
449
|
items: FileFieldTableItem[];
|
|
450
450
|
hasData: boolean;
|
|
451
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Per-document File metadata attached by finsys-api `getIhsDetailsById` as the
|
|
454
|
+
* `documentMetadata` sibling map (SYS-2765), keyed by the document's raw stored
|
|
455
|
+
* path. The single source for the documents table's Type / Size / Uploaded
|
|
456
|
+
* columns — the IHS doc fields themselves carry only the path.
|
|
457
|
+
*/
|
|
458
|
+
interface DocumentFileMetadata {
|
|
459
|
+
fileName: string | null;
|
|
460
|
+
fileType: string | null;
|
|
461
|
+
fileSize: number | null;
|
|
462
|
+
createdAt: string | null;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Intrinsic, data-derived capability eligibility for a document row. Reflects
|
|
466
|
+
* ONLY what the IHS payload implies (doc type + a resolvable file); the consumer
|
|
467
|
+
* ANDs in its own runtime gates (readOnly, allowReupload, and — for viewJson —
|
|
468
|
+
* whether extraction has actually completed) before showing a control.
|
|
469
|
+
*/
|
|
470
|
+
interface DocumentRowCapabilities {
|
|
471
|
+
/** A downloadable original exists (a resolvable documentId). */
|
|
472
|
+
download: boolean;
|
|
473
|
+
/** The doc type produces extracted JSON (consumer still gates on "Extracted"). */
|
|
474
|
+
viewJson: boolean;
|
|
475
|
+
/** The doc type can be re-extracted. */
|
|
476
|
+
reExtract: boolean;
|
|
477
|
+
/** The doc type accepts a replacement upload (finsys-api /ihs/client/update/document). */
|
|
478
|
+
reUpload: boolean;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* One uploaded document, presentation-agnostic — built by `buildDocumentRows`
|
|
482
|
+
* from the IHS payload + its `documentMetadata` map. Rendered identically by
|
|
483
|
+
* FinHub (React) and finsys-client (Edge). Live extraction status + confidence
|
|
484
|
+
* are NOT payload-derived; the consumer overlays them by matching
|
|
485
|
+
* `(docType, timePeriod)`.
|
|
486
|
+
*/
|
|
487
|
+
interface DocumentRow {
|
|
488
|
+
/** IHS field key, e.g. 'bankStatements'. */
|
|
489
|
+
docType: string;
|
|
490
|
+
/** Human label for the doc-type group, e.g. 'Bank Statements'. */
|
|
491
|
+
label: string;
|
|
492
|
+
/** 0-based position within the docType group. */
|
|
493
|
+
index: number;
|
|
494
|
+
/** Best display name (resolved file name, or a label + period/index fallback). */
|
|
495
|
+
displayName: string;
|
|
496
|
+
/** Id for the download link; null when no file path is resolvable. */
|
|
497
|
+
documentId: string | null;
|
|
498
|
+
/** Raw stored path — the join key back to `documentMetadata`. */
|
|
499
|
+
path: string | null;
|
|
500
|
+
/** Extraction time-period token: 'T{month|year}' or 'ALL'. */
|
|
501
|
+
timePeriod: string;
|
|
502
|
+
/** Human period label ('Jan 2026' / 'Year 2024') or null. */
|
|
503
|
+
periodLabel: string | null;
|
|
504
|
+
/** Resolved file name; null when the stored name looks like an opaque id. */
|
|
505
|
+
fileName: string | null;
|
|
506
|
+
/** File type label (extension → MIME subtype, upper-cased) or null. */
|
|
507
|
+
fileType: string | null;
|
|
508
|
+
/** File size in bytes, or null when unknown. */
|
|
509
|
+
fileSize: number | null;
|
|
510
|
+
/** ISO upload timestamp (File.createdAt) or null. */
|
|
511
|
+
uploadedAt: string | null;
|
|
512
|
+
/** Intrinsic capability eligibility (consumer overlays its runtime gates). */
|
|
513
|
+
capabilities: DocumentRowCapabilities;
|
|
514
|
+
}
|
|
452
515
|
|
|
453
516
|
/** Returns the full display name registry (extraction column → human label). */
|
|
454
517
|
declare function getDisplayNames(): Record<string, string>;
|
|
@@ -460,6 +523,42 @@ declare function groupFieldsByPattern(fields: FieldData[]): Record<string, Field
|
|
|
460
523
|
/** Returns human-friendly display names for field groups. */
|
|
461
524
|
declare function getGroupDisplayNames(): Record<string, string>;
|
|
462
525
|
declare function buildFileFieldTables(ihsData: Record<string, unknown>, fieldProvenance?: Record<string, IhsFieldProvenance>): Record<string, FileFieldTableData>;
|
|
526
|
+
/** IHS doc-field key → human label (the fields that become document sections). */
|
|
527
|
+
declare function getDocDisplayNames(): Record<string, string>;
|
|
528
|
+
/** Doc types eligible for extraction (re-extract / view-JSON). */
|
|
529
|
+
declare function getExtractableDocTypes(): Set<string>;
|
|
530
|
+
/** Doc types eligible for a replacement upload. */
|
|
531
|
+
declare function getReuploadableDocTypes(): Set<string>;
|
|
532
|
+
interface ParsedDocFile {
|
|
533
|
+
path?: string;
|
|
534
|
+
fileName?: string;
|
|
535
|
+
documentId?: string;
|
|
536
|
+
fileSize?: number | string;
|
|
537
|
+
fileType?: string;
|
|
538
|
+
createdAt?: string;
|
|
539
|
+
month?: number;
|
|
540
|
+
year?: number;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Parse one IHS doc field into file entries. Handles the shapes the field takes:
|
|
544
|
+
* a JSON-array string (bank/financial/…, possibly inline-enriched like
|
|
545
|
+
* supplementaryDoc), an already-parsed array, or a bare URL string (ssm/form9/ic).
|
|
546
|
+
*/
|
|
547
|
+
declare function parseFileField(value: unknown): ParsedDocFile[];
|
|
548
|
+
/**
|
|
549
|
+
* Build the presentation-agnostic document rows for an IHS. Reads the doc fields
|
|
550
|
+
* named in DOC_DISPLAY_NAMES + the `documentMetadata` sibling map (SYS-2765) and
|
|
551
|
+
* emits a flat DocumentRow[] (all sections, in DOC_DISPLAY_NAMES order). Metadata
|
|
552
|
+
* is taken inline off the entry first (supplementaryDoc is enriched inline), then
|
|
553
|
+
* from `documentMetadata[path]`.
|
|
554
|
+
*/
|
|
555
|
+
declare function buildDocumentRows(ihsData: Record<string, unknown>): DocumentRow[];
|
|
556
|
+
/** Type column: the resolved type label, or em-dash. */
|
|
557
|
+
declare function formatDocumentType(row: Pick<DocumentRow, 'fileType'>): string;
|
|
558
|
+
/** Size column: human bytes (B / KB / MB), or em-dash when unknown. */
|
|
559
|
+
declare function formatDocumentSize(bytes: number | null | undefined): string;
|
|
560
|
+
/** Uploaded column: the upload date, else the period label, else em-dash. */
|
|
561
|
+
declare function formatDocumentUploaded(row: Pick<DocumentRow, 'uploadedAt' | 'periodLabel'>): string;
|
|
463
562
|
declare function processIhsDetails(ihsData: Record<string, unknown>): IhsFieldDetail[];
|
|
464
563
|
declare function groupDetailsByCategory(details: IhsFieldDetail[]): IhsDetailCategory[];
|
|
465
564
|
|
|
@@ -1249,4 +1348,4 @@ interface FieldMapEntry {
|
|
|
1249
1348
|
readonly transform?: "identity" | "pct_to_ratio01" | "to_boolean" | "to_integer";
|
|
1250
1349
|
}
|
|
1251
1350
|
|
|
1252
|
-
export { ADAPTER_CATEGORY_IDS, ALL_AGGREGATION_OPS, type AdapterCategory, AdapterError, type AdapterErrorReason, type AdapterExtraction, type AdapterManifest, type AggregationOp, type ApplicantIdentity, BASE_FIELD_SPECS, BasicFormField, type CanonicalFieldName, type CanonicalFieldSpec, type CanonicalFieldValue, type CanonicalFieldValues, type Category, type CategorySchema, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DeclarativeImplementation, type DocExtractionResult, DocExtractionStatus, type DropdownOption, type EditorValidator, ExtractionFileType, type ExtractionJobRecord, ExtractionJobStatus, type ExtractionStatusResult, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldMapEntry, type FieldReference, FieldType, type FileFieldTableData, type FileFieldTableItem, FileFieldTableType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, IHS_FAILURE_STATUSES, IHS_TERMINAL_STATUSES, IHS_VALID_STATUSES, type IhsDetailCategory, type IhsFieldDetail, type IhsFieldProvenance, IhsStatus, IhsValueFormat, type InstanceValue, type PageConfig, type RHFSchemaOutput, type RHFStep, type RawPayload, type ResolvedField, Role, type SourceAdapter, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type TypescriptImplementation, type UnifiedFormConfig, type Validator, allCategories, applyAggregation, applyDynamicTitles, assertAdapterCategory, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isAdapterCategory, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
|
1351
|
+
export { ADAPTER_CATEGORY_IDS, ALL_AGGREGATION_OPS, type AdapterCategory, AdapterError, type AdapterErrorReason, type AdapterExtraction, type AdapterManifest, type AggregationOp, type ApplicantIdentity, BASE_FIELD_SPECS, BasicFormField, type CanonicalFieldName, type CanonicalFieldSpec, type CanonicalFieldValue, type CanonicalFieldValues, type Category, type CategorySchema, type Choice, DEFAULT_VALIDATOR_DEFINITIONS, type DeclarativeImplementation, type DocExtractionResult, DocExtractionStatus, type DocumentFileMetadata, type DocumentRow, type DocumentRowCapabilities, type DropdownOption, type EditorValidator, ExtractionFileType, type ExtractionJobRecord, ExtractionJobStatus, type ExtractionStatusResult, FIELD_TYPE_DEFINITIONS, type FieldData, type FieldGroup, type FieldMapEntry, type FieldReference, FieldType, type FileFieldTableData, type FileFieldTableItem, FileFieldTableType, FileFormField, FormField, FormFieldCategory, type FormFieldInputType, type FormFieldType, type FormFieldTypeDefinitions, FormFieldValidator, FormSpec, type FormValidatorDefinitions, IHS_FAILURE_STATUSES, IHS_TERMINAL_STATUSES, IHS_VALID_STATUSES, type IhsDetailCategory, type IhsFieldDetail, type IhsFieldProvenance, IhsStatus, IhsValueFormat, type InstanceValue, type PageConfig, type RHFSchemaOutput, type RHFStep, type RawPayload, type ResolvedField, Role, type SourceAdapter, type SurveyElementJSON, type SurveyJSON, type SurveyPageJSON, type TypescriptImplementation, type UnifiedFormConfig, type Validator, allCategories, applyAggregation, applyDynamicTitles, assertAdapterCategory, buildDocumentRows, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, formatDocumentSize, formatDocumentType, formatDocumentUploaded, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getDocDisplayNames, getExtractableDocTypes, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getReuploadableDocTypes, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isAdapterCategory, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, parseFileField, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
package/dist/index.js
CHANGED
|
@@ -8389,7 +8389,7 @@ var form_field_base_specs_default = {
|
|
|
8389
8389
|
ihs_column_names: [
|
|
8390
8390
|
"ssmCompanyName",
|
|
8391
8391
|
"ssmCompanyRegNo",
|
|
8392
|
-
"
|
|
8392
|
+
"incorporatedDate",
|
|
8393
8393
|
"businessCommencementDate",
|
|
8394
8394
|
"businessNature",
|
|
8395
8395
|
"ssmCompanyEntityType",
|
|
@@ -9238,7 +9238,6 @@ var form_field_display_names_default = {
|
|
|
9238
9238
|
companyRegNo: "Company Registration No.",
|
|
9239
9239
|
ssmCompanyName: "Company Name (SSM)",
|
|
9240
9240
|
ssmCompanyRegNo: "Registration No. (SSM)",
|
|
9241
|
-
ssmIncorporatedDate: "Incorporated Date (SSM)",
|
|
9242
9241
|
ssmCompanyEntityType: "Entity Type (SSM)",
|
|
9243
9242
|
ssmPaidUpCapital: "Paid-Up Capital (SSM)",
|
|
9244
9243
|
businessCommencementDate: "Business Commencement Date",
|
|
@@ -9451,6 +9450,147 @@ function buildFileFieldTables(ihsData, fieldProvenance) {
|
|
|
9451
9450
|
}
|
|
9452
9451
|
return tables;
|
|
9453
9452
|
}
|
|
9453
|
+
var DOC_DISPLAY_NAMES = {
|
|
9454
|
+
bankStatements: "Bank Statements",
|
|
9455
|
+
financialStatements: "Financial Statements",
|
|
9456
|
+
form9: "Form 9",
|
|
9457
|
+
epfStatements: "EPF Statements",
|
|
9458
|
+
payslips: "Payslips",
|
|
9459
|
+
ssm: "SSM Company Profile",
|
|
9460
|
+
ic: "Identity Card",
|
|
9461
|
+
ssm_registration_documents: "Form 9",
|
|
9462
|
+
ic_documents: "Identity Documents (Supplementary)",
|
|
9463
|
+
consentForm: "Consent Form",
|
|
9464
|
+
supplementaryDoc: "Supplementary Documents",
|
|
9465
|
+
coreIncomeDoc: "Core Income Document",
|
|
9466
|
+
incomeSupportingDoc: "Income Supporting Document",
|
|
9467
|
+
incomeEPF_iakaun: "EPF i-Akaun",
|
|
9468
|
+
photocopyRegistrationCard: "Registration Card",
|
|
9469
|
+
bankStatementOrSavingPassbook: "Bank Passbook",
|
|
9470
|
+
tnbBills: "TNB Bills"
|
|
9471
|
+
};
|
|
9472
|
+
var EXTRACTABLE_DOC_TYPES = /* @__PURE__ */ new Set([
|
|
9473
|
+
"bankStatements",
|
|
9474
|
+
"financialStatements",
|
|
9475
|
+
"form9",
|
|
9476
|
+
"epfStatements",
|
|
9477
|
+
"payslips",
|
|
9478
|
+
"ssm",
|
|
9479
|
+
"ic",
|
|
9480
|
+
"ssm_registration_documents",
|
|
9481
|
+
"ic_documents"
|
|
9482
|
+
]);
|
|
9483
|
+
var REUPLOADABLE_DOC_TYPES = /* @__PURE__ */ new Set(["bankStatements", "financialStatements"]);
|
|
9484
|
+
function getDocDisplayNames() {
|
|
9485
|
+
return DOC_DISPLAY_NAMES;
|
|
9486
|
+
}
|
|
9487
|
+
function getExtractableDocTypes() {
|
|
9488
|
+
return EXTRACTABLE_DOC_TYPES;
|
|
9489
|
+
}
|
|
9490
|
+
function getReuploadableDocTypes() {
|
|
9491
|
+
return REUPLOADABLE_DOC_TYPES;
|
|
9492
|
+
}
|
|
9493
|
+
function isProbablyId(str) {
|
|
9494
|
+
if (!str) return false;
|
|
9495
|
+
const clean = str.split(".")[0];
|
|
9496
|
+
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;
|
|
9497
|
+
if (/^[0-9a-f]{32,128}$/i.test(clean)) return true;
|
|
9498
|
+
return false;
|
|
9499
|
+
}
|
|
9500
|
+
function parseFileField(value) {
|
|
9501
|
+
if (!value) return [];
|
|
9502
|
+
if (Array.isArray(value)) return value;
|
|
9503
|
+
if (typeof value === "string") {
|
|
9504
|
+
try {
|
|
9505
|
+
const parsed = JSON.parse(value);
|
|
9506
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
9507
|
+
} catch {
|
|
9508
|
+
if (value.startsWith("http")) {
|
|
9509
|
+
return [{ path: value, documentId: value.split("/").pop() || void 0 }];
|
|
9510
|
+
}
|
|
9511
|
+
return [];
|
|
9512
|
+
}
|
|
9513
|
+
}
|
|
9514
|
+
return [];
|
|
9515
|
+
}
|
|
9516
|
+
function toBytes(value) {
|
|
9517
|
+
if (typeof value === "number") return Number.isNaN(value) ? null : value;
|
|
9518
|
+
if (typeof value === "string") {
|
|
9519
|
+
const n = parseInt(value, 10);
|
|
9520
|
+
return Number.isNaN(n) ? null : n;
|
|
9521
|
+
}
|
|
9522
|
+
return null;
|
|
9523
|
+
}
|
|
9524
|
+
function buildDocumentRows(ihsData) {
|
|
9525
|
+
const metaMap = ihsData.documentMetadata ?? {};
|
|
9526
|
+
const rows = [];
|
|
9527
|
+
for (const docType of Object.keys(DOC_DISPLAY_NAMES)) {
|
|
9528
|
+
const files = parseFileField(ihsData[docType]);
|
|
9529
|
+
if (files.length === 0) continue;
|
|
9530
|
+
const label = DOC_DISPLAY_NAMES[docType];
|
|
9531
|
+
const extractable = EXTRACTABLE_DOC_TYPES.has(docType);
|
|
9532
|
+
const reUploadable = extractable && REUPLOADABLE_DOC_TYPES.has(docType);
|
|
9533
|
+
files.forEach((file, index) => {
|
|
9534
|
+
const path = file.path ?? null;
|
|
9535
|
+
const meta = path ? metaMap[path] : void 0;
|
|
9536
|
+
const documentId = file.documentId || (path ? path.split("/").pop() || null : null);
|
|
9537
|
+
const timePeriod = file.month ? `T${file.month}` : file.year ? `T${file.year}` : "ALL";
|
|
9538
|
+
const rawName = file.fileName ?? meta?.fileName ?? void 0;
|
|
9539
|
+
const fileName = rawName && !isProbablyId(rawName) ? rawName : null;
|
|
9540
|
+
const rawExt = (rawName ?? "").split(".").pop();
|
|
9541
|
+
const ext = rawExt && rawExt.length <= 5 && !isProbablyId(rawExt) ? rawExt.toUpperCase() : null;
|
|
9542
|
+
const mime = file.fileType ?? meta?.fileType;
|
|
9543
|
+
const fileType = ext || (mime?.split("/").pop()?.toUpperCase() ?? null);
|
|
9544
|
+
const fileSize = toBytes(file.fileSize) ?? meta?.fileSize ?? null;
|
|
9545
|
+
const uploadedAt = file.createdAt ?? meta?.createdAt ?? null;
|
|
9546
|
+
const periodLabel = file.month && file.year ? new Date(file.year, file.month - 1).toLocaleDateString("en-MY", {
|
|
9547
|
+
year: "numeric",
|
|
9548
|
+
month: "short"
|
|
9549
|
+
}) : file.year ? `Year ${file.year}` : null;
|
|
9550
|
+
const displayName = fileName || (periodLabel ? `${label} \u2014 ${periodLabel}` : files.length > 1 ? `${label} ${index + 1}` : label);
|
|
9551
|
+
rows.push({
|
|
9552
|
+
docType,
|
|
9553
|
+
label,
|
|
9554
|
+
index,
|
|
9555
|
+
displayName,
|
|
9556
|
+
documentId,
|
|
9557
|
+
path,
|
|
9558
|
+
timePeriod,
|
|
9559
|
+
periodLabel,
|
|
9560
|
+
fileName,
|
|
9561
|
+
fileType,
|
|
9562
|
+
fileSize,
|
|
9563
|
+
uploadedAt,
|
|
9564
|
+
capabilities: {
|
|
9565
|
+
download: !!documentId,
|
|
9566
|
+
viewJson: extractable,
|
|
9567
|
+
reExtract: extractable,
|
|
9568
|
+
reUpload: reUploadable
|
|
9569
|
+
}
|
|
9570
|
+
});
|
|
9571
|
+
});
|
|
9572
|
+
}
|
|
9573
|
+
return rows;
|
|
9574
|
+
}
|
|
9575
|
+
var EM_DASH = "\u2014";
|
|
9576
|
+
function formatDocumentType(row) {
|
|
9577
|
+
return row.fileType ?? EM_DASH;
|
|
9578
|
+
}
|
|
9579
|
+
function formatDocumentSize(bytes) {
|
|
9580
|
+
if (!bytes || Number.isNaN(bytes)) return EM_DASH;
|
|
9581
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
9582
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
9583
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
9584
|
+
}
|
|
9585
|
+
function formatDocumentUploaded(row) {
|
|
9586
|
+
if (row.uploadedAt) {
|
|
9587
|
+
const d = new Date(row.uploadedAt);
|
|
9588
|
+
if (!Number.isNaN(d.getTime())) {
|
|
9589
|
+
return d.toLocaleDateString("en-MY", { year: "numeric", month: "short", day: "numeric" });
|
|
9590
|
+
}
|
|
9591
|
+
}
|
|
9592
|
+
return row.periodLabel ?? EM_DASH;
|
|
9593
|
+
}
|
|
9454
9594
|
function isFileOrFinancialColumn(fieldName, fileColumnSet) {
|
|
9455
9595
|
return fileColumnSet.has(fieldName) || fieldName.startsWith("financials") || fieldName.startsWith("bank_statement");
|
|
9456
9596
|
}
|
|
@@ -10373,12 +10513,16 @@ export {
|
|
|
10373
10513
|
applyAggregation,
|
|
10374
10514
|
applyDynamicTitles,
|
|
10375
10515
|
assertAdapterCategory,
|
|
10516
|
+
buildDocumentRows,
|
|
10376
10517
|
buildFileFieldTables,
|
|
10377
10518
|
categoryFieldsOf,
|
|
10378
10519
|
categoryForField,
|
|
10379
10520
|
categorySchemaOf,
|
|
10380
10521
|
evaluateExpression,
|
|
10381
10522
|
extractTimePeriods,
|
|
10523
|
+
formatDocumentSize,
|
|
10524
|
+
formatDocumentType,
|
|
10525
|
+
formatDocumentUploaded,
|
|
10382
10526
|
generateRHFSchema,
|
|
10383
10527
|
generateSurveyJson,
|
|
10384
10528
|
getBaseCategories,
|
|
@@ -10388,9 +10532,12 @@ export {
|
|
|
10388
10532
|
getCategoryName,
|
|
10389
10533
|
getDisplayName,
|
|
10390
10534
|
getDisplayNames,
|
|
10535
|
+
getDocDisplayNames,
|
|
10536
|
+
getExtractableDocTypes,
|
|
10391
10537
|
getGroupDisplayNames,
|
|
10392
10538
|
getPastMonthLabel,
|
|
10393
10539
|
getPastYearLabel,
|
|
10540
|
+
getReuploadableDocTypes,
|
|
10394
10541
|
getStepDefaultValues,
|
|
10395
10542
|
getStepSchema,
|
|
10396
10543
|
groupColumnsByTimePeriod,
|
|
@@ -10401,6 +10548,7 @@ export {
|
|
|
10401
10548
|
isFailureIhsStatus,
|
|
10402
10549
|
isTerminalIhsStatus,
|
|
10403
10550
|
isValidIhsStatus,
|
|
10551
|
+
parseFileField,
|
|
10404
10552
|
processIhsDetails,
|
|
10405
10553
|
resolveExtractionStatus,
|
|
10406
10554
|
resolvePageFields,
|