@temboplus/frontend-core 1.0.1-beta.0 → 1.0.1-beta.2
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/domain/bank/bank.helpers.d.ts +5 -0
- package/dist/domain/mobile-money-provider/mobile-money-provider.d.ts +3 -3
- package/dist/domain/mobile-money-provider/mobile-money-provider.helpers.d.ts +62 -1
- package/dist/domain/mobile-money-provider/mobile-money-provider.types.d.ts +32 -1
- package/dist/factories/mobile-money-provider.factory.d.ts +2 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/registries/mobile-money-provider.registry.d.ts +3 -2
- package/package.json +1 -1
|
@@ -6,7 +6,12 @@ export declare const BankHelpers: {
|
|
|
6
6
|
validateSwiftCode: typeof validateSwiftCode;
|
|
7
7
|
validateAllBankDetails: typeof validateAllBankDetails;
|
|
8
8
|
getCountryFromSwiftCode: typeof getCountryFromSwiftCode;
|
|
9
|
+
validateAccountName: typeof validateAccountName;
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Validates a bank account name.
|
|
13
|
+
*/
|
|
14
|
+
declare function validateAccountName(accountName: string): boolean;
|
|
10
15
|
/**
|
|
11
16
|
* Validates a bank account number format. When countryCode is omitted, every
|
|
12
17
|
* supported country validator is checked.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChannelType, TransactionDirection } from "@domain/channel/channel.enums.js";
|
|
2
2
|
import type { ISO2CountryCode } from "@domain/country/country.types.js";
|
|
3
3
|
import { MobileMoneyProviderJSON } from "./mobile-money-provider.schema.js";
|
|
4
|
-
import type { MobileMoneyProviderData } from "./mobile-money-provider.types.js";
|
|
4
|
+
import type { MobileMoneyProviderData, MobileMoneyProviderId } from "./mobile-money-provider.types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Plain-object representation of a MobileMoneyProvider containing the full state.
|
|
7
7
|
*/
|
|
@@ -18,7 +18,7 @@ export declare const MobileMoneyProviderConstructorToken: unique symbol;
|
|
|
18
18
|
* the static methods on this class are thin delegations for ergonomic call sites.
|
|
19
19
|
*/
|
|
20
20
|
export declare class MobileMoneyProvider {
|
|
21
|
-
readonly id:
|
|
21
|
+
readonly id: MobileMoneyProviderId;
|
|
22
22
|
readonly displayName: string;
|
|
23
23
|
readonly mobileMoneyServiceName: string;
|
|
24
24
|
readonly countryCode: MobileMoneyProviderData["countryCode"];
|
|
@@ -42,7 +42,7 @@ export declare class MobileMoneyProvider {
|
|
|
42
42
|
* Resolves a MobileMoneyProvider by ID. When `countryCode` is omitted, the
|
|
43
43
|
* factory searches across every supported country.
|
|
44
44
|
*/
|
|
45
|
-
static fromID(id: string, countryCode?: ISO2CountryCode): MobileMoneyProvider | undefined;
|
|
45
|
+
static fromID(id: MobileMoneyProviderId | string, countryCode?: ISO2CountryCode): MobileMoneyProvider | undefined;
|
|
46
46
|
/** Re-resolves a MobileMoneyProvider from its compact JSON identity. */
|
|
47
47
|
static fromJSON(json: MobileMoneyProviderJSON | string): MobileMoneyProvider | undefined;
|
|
48
48
|
/** Re-resolves a MobileMoneyProvider from a JSON string. */
|
|
@@ -1,5 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TransactionDirection } from "@domain/channel/channel.enums.js";
|
|
2
|
+
import type { ISO2CountryCode } from "@domain/country/country.types.js";
|
|
3
|
+
import { PhoneNumber } from "@domain/phone-number/phone-number.js";
|
|
4
|
+
import { MobileMoneyProvider } from "./mobile-money-provider.js";
|
|
5
|
+
import { isMobileMoneyProviderId, isPhonePrefix, isProviderId, type MobileMoneyProviderId } from "./mobile-money-provider.types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Flat helper surface around `MobileMoneyProvider`, the registry, and the
|
|
8
|
+
* provider ID type guards. Mirrors `BankHelpers` / `CountryHelpers` so consumers
|
|
9
|
+
* have a single entry point and don't need to reach into the registry singleton
|
|
10
|
+
* directly.
|
|
11
|
+
*/
|
|
2
12
|
export declare const MobileMoneyProviderHelpers: {
|
|
3
13
|
isProviderId: typeof isProviderId;
|
|
14
|
+
isMobileMoneyProviderId: typeof isMobileMoneyProviderId;
|
|
4
15
|
isPhonePrefix: typeof isPhonePrefix;
|
|
16
|
+
findById: typeof findById;
|
|
17
|
+
getProviders: typeof getProviders;
|
|
18
|
+
requiresExplicitProvider: typeof requiresExplicitProvider;
|
|
19
|
+
isProviderSupported: typeof isProviderSupported;
|
|
20
|
+
detectProviderByPhoneNumber: typeof detectProviderByPhoneNumber;
|
|
21
|
+
validateProviderForPhoneNumber: typeof validateProviderForPhoneNumber;
|
|
5
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Resolves a provider by ID. When `countryCode` is provided the lookup is
|
|
25
|
+
* scoped to that country; otherwise every supported country is searched.
|
|
26
|
+
*
|
|
27
|
+
* @returns the matching `MobileMoneyProvider`, or `undefined` if not found.
|
|
28
|
+
*/
|
|
29
|
+
declare function findById(id: MobileMoneyProviderId | string, countryCode?: ISO2CountryCode): MobileMoneyProvider | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Returns every supported provider for a country, optionally filtered by
|
|
32
|
+
* transaction direction.
|
|
33
|
+
*/
|
|
34
|
+
declare function getProviders(countryCode: ISO2CountryCode, direction?: TransactionDirection): MobileMoneyProvider[];
|
|
35
|
+
/**
|
|
36
|
+
* Whether the country requires the caller to supply the provider ID
|
|
37
|
+
* explicitly (e.g. Kenya, where number portability makes prefix-based
|
|
38
|
+
* detection unreliable).
|
|
39
|
+
*/
|
|
40
|
+
declare function requiresExplicitProvider(countryCode: ISO2CountryCode): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a provider ID is supported in the given country, optionally
|
|
43
|
+
* constrained to a transaction direction.
|
|
44
|
+
*/
|
|
45
|
+
declare function isProviderSupported(countryCode: ISO2CountryCode, providerId: MobileMoneyProviderId | string, direction?: TransactionDirection): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Detects a provider from a phone number when prefix mapping is reliable.
|
|
48
|
+
*
|
|
49
|
+
* Accepts either a parsed `PhoneNumber` or a raw string (which will be parsed
|
|
50
|
+
* via `PhoneNumber.from`). Returns `undefined` when the country requires an
|
|
51
|
+
* explicit provider, or when no prefix matches.
|
|
52
|
+
*/
|
|
53
|
+
declare function detectProviderByPhoneNumber(input: PhoneNumber | string): MobileMoneyProvider | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Validates that a provider ID is consistent with a phone number.
|
|
56
|
+
*
|
|
57
|
+
* - When the country uses prefix-based detection, the supplied ID must match
|
|
58
|
+
* the provider auto-detected from the phone's prefix.
|
|
59
|
+
* - When the country requires an explicit provider, any supported ID for that
|
|
60
|
+
* country is accepted.
|
|
61
|
+
*
|
|
62
|
+
* Returns `false` if the phone number cannot be parsed or the ID is not
|
|
63
|
+
* supported in the inferred country.
|
|
64
|
+
*/
|
|
65
|
+
declare function validateProviderForPhoneNumber(phoneNumber: PhoneNumber | string, providerId: MobileMoneyProviderId | string): boolean;
|
|
66
|
+
export {};
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import type { ISO2CountryCode } from "@domain/country/country.types.js";
|
|
2
2
|
import type { CurrencyCode } from "@domain/currency/currency.types.js";
|
|
3
3
|
import type { TransactionDirection } from "@domain/channel/channel.enums.js";
|
|
4
|
+
/**
|
|
5
|
+
* Tanzania mobile-money provider IDs.
|
|
6
|
+
* Keep this in sync with src/data/mobile-money/tz.json.
|
|
7
|
+
*/
|
|
8
|
+
export type TZMobileMoneyProviderId = "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL";
|
|
9
|
+
/**
|
|
10
|
+
* Kenya mobile-money provider IDs.
|
|
11
|
+
* Keep this in sync with src/data/mobile-money/ke.json.
|
|
12
|
+
*/
|
|
13
|
+
export type KEMobileMoneyProviderId = "SAFARICOM";
|
|
14
|
+
/**
|
|
15
|
+
* Stable Tembo identifier for any supported mobile-money provider.
|
|
16
|
+
*
|
|
17
|
+
* Combines the per-country provider unions so a value of this type is
|
|
18
|
+
* guaranteed to refer to a real provider in the package's dataset.
|
|
19
|
+
*/
|
|
20
|
+
export type MobileMoneyProviderId = TZMobileMoneyProviderId | KEMobileMoneyProviderId;
|
|
4
21
|
export interface MobileMoneyProviderData {
|
|
5
|
-
id:
|
|
22
|
+
id: MobileMoneyProviderId;
|
|
6
23
|
displayName: string;
|
|
7
24
|
mobileMoneyServiceName: string;
|
|
8
25
|
countryCode: ISO2CountryCode;
|
|
@@ -11,10 +28,24 @@ export interface MobileMoneyProviderData {
|
|
|
11
28
|
requiresExplicitProvider: boolean;
|
|
12
29
|
phonePrefixes: string[];
|
|
13
30
|
}
|
|
31
|
+
/** Set of TZ provider IDs derived from the dataset for runtime lookups. */
|
|
32
|
+
export declare const TZMobileMoneyProviderIdsSet: Set<string>;
|
|
33
|
+
/** Set of KE provider IDs derived from the dataset for runtime lookups. */
|
|
34
|
+
export declare const KEMobileMoneyProviderIdsSet: Set<string>;
|
|
35
|
+
/** Combined set of every supported provider ID across countries. */
|
|
36
|
+
export declare const MobileMoneyProviderIdsSet: Set<string>;
|
|
14
37
|
/**
|
|
15
38
|
* Provider IDs are stable uppercase Tembo identifiers, not display names.
|
|
39
|
+
*
|
|
40
|
+
* This is a shape check (matches the regex of valid IDs); use
|
|
41
|
+
* `isMobileMoneyProviderId` for membership against the dataset.
|
|
16
42
|
*/
|
|
17
43
|
export declare function isProviderId(value: unknown): value is string;
|
|
44
|
+
/**
|
|
45
|
+
* Membership check: returns true when the value is one of the provider IDs
|
|
46
|
+
* present in the package's dataset.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isMobileMoneyProviderId(value: unknown): value is MobileMoneyProviderId;
|
|
18
49
|
/**
|
|
19
50
|
* Prefixes are national-number prefixes used only when detection is reliable.
|
|
20
51
|
*/
|
|
@@ -2,6 +2,7 @@ import type { ISO2CountryCode } from "@domain/country/country.types.js";
|
|
|
2
2
|
import type { CurrencyCode } from "@domain/currency/currency.types.js";
|
|
3
3
|
import { MobileMoneyProvider } from "@domain/mobile-money-provider/mobile-money-provider.js";
|
|
4
4
|
import { type MobileMoneyProviderJSON } from "@domain/mobile-money-provider/mobile-money-provider.schema.js";
|
|
5
|
+
import type { MobileMoneyProviderId } from "@domain/mobile-money-provider/mobile-money-provider.types.js";
|
|
5
6
|
import { type RawMobileMoneyProvider } from "@repositories/mobile-money-provider.repository.js";
|
|
6
7
|
/**
|
|
7
8
|
* Constructs MobileMoneyProvider model instances from raw provider records.
|
|
@@ -19,7 +20,7 @@ export declare class MobileMoneyProviderFactory {
|
|
|
19
20
|
* lookup is scoped to that country; otherwise the repository searches across
|
|
20
21
|
* every supported country.
|
|
21
22
|
*/
|
|
22
|
-
create(id: string, countryCode?: ISO2CountryCode): MobileMoneyProvider | undefined;
|
|
23
|
+
create(id: MobileMoneyProviderId | string, countryCode?: ISO2CountryCode): MobileMoneyProvider | undefined;
|
|
23
24
|
/**
|
|
24
25
|
* Builds a MobileMoneyProvider directly from a raw provider record plus the
|
|
25
26
|
* country/currency context (typically supplied by the repository or registry).
|