@finsys/core 2.6.0 → 2.7.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/README.md +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -2
- package/dist/index.d.ts +164 -2
- package/dist/index.js.map +1 -1
- package/dist/schema/adapter-manifest.schema.json +11 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -744,8 +744,26 @@ type CanonicalFieldValue = number | string | boolean | null;
|
|
|
744
744
|
* host app's discovery mechanism (SYS-2444); the host app constructs
|
|
745
745
|
* the adapter from its manifest + extract module, then registers it
|
|
746
746
|
* against the registry by `id`.
|
|
747
|
+
*
|
|
748
|
+
* Type parameter `E` lets adapter authors declare the partner-specific
|
|
749
|
+
* extension shape on ApplicantIdentity. v2.7.0+ — defaults to `{}` so
|
|
750
|
+
* v2.6.0 adapters (which didn't have fetch and never read identity)
|
|
751
|
+
* stay assignment-compatible. A telco adapter that needs an MSISDN
|
|
752
|
+
* declares it once at the interface level:
|
|
753
|
+
*
|
|
754
|
+
* interface CelcomExt { msisdn: string }
|
|
755
|
+
* const celcomTelco: SourceAdapter<CelcomExt> = {
|
|
756
|
+
* async fetch(identity) {
|
|
757
|
+
* identity.msisdn // string (typed via E)
|
|
758
|
+
* identity.ic // string (core)
|
|
759
|
+
* },
|
|
760
|
+
* ...
|
|
761
|
+
* }
|
|
762
|
+
*
|
|
763
|
+
* The generic flows from interface → method, so implementations
|
|
764
|
+
* don't have to redeclare it on fetch.
|
|
747
765
|
*/
|
|
748
|
-
interface SourceAdapter {
|
|
766
|
+
interface SourceAdapter<E extends Record<string, unknown> = {}> {
|
|
749
767
|
/**
|
|
750
768
|
* Globally unique id for this adapter instance. By convention:
|
|
751
769
|
* `<vendor>-<category-short>-v<n>` — e.g. `celcom-telco-v1`. Vendor
|
|
@@ -803,7 +821,129 @@ interface SourceAdapter {
|
|
|
803
821
|
* expected-failure path.
|
|
804
822
|
*/
|
|
805
823
|
extract(raw: RawPayload): Promise<AdapterExtraction[]>;
|
|
824
|
+
/**
|
|
825
|
+
* Optional partner-data fetch path. v2.7.0+ — adapters that own their
|
|
826
|
+
* partner-API integration declare this method; the host invokes it
|
|
827
|
+
* before extract() and passes the result through. Adapters that
|
|
828
|
+
* receive raw payload from elsewhere (e.g., bank-statement adapters
|
|
829
|
+
* reading FinXtract OCR output, or webhook-driven push ingest) omit
|
|
830
|
+
* fetch() entirely and the host treats raw as already-staged.
|
|
831
|
+
*
|
|
832
|
+
* The host builds `identity` from the IHS row (ic, fullName, etc.)
|
|
833
|
+
* plus any partner-specific fields the adapter declared via the
|
|
834
|
+
* manifest's `requiredIdentityFields`. If a required field is missing
|
|
835
|
+
* from the IHS, the host logs + skips this adapter for the run
|
|
836
|
+
* (no extract call, no canonical rows).
|
|
837
|
+
*
|
|
838
|
+
* Implementations should:
|
|
839
|
+
* - Throw AdapterError('source_unavailable') ONLY on transient,
|
|
840
|
+
* retryable upstream failures (timeouts, 5xx, rate limits). The
|
|
841
|
+
* host runner is free to retry these; misclassifying a permanent
|
|
842
|
+
* failure here will burn retry budget for nothing.
|
|
843
|
+
* - Throw AdapterError('not_applicable') on permanent
|
|
844
|
+
* no-relationship signals — 404 ("applicant unknown to partner"),
|
|
845
|
+
* 410, an explicit "not a subscriber" response. Communicates
|
|
846
|
+
* 'we asked and they said no' so the host records the run + skips
|
|
847
|
+
* retry. This is the correct reason for most non-retryable
|
|
848
|
+
* upstream conditions.
|
|
849
|
+
* - Throw AdapterError('payload_invalid') if the partner returned
|
|
850
|
+
* a malformed response (200 with garbage body, schema violation).
|
|
851
|
+
* - Return a RawPayload that extract() will translate. The same
|
|
852
|
+
* adapter's extract() is the only consumer; the host doesn't
|
|
853
|
+
* inspect the shape.
|
|
854
|
+
*
|
|
855
|
+
* Strict additive — v2.6.0 read-only adapters that omit fetch()
|
|
856
|
+
* keep working without change.
|
|
857
|
+
*
|
|
858
|
+
* @example WRONG — recurses into the adapter method:
|
|
859
|
+
* ```ts
|
|
860
|
+
* const adapter: SourceAdapter = {
|
|
861
|
+
* async fetch(identity) {
|
|
862
|
+
* const res = await fetch(`/api/lookup/${identity.ic}`) // infinite recursion
|
|
863
|
+
* return res.json()
|
|
864
|
+
* },
|
|
865
|
+
* ...
|
|
866
|
+
* }
|
|
867
|
+
* ```
|
|
868
|
+
*
|
|
869
|
+
* @example RIGHT — explicit globalThis access:
|
|
870
|
+
* ```ts
|
|
871
|
+
* const adapter: SourceAdapter = {
|
|
872
|
+
* async fetch(identity) {
|
|
873
|
+
* const res = await globalThis.fetch(`/api/lookup/${identity.ic}`)
|
|
874
|
+
* return res.json()
|
|
875
|
+
* },
|
|
876
|
+
* ...
|
|
877
|
+
* }
|
|
878
|
+
* ```
|
|
879
|
+
*
|
|
880
|
+
* Implementation note: this method is named `fetch` which shadows
|
|
881
|
+
* the global `fetch()` inside the method body — see the @example
|
|
882
|
+
* blocks above. The fake-* reference adapters in
|
|
883
|
+
* @finsys/adapter-toolkit use the explicit-globalThis pattern.
|
|
884
|
+
* Partner repos can also pin this with the lint rule
|
|
885
|
+
* `no-restricted-syntax`: `CallExpression[callee.name='fetch']`
|
|
886
|
+
* inside any method literal named `fetch`.
|
|
887
|
+
*/
|
|
888
|
+
fetch?(identity: ApplicantIdentity<E>): Promise<RawPayload>;
|
|
806
889
|
}
|
|
890
|
+
/**
|
|
891
|
+
* Identity payload the host hands to fetch() so adapters can call
|
|
892
|
+
* partner APIs with the right per-applicant identifiers.
|
|
893
|
+
*
|
|
894
|
+
* The shape is an intersection of three pieces:
|
|
895
|
+
* - Core fields (`ihsId`, `ic`, `fullName`) — always present, the
|
|
896
|
+
* host populates them from the IHS row before invoking fetch().
|
|
897
|
+
* - Partner extensions (`E`) — typed declaratively per adapter.
|
|
898
|
+
* Defaults to `{}` (no extra typed fields) for adapters that only
|
|
899
|
+
* need the core trio.
|
|
900
|
+
* - Open index signature (`[k: string]: unknown`) — catches any
|
|
901
|
+
* ad-hoc field a host might pass through; reads land on `unknown`
|
|
902
|
+
* so partners must validate before use.
|
|
903
|
+
*
|
|
904
|
+
* Narrowing example (the ergonomics win this type is designed to deliver):
|
|
905
|
+
*
|
|
906
|
+
* interface CelcomExt { msisdn: string; accountRef: string }
|
|
907
|
+
*
|
|
908
|
+
* // declare adapter with the extension shape baked in:
|
|
909
|
+
* const celcom: SourceAdapter<CelcomExt> = {
|
|
910
|
+
* async fetch(identity) {
|
|
911
|
+
* identity.ic // string
|
|
912
|
+
* identity.msisdn // string (NOT unknown — narrowed by E)
|
|
913
|
+
* identity.foo // unknown (falls through to index signature)
|
|
914
|
+
* // ...
|
|
915
|
+
* },
|
|
916
|
+
* // ...
|
|
917
|
+
* }
|
|
918
|
+
*
|
|
919
|
+
* The intersection puts narrowed members at the root, so partners get
|
|
920
|
+
* `identity.msisdn` (not `identity.extensions?.msisdn`) — matching the
|
|
921
|
+
* pattern the host actually uses (it spreads partner-required fields
|
|
922
|
+
* onto the root identity object, no nested 'extensions' envelope).
|
|
923
|
+
*
|
|
924
|
+
* Examples:
|
|
925
|
+
* - Telco adapter declares `requiredIdentityFields: ['msisdn']`.
|
|
926
|
+
* Identity arrives with msisdn populated; adapter calls partner API.
|
|
927
|
+
* (Don't include 'ihsId', 'ic', or 'fullName' in
|
|
928
|
+
* `requiredIdentityFields` — those are core fields. `ic` in
|
|
929
|
+
* particular can be legitimately empty for non-MY scope, so
|
|
930
|
+
* declaring it required would cause the host to skip every applicant.)
|
|
931
|
+
* - Payment-network adapter declares `requiredIdentityFields:
|
|
932
|
+
* ['businessRegistrationNumber']`. Adapter looks it up + calls.
|
|
933
|
+
* - An adapter that only needs the IHS id declares no extra
|
|
934
|
+
* fields; identity has just the core trio.
|
|
935
|
+
*/
|
|
936
|
+
type ApplicantIdentity<E extends Record<string, unknown> = {}> = {
|
|
937
|
+
/** Internal IHS id — always present. */
|
|
938
|
+
readonly ihsId: number;
|
|
939
|
+
/** Malaysian IC (or analogous national id). May be empty for non-MY scope. */
|
|
940
|
+
readonly ic: string;
|
|
941
|
+
/** Applicant full legal name. */
|
|
942
|
+
readonly fullName: string;
|
|
943
|
+
} & E & {
|
|
944
|
+
/** Catch-all for ad-hoc reads (typed `unknown` — validate before use). */
|
|
945
|
+
readonly [key: string]: unknown;
|
|
946
|
+
};
|
|
807
947
|
/**
|
|
808
948
|
* Typed error thrown by adapters on expected failure paths. The
|
|
809
949
|
* `reason` discriminator lets the host app's adapter runner classify
|
|
@@ -984,6 +1124,28 @@ interface AdapterManifest {
|
|
|
984
1124
|
* host imports it dynamically.
|
|
985
1125
|
*/
|
|
986
1126
|
readonly implementation: DeclarativeImplementation | TypescriptImplementation;
|
|
1127
|
+
/**
|
|
1128
|
+
* v2.7.0 — partner-specific identity fields the adapter needs from
|
|
1129
|
+
* the IHS row when fetch() is invoked. Strings name the keys that
|
|
1130
|
+
* MUST be present on the ApplicantIdentity payload — the host
|
|
1131
|
+
* validates per-applicant before calling fetch() and skips the
|
|
1132
|
+
* adapter (with a logged warning) if any required field is missing.
|
|
1133
|
+
*
|
|
1134
|
+
* Examples:
|
|
1135
|
+
* - Telco adapter: `["ic", "msisdn"]`
|
|
1136
|
+
* - Payment-network adapter: `["businessRegistrationNumber"]`
|
|
1137
|
+
* - Bank-statement-from-OCR adapter: `[]` (no fetch — extract
|
|
1138
|
+
* reads from FinXtract output staged elsewhere)
|
|
1139
|
+
*
|
|
1140
|
+
* Omit entirely (or use empty array) for adapters that don't
|
|
1141
|
+
* implement fetch() — the host then passes an empty raw payload
|
|
1142
|
+
* to extract() and the adapter is responsible for sourcing data
|
|
1143
|
+
* via some other path (FinXtract output, webhook ingest, etc.).
|
|
1144
|
+
*
|
|
1145
|
+
* Core identity fields (`ihsId`, `ic`, `fullName`) are always
|
|
1146
|
+
* present — declaring them is harmless but unnecessary.
|
|
1147
|
+
*/
|
|
1148
|
+
readonly requiredIdentityFields?: ReadonlyArray<string>;
|
|
987
1149
|
/**
|
|
988
1150
|
* Optional free-form notes — useful for partner-side documentation
|
|
989
1151
|
* (where to find the adapter's source, who owns it, what version of
|
|
@@ -1036,4 +1198,4 @@ interface FieldMapEntry {
|
|
|
1036
1198
|
readonly transform?: "identity" | "pct_to_ratio01" | "to_boolean" | "to_integer";
|
|
1037
1199
|
}
|
|
1038
1200
|
|
|
1039
|
-
export { ALL_AGGREGATION_OPS, type AdapterCategory, AdapterError, type AdapterErrorReason, type AdapterExtraction, type AdapterManifest, type AggregationOp, 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, 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, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
|
1201
|
+
export { 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, 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, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -744,8 +744,26 @@ type CanonicalFieldValue = number | string | boolean | null;
|
|
|
744
744
|
* host app's discovery mechanism (SYS-2444); the host app constructs
|
|
745
745
|
* the adapter from its manifest + extract module, then registers it
|
|
746
746
|
* against the registry by `id`.
|
|
747
|
+
*
|
|
748
|
+
* Type parameter `E` lets adapter authors declare the partner-specific
|
|
749
|
+
* extension shape on ApplicantIdentity. v2.7.0+ — defaults to `{}` so
|
|
750
|
+
* v2.6.0 adapters (which didn't have fetch and never read identity)
|
|
751
|
+
* stay assignment-compatible. A telco adapter that needs an MSISDN
|
|
752
|
+
* declares it once at the interface level:
|
|
753
|
+
*
|
|
754
|
+
* interface CelcomExt { msisdn: string }
|
|
755
|
+
* const celcomTelco: SourceAdapter<CelcomExt> = {
|
|
756
|
+
* async fetch(identity) {
|
|
757
|
+
* identity.msisdn // string (typed via E)
|
|
758
|
+
* identity.ic // string (core)
|
|
759
|
+
* },
|
|
760
|
+
* ...
|
|
761
|
+
* }
|
|
762
|
+
*
|
|
763
|
+
* The generic flows from interface → method, so implementations
|
|
764
|
+
* don't have to redeclare it on fetch.
|
|
747
765
|
*/
|
|
748
|
-
interface SourceAdapter {
|
|
766
|
+
interface SourceAdapter<E extends Record<string, unknown> = {}> {
|
|
749
767
|
/**
|
|
750
768
|
* Globally unique id for this adapter instance. By convention:
|
|
751
769
|
* `<vendor>-<category-short>-v<n>` — e.g. `celcom-telco-v1`. Vendor
|
|
@@ -803,7 +821,129 @@ interface SourceAdapter {
|
|
|
803
821
|
* expected-failure path.
|
|
804
822
|
*/
|
|
805
823
|
extract(raw: RawPayload): Promise<AdapterExtraction[]>;
|
|
824
|
+
/**
|
|
825
|
+
* Optional partner-data fetch path. v2.7.0+ — adapters that own their
|
|
826
|
+
* partner-API integration declare this method; the host invokes it
|
|
827
|
+
* before extract() and passes the result through. Adapters that
|
|
828
|
+
* receive raw payload from elsewhere (e.g., bank-statement adapters
|
|
829
|
+
* reading FinXtract OCR output, or webhook-driven push ingest) omit
|
|
830
|
+
* fetch() entirely and the host treats raw as already-staged.
|
|
831
|
+
*
|
|
832
|
+
* The host builds `identity` from the IHS row (ic, fullName, etc.)
|
|
833
|
+
* plus any partner-specific fields the adapter declared via the
|
|
834
|
+
* manifest's `requiredIdentityFields`. If a required field is missing
|
|
835
|
+
* from the IHS, the host logs + skips this adapter for the run
|
|
836
|
+
* (no extract call, no canonical rows).
|
|
837
|
+
*
|
|
838
|
+
* Implementations should:
|
|
839
|
+
* - Throw AdapterError('source_unavailable') ONLY on transient,
|
|
840
|
+
* retryable upstream failures (timeouts, 5xx, rate limits). The
|
|
841
|
+
* host runner is free to retry these; misclassifying a permanent
|
|
842
|
+
* failure here will burn retry budget for nothing.
|
|
843
|
+
* - Throw AdapterError('not_applicable') on permanent
|
|
844
|
+
* no-relationship signals — 404 ("applicant unknown to partner"),
|
|
845
|
+
* 410, an explicit "not a subscriber" response. Communicates
|
|
846
|
+
* 'we asked and they said no' so the host records the run + skips
|
|
847
|
+
* retry. This is the correct reason for most non-retryable
|
|
848
|
+
* upstream conditions.
|
|
849
|
+
* - Throw AdapterError('payload_invalid') if the partner returned
|
|
850
|
+
* a malformed response (200 with garbage body, schema violation).
|
|
851
|
+
* - Return a RawPayload that extract() will translate. The same
|
|
852
|
+
* adapter's extract() is the only consumer; the host doesn't
|
|
853
|
+
* inspect the shape.
|
|
854
|
+
*
|
|
855
|
+
* Strict additive — v2.6.0 read-only adapters that omit fetch()
|
|
856
|
+
* keep working without change.
|
|
857
|
+
*
|
|
858
|
+
* @example WRONG — recurses into the adapter method:
|
|
859
|
+
* ```ts
|
|
860
|
+
* const adapter: SourceAdapter = {
|
|
861
|
+
* async fetch(identity) {
|
|
862
|
+
* const res = await fetch(`/api/lookup/${identity.ic}`) // infinite recursion
|
|
863
|
+
* return res.json()
|
|
864
|
+
* },
|
|
865
|
+
* ...
|
|
866
|
+
* }
|
|
867
|
+
* ```
|
|
868
|
+
*
|
|
869
|
+
* @example RIGHT — explicit globalThis access:
|
|
870
|
+
* ```ts
|
|
871
|
+
* const adapter: SourceAdapter = {
|
|
872
|
+
* async fetch(identity) {
|
|
873
|
+
* const res = await globalThis.fetch(`/api/lookup/${identity.ic}`)
|
|
874
|
+
* return res.json()
|
|
875
|
+
* },
|
|
876
|
+
* ...
|
|
877
|
+
* }
|
|
878
|
+
* ```
|
|
879
|
+
*
|
|
880
|
+
* Implementation note: this method is named `fetch` which shadows
|
|
881
|
+
* the global `fetch()` inside the method body — see the @example
|
|
882
|
+
* blocks above. The fake-* reference adapters in
|
|
883
|
+
* @finsys/adapter-toolkit use the explicit-globalThis pattern.
|
|
884
|
+
* Partner repos can also pin this with the lint rule
|
|
885
|
+
* `no-restricted-syntax`: `CallExpression[callee.name='fetch']`
|
|
886
|
+
* inside any method literal named `fetch`.
|
|
887
|
+
*/
|
|
888
|
+
fetch?(identity: ApplicantIdentity<E>): Promise<RawPayload>;
|
|
806
889
|
}
|
|
890
|
+
/**
|
|
891
|
+
* Identity payload the host hands to fetch() so adapters can call
|
|
892
|
+
* partner APIs with the right per-applicant identifiers.
|
|
893
|
+
*
|
|
894
|
+
* The shape is an intersection of three pieces:
|
|
895
|
+
* - Core fields (`ihsId`, `ic`, `fullName`) — always present, the
|
|
896
|
+
* host populates them from the IHS row before invoking fetch().
|
|
897
|
+
* - Partner extensions (`E`) — typed declaratively per adapter.
|
|
898
|
+
* Defaults to `{}` (no extra typed fields) for adapters that only
|
|
899
|
+
* need the core trio.
|
|
900
|
+
* - Open index signature (`[k: string]: unknown`) — catches any
|
|
901
|
+
* ad-hoc field a host might pass through; reads land on `unknown`
|
|
902
|
+
* so partners must validate before use.
|
|
903
|
+
*
|
|
904
|
+
* Narrowing example (the ergonomics win this type is designed to deliver):
|
|
905
|
+
*
|
|
906
|
+
* interface CelcomExt { msisdn: string; accountRef: string }
|
|
907
|
+
*
|
|
908
|
+
* // declare adapter with the extension shape baked in:
|
|
909
|
+
* const celcom: SourceAdapter<CelcomExt> = {
|
|
910
|
+
* async fetch(identity) {
|
|
911
|
+
* identity.ic // string
|
|
912
|
+
* identity.msisdn // string (NOT unknown — narrowed by E)
|
|
913
|
+
* identity.foo // unknown (falls through to index signature)
|
|
914
|
+
* // ...
|
|
915
|
+
* },
|
|
916
|
+
* // ...
|
|
917
|
+
* }
|
|
918
|
+
*
|
|
919
|
+
* The intersection puts narrowed members at the root, so partners get
|
|
920
|
+
* `identity.msisdn` (not `identity.extensions?.msisdn`) — matching the
|
|
921
|
+
* pattern the host actually uses (it spreads partner-required fields
|
|
922
|
+
* onto the root identity object, no nested 'extensions' envelope).
|
|
923
|
+
*
|
|
924
|
+
* Examples:
|
|
925
|
+
* - Telco adapter declares `requiredIdentityFields: ['msisdn']`.
|
|
926
|
+
* Identity arrives with msisdn populated; adapter calls partner API.
|
|
927
|
+
* (Don't include 'ihsId', 'ic', or 'fullName' in
|
|
928
|
+
* `requiredIdentityFields` — those are core fields. `ic` in
|
|
929
|
+
* particular can be legitimately empty for non-MY scope, so
|
|
930
|
+
* declaring it required would cause the host to skip every applicant.)
|
|
931
|
+
* - Payment-network adapter declares `requiredIdentityFields:
|
|
932
|
+
* ['businessRegistrationNumber']`. Adapter looks it up + calls.
|
|
933
|
+
* - An adapter that only needs the IHS id declares no extra
|
|
934
|
+
* fields; identity has just the core trio.
|
|
935
|
+
*/
|
|
936
|
+
type ApplicantIdentity<E extends Record<string, unknown> = {}> = {
|
|
937
|
+
/** Internal IHS id — always present. */
|
|
938
|
+
readonly ihsId: number;
|
|
939
|
+
/** Malaysian IC (or analogous national id). May be empty for non-MY scope. */
|
|
940
|
+
readonly ic: string;
|
|
941
|
+
/** Applicant full legal name. */
|
|
942
|
+
readonly fullName: string;
|
|
943
|
+
} & E & {
|
|
944
|
+
/** Catch-all for ad-hoc reads (typed `unknown` — validate before use). */
|
|
945
|
+
readonly [key: string]: unknown;
|
|
946
|
+
};
|
|
807
947
|
/**
|
|
808
948
|
* Typed error thrown by adapters on expected failure paths. The
|
|
809
949
|
* `reason` discriminator lets the host app's adapter runner classify
|
|
@@ -984,6 +1124,28 @@ interface AdapterManifest {
|
|
|
984
1124
|
* host imports it dynamically.
|
|
985
1125
|
*/
|
|
986
1126
|
readonly implementation: DeclarativeImplementation | TypescriptImplementation;
|
|
1127
|
+
/**
|
|
1128
|
+
* v2.7.0 — partner-specific identity fields the adapter needs from
|
|
1129
|
+
* the IHS row when fetch() is invoked. Strings name the keys that
|
|
1130
|
+
* MUST be present on the ApplicantIdentity payload — the host
|
|
1131
|
+
* validates per-applicant before calling fetch() and skips the
|
|
1132
|
+
* adapter (with a logged warning) if any required field is missing.
|
|
1133
|
+
*
|
|
1134
|
+
* Examples:
|
|
1135
|
+
* - Telco adapter: `["ic", "msisdn"]`
|
|
1136
|
+
* - Payment-network adapter: `["businessRegistrationNumber"]`
|
|
1137
|
+
* - Bank-statement-from-OCR adapter: `[]` (no fetch — extract
|
|
1138
|
+
* reads from FinXtract output staged elsewhere)
|
|
1139
|
+
*
|
|
1140
|
+
* Omit entirely (or use empty array) for adapters that don't
|
|
1141
|
+
* implement fetch() — the host then passes an empty raw payload
|
|
1142
|
+
* to extract() and the adapter is responsible for sourcing data
|
|
1143
|
+
* via some other path (FinXtract output, webhook ingest, etc.).
|
|
1144
|
+
*
|
|
1145
|
+
* Core identity fields (`ihsId`, `ic`, `fullName`) are always
|
|
1146
|
+
* present — declaring them is harmless but unnecessary.
|
|
1147
|
+
*/
|
|
1148
|
+
readonly requiredIdentityFields?: ReadonlyArray<string>;
|
|
987
1149
|
/**
|
|
988
1150
|
* Optional free-form notes — useful for partner-side documentation
|
|
989
1151
|
* (where to find the adapter's source, who owns it, what version of
|
|
@@ -1036,4 +1198,4 @@ interface FieldMapEntry {
|
|
|
1036
1198
|
readonly transform?: "identity" | "pct_to_ratio01" | "to_boolean" | "to_integer";
|
|
1037
1199
|
}
|
|
1038
1200
|
|
|
1039
|
-
export { ALL_AGGREGATION_OPS, type AdapterCategory, AdapterError, type AdapterErrorReason, type AdapterExtraction, type AdapterManifest, type AggregationOp, 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, 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, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|
|
1201
|
+
export { 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, 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, buildFileFieldTables, categoryFieldsOf, categoryForField, categorySchemaOf, evaluateExpression, extractTimePeriods, generateRHFSchema, generateSurveyJson, getBaseCategories, getBaseFieldNames, getBaseFieldSpecMap, getBaseFieldSpecs, getCategoryName, getDisplayName, getDisplayNames, getGroupDisplayNames, getPastMonthLabel, getPastYearLabel, getStepDefaultValues, getStepSchema, groupColumnsByTimePeriod, groupDetailsByCategory, groupFieldsByCategory, groupFieldsByPattern, isFailureIhsStatus, isTerminalIhsStatus, isValidIhsStatus, processIhsDetails, resolveExtractionStatus, resolvePageFields, validateFormConfig, validateFormSpec, validatePagesConfig };
|