@temboplus/frontend-core 1.0.1-beta.1 → 1.0.1-beta.3

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.
@@ -10,10 +10,10 @@ export declare const AmountJSONSchema: z.ZodObject<{
10
10
  text: z.ZodString;
11
11
  /** The ISO currency code */
12
12
  currencyCode: z.ZodString;
13
- /** Version for future compatibility */
14
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
+ /** Model JSON schema version for future compatibility. */
14
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
15
15
  }, "strip", z.ZodTypeAny, {
16
- version: string;
16
+ _version: string;
17
17
  value: number;
18
18
  text: string;
19
19
  currencyCode: string;
@@ -21,7 +21,7 @@ export declare const AmountJSONSchema: z.ZodObject<{
21
21
  value: number;
22
22
  text: string;
23
23
  currencyCode: string;
24
- version?: string | undefined;
24
+ _version?: string | undefined;
25
25
  }>;
26
26
  /**
27
27
  * Compact JSON identity for an Amount, sufficient to reconstruct the value via
@@ -14,26 +14,26 @@ export declare const BankJSONSchema: z.ZodEffects<z.ZodObject<{
14
14
  swiftCode: z.ZodOptional<z.ZodString>;
15
15
  /** The ISO 3166-1 alpha-2 country code */
16
16
  countryCode: z.ZodString;
17
- /** Version for future compatibility */
18
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17
+ /** Model JSON schema version for future compatibility. */
18
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
19
19
  }, "strip", z.ZodTypeAny, {
20
- version: string;
20
+ _version: string;
21
21
  countryCode: string;
22
22
  bic?: string | undefined;
23
23
  swiftCode?: string | undefined;
24
24
  }, {
25
25
  countryCode: string;
26
- version?: string | undefined;
26
+ _version?: string | undefined;
27
27
  bic?: string | undefined;
28
28
  swiftCode?: string | undefined;
29
29
  }>, {
30
- version: string;
30
+ _version: string;
31
31
  countryCode: string;
32
32
  bic?: string | undefined;
33
33
  swiftCode?: string | undefined;
34
34
  }, {
35
35
  countryCode: string;
36
- version?: string | undefined;
36
+ _version?: string | undefined;
37
37
  bic?: string | undefined;
38
38
  swiftCode?: string | undefined;
39
39
  }>;
@@ -6,14 +6,14 @@ import { z } from "zod";
6
6
  export declare const CountryJSONSchema: z.ZodObject<{
7
7
  /** The ISO 3166-1 alpha-2 country code */
8
8
  code: z.ZodString;
9
- /** Version for future compatibility */
10
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
9
+ /** Model JSON schema version for future compatibility. */
10
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
11
11
  }, "strip", z.ZodTypeAny, {
12
12
  code: string;
13
- version: string;
13
+ _version: string;
14
14
  }, {
15
15
  code: string;
16
- version?: string | undefined;
16
+ _version?: string | undefined;
17
17
  }>;
18
18
  /**
19
19
  * Zod schema for validating ISO 3166-1 alpha-2 country codes.
@@ -62,12 +62,12 @@ export declare const ISO3CountryCodeSchema: z.ZodEffects<z.ZodString, string, st
62
62
  export declare const CountryCodeSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
63
63
  /** The ISO 3166-1 alpha-2 country code */
64
64
  code: z.ZodString;
65
- /** Version for future compatibility */
66
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
65
+ /** Model JSON schema version for future compatibility. */
66
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
67
67
  }, "strip", z.ZodTypeAny, {
68
68
  code: string;
69
- version: string;
69
+ _version: string;
70
70
  }, {
71
71
  code: string;
72
- version?: string | undefined;
72
+ _version?: string | undefined;
73
73
  }>]>;
@@ -13,12 +13,12 @@ export declare const CurrencyCodeSchema: z.ZodEffects<z.ZodString, string, strin
13
13
  export declare const CurrencyJSONSchema: z.ZodObject<{
14
14
  /** The ISO 4217 currency code */
15
15
  code: z.ZodString;
16
- /** Version for future compatibility */
17
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
16
+ /** Model JSON schema version for future compatibility. */
17
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
18
18
  }, "strip", z.ZodTypeAny, {
19
19
  code: string;
20
- version: string;
20
+ _version: string;
21
21
  }, {
22
22
  code: string;
23
- version?: string | undefined;
23
+ _version?: string | undefined;
24
24
  }>;
@@ -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: string;
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 { isPhonePrefix, isProviderId } from "./mobile-money-provider.types.js";
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 {};
@@ -5,9 +5,9 @@ export declare const MobileMoneyProviderJSONSchema: z.ZodObject<{
5
5
  countryCode: z.ZodString;
6
6
  channelType: z.ZodDefault<z.ZodLiteral<ChannelType.MOBILE_MONEY>>;
7
7
  direction: z.ZodOptional<z.ZodNativeEnum<typeof TransactionDirection>>;
8
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
9
9
  }, "strip", z.ZodTypeAny, {
10
- version: string;
10
+ _version: string;
11
11
  countryCode: string;
12
12
  id: string;
13
13
  channelType: ChannelType.MOBILE_MONEY;
@@ -15,7 +15,7 @@ export declare const MobileMoneyProviderJSONSchema: z.ZodObject<{
15
15
  }, {
16
16
  countryCode: string;
17
17
  id: string;
18
- version?: string | undefined;
18
+ _version?: string | undefined;
19
19
  channelType?: ChannelType.MOBILE_MONEY | undefined;
20
20
  direction?: TransactionDirection | undefined;
21
21
  }>;
@@ -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: string;
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
  */
@@ -10,12 +10,12 @@ import { z } from "zod";
10
10
  */
11
11
  export declare const PhoneNumberJSONSchema: z.ZodObject<{
12
12
  e164Format: z.ZodString;
13
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
14
  }, "strip", z.ZodTypeAny, {
15
- version: string;
15
+ _version: string;
16
16
  e164Format: string;
17
17
  }, {
18
18
  e164Format: string;
19
- version?: string | undefined;
19
+ _version?: string | undefined;
20
20
  }>;
21
21
  export type PhoneNumberJSON = z.infer<typeof PhoneNumberJSONSchema>;
@@ -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).