@mitumba/sdk 5.5.0 → 5.6.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.d.mts CHANGED
@@ -2019,6 +2019,64 @@ interface CheckoutStatusResponse {
2019
2019
  poll_after_ms: number;
2020
2020
  }
2021
2021
 
2022
+ /**
2023
+ * Platform markets: the countries Mitumba operates in (or plans to).
2024
+ *
2025
+ * The backend owns the registry and serves it at `GET /markets`. Clients read it at runtime and
2026
+ * never hardcode a country, a currency, a calling code or a region name.
2027
+ *
2028
+ * `code` is UPPERCASE ISO 3166-1 alpha-2 (`"KE"`). `slug` is the lowercase URL form (`"ke"`).
2029
+ */
2030
+ type MarketStatus = 'active' | 'coming_soon';
2031
+ interface MarketCurrency {
2032
+ /** ISO 4217 alpha-3, e.g. `"KES"`. */
2033
+ code: string;
2034
+ /** The currency's real exponent: 2 for KES, 0 for UGX. */
2035
+ minor_unit: number;
2036
+ symbol: string;
2037
+ /** A locale that formats this currency correctly, e.g. `"en-KE"`. */
2038
+ locale: string;
2039
+ }
2040
+ interface MarketPhone {
2041
+ /** With the plus, e.g. `"+254"`. */
2042
+ calling_code: string;
2043
+ /** Allowed digit counts after the calling code, without a trunk `0`. */
2044
+ national_length: number[];
2045
+ /** A valid example in E.164, for placeholders. */
2046
+ example: string;
2047
+ }
2048
+ interface Market {
2049
+ code: string;
2050
+ slug: string;
2051
+ name: string;
2052
+ /** Only `active` markets can transact. `coming_soon` markets are discoverable only. */
2053
+ status: MarketStatus;
2054
+ currency: MarketCurrency;
2055
+ locale: {
2056
+ /** BCP 47 tag, e.g. `"en-KE"`. */
2057
+ default: string;
2058
+ /** IANA zone, e.g. `"Africa/Nairobi"`. */
2059
+ timezone: string;
2060
+ };
2061
+ phone: MarketPhone;
2062
+ /** What the market calls its first-level administrative region, e.g. County / Counties. */
2063
+ regions: {
2064
+ label: string;
2065
+ plural: string;
2066
+ };
2067
+ /** Buyer-visible payment rails, never a provider name. */
2068
+ payments: {
2069
+ method_types: string[];
2070
+ };
2071
+ /** Fulfilment methods offered in this market. */
2072
+ fulfilment_methods: string[];
2073
+ }
2074
+ interface MarketsResponse {
2075
+ version: 1;
2076
+ markets: Market[];
2077
+ updated_at: string;
2078
+ }
2079
+
2022
2080
  interface VAZIOutfitItem {
2023
2081
  id: string;
2024
2082
  title: string;
@@ -4328,6 +4386,71 @@ declare class IamModule {
4328
4386
  }>;
4329
4387
  }
4330
4388
 
4389
+ declare class MarketsModule {
4390
+ private readonly client;
4391
+ constructor(client: APIClient);
4392
+ /**
4393
+ * List the platform's markets: the countries Mitumba operates in or plans to, with each
4394
+ * market's currency, locale, phone rules, region naming and payment rails.
4395
+ *
4396
+ * Public (no sign-in needed) and cacheable for a few minutes. Read this at runtime instead of
4397
+ * hardcoding a country, and pair it with the helpers exported from the package root
4398
+ * (`formatMoney`, `normalizePhone`, `findMarket`, ...).
4399
+ */
4400
+ list(options?: RequestOptions): Promise<MarketsResponse>;
4401
+ }
4402
+
4403
+ /**
4404
+ * Market-aware formatting and validation. Everything here is driven by a `Market` read from
4405
+ * `sdk.markets.list()`: no country, currency or calling code is hardcoded, so adding a market
4406
+ * needs no client change.
4407
+ *
4408
+ * Amounts are WHOLE major units (1850 means KES 1,850), exactly as the platform stores catalogue
4409
+ * and order prices. Phone numbers are stored in E.164.
4410
+ *
4411
+ * Pure and isomorphic: no network, no Node or browser APIs beyond `Intl.NumberFormat` for
4412
+ * digit grouping.
4413
+ */
4414
+ type CurrencyMarket = Pick<Market, 'currency'>;
4415
+ type PhoneMarket = Pick<Market, 'phone'>;
4416
+ /**
4417
+ * `1850` reads as `KES 1,850`. The currency code leads and a space follows it on purpose:
4418
+ * `KES1,850` misreads, and a symbol like `Ksh` is ambiguous across markets. A non-finite amount
4419
+ * renders as `KES —` rather than a believable-looking number.
4420
+ */
4421
+ declare function formatMoney(amount: number, market: CurrencyMarket): string;
4422
+ /** The number alone, for rows that already say what currency they are in. */
4423
+ declare function formatAmount(amount: number, market: CurrencyMarket): string;
4424
+ /**
4425
+ * For dashboard figures where the magnitude matters more than the exact amount: `13500` reads as
4426
+ * `KES 13.5K`, `2400000` as `KES 2.4M`. Below 10,000 it falls back to the full amount.
4427
+ */
4428
+ declare function formatMoneyCompact(amount: number, market: CurrencyMarket): string;
4429
+ /**
4430
+ * Turn what a person typed into E.164 for this market, or `null` if it cannot be a number here.
4431
+ * Accepts `0712 345 678`, `712345678`, `254712345678` and `+254 712-345-678`. A leading `+` is
4432
+ * taken literally: it must carry this market's calling code. Without one, a trunk `0`, then the
4433
+ * calling code, then a bare national number are tried in that order.
4434
+ */
4435
+ declare function normalizePhone(input: string, market: PhoneMarket): string | null;
4436
+ /** True when `input` can be normalized to a number in this market. */
4437
+ declare function isValidPhone(input: string, market: PhoneMarket): boolean;
4438
+ /**
4439
+ * Reads an E.164 number in groups of three: `+254712345678` becomes `+254 712 345 678`. Anything
4440
+ * that is not a stored number for this market is returned untouched, because a half-formatted
4441
+ * number is worse than a raw one.
4442
+ */
4443
+ declare function formatPhone(value: string, market: PhoneMarket): string;
4444
+ /**
4445
+ * Hides the middle of a number where it only needs to prove which number it is:
4446
+ * `+254712345678` becomes `+254 712 ••• 678`. Untouched if it is not a stored number here.
4447
+ */
4448
+ declare function maskPhone(value: string, market: PhoneMarket): string;
4449
+ /** Find a market by UPPERCASE ISO 3166-1 alpha-2 code in a list read from `sdk.markets.list()`. */
4450
+ declare function findMarket(markets: readonly Market[], code: string): Market | undefined;
4451
+ /** Markets that can transact. A `coming_soon` market is for discovery only. */
4452
+ declare function activeMarkets(markets: readonly Market[]): Market[];
4453
+
4331
4454
  /**
4332
4455
  * Canonical go.mitumba.africa share URLs — the one place clients build listing, store and bale share links.
4333
4456
  *
@@ -4374,6 +4497,7 @@ declare class MitumbaClient {
4374
4497
  readonly reports: ReportsModule;
4375
4498
  readonly wholesale: WholesaleModule;
4376
4499
  readonly iam: IamModule;
4500
+ readonly markets: MarketsModule;
4377
4501
  constructor(config: MitumbaClientConfig);
4378
4502
  /**
4379
4503
  * Set the access token for authenticated requests.
@@ -4405,4 +4529,4 @@ declare class MitumbaClient {
4405
4529
  isAuthenticated(): Promise<boolean>;
4406
4530
  }
4407
4531
 
4408
- export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isConsentRequired, isMessagingAPIError, listingShareUrl, storeShareUrl };
4532
+ export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, type Market, type MarketCurrency, type MarketPhone, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, createTokenStore, findMarket, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, storeShareUrl };
package/dist/index.d.ts CHANGED
@@ -2019,6 +2019,64 @@ interface CheckoutStatusResponse {
2019
2019
  poll_after_ms: number;
2020
2020
  }
2021
2021
 
2022
+ /**
2023
+ * Platform markets: the countries Mitumba operates in (or plans to).
2024
+ *
2025
+ * The backend owns the registry and serves it at `GET /markets`. Clients read it at runtime and
2026
+ * never hardcode a country, a currency, a calling code or a region name.
2027
+ *
2028
+ * `code` is UPPERCASE ISO 3166-1 alpha-2 (`"KE"`). `slug` is the lowercase URL form (`"ke"`).
2029
+ */
2030
+ type MarketStatus = 'active' | 'coming_soon';
2031
+ interface MarketCurrency {
2032
+ /** ISO 4217 alpha-3, e.g. `"KES"`. */
2033
+ code: string;
2034
+ /** The currency's real exponent: 2 for KES, 0 for UGX. */
2035
+ minor_unit: number;
2036
+ symbol: string;
2037
+ /** A locale that formats this currency correctly, e.g. `"en-KE"`. */
2038
+ locale: string;
2039
+ }
2040
+ interface MarketPhone {
2041
+ /** With the plus, e.g. `"+254"`. */
2042
+ calling_code: string;
2043
+ /** Allowed digit counts after the calling code, without a trunk `0`. */
2044
+ national_length: number[];
2045
+ /** A valid example in E.164, for placeholders. */
2046
+ example: string;
2047
+ }
2048
+ interface Market {
2049
+ code: string;
2050
+ slug: string;
2051
+ name: string;
2052
+ /** Only `active` markets can transact. `coming_soon` markets are discoverable only. */
2053
+ status: MarketStatus;
2054
+ currency: MarketCurrency;
2055
+ locale: {
2056
+ /** BCP 47 tag, e.g. `"en-KE"`. */
2057
+ default: string;
2058
+ /** IANA zone, e.g. `"Africa/Nairobi"`. */
2059
+ timezone: string;
2060
+ };
2061
+ phone: MarketPhone;
2062
+ /** What the market calls its first-level administrative region, e.g. County / Counties. */
2063
+ regions: {
2064
+ label: string;
2065
+ plural: string;
2066
+ };
2067
+ /** Buyer-visible payment rails, never a provider name. */
2068
+ payments: {
2069
+ method_types: string[];
2070
+ };
2071
+ /** Fulfilment methods offered in this market. */
2072
+ fulfilment_methods: string[];
2073
+ }
2074
+ interface MarketsResponse {
2075
+ version: 1;
2076
+ markets: Market[];
2077
+ updated_at: string;
2078
+ }
2079
+
2022
2080
  interface VAZIOutfitItem {
2023
2081
  id: string;
2024
2082
  title: string;
@@ -4328,6 +4386,71 @@ declare class IamModule {
4328
4386
  }>;
4329
4387
  }
4330
4388
 
4389
+ declare class MarketsModule {
4390
+ private readonly client;
4391
+ constructor(client: APIClient);
4392
+ /**
4393
+ * List the platform's markets: the countries Mitumba operates in or plans to, with each
4394
+ * market's currency, locale, phone rules, region naming and payment rails.
4395
+ *
4396
+ * Public (no sign-in needed) and cacheable for a few minutes. Read this at runtime instead of
4397
+ * hardcoding a country, and pair it with the helpers exported from the package root
4398
+ * (`formatMoney`, `normalizePhone`, `findMarket`, ...).
4399
+ */
4400
+ list(options?: RequestOptions): Promise<MarketsResponse>;
4401
+ }
4402
+
4403
+ /**
4404
+ * Market-aware formatting and validation. Everything here is driven by a `Market` read from
4405
+ * `sdk.markets.list()`: no country, currency or calling code is hardcoded, so adding a market
4406
+ * needs no client change.
4407
+ *
4408
+ * Amounts are WHOLE major units (1850 means KES 1,850), exactly as the platform stores catalogue
4409
+ * and order prices. Phone numbers are stored in E.164.
4410
+ *
4411
+ * Pure and isomorphic: no network, no Node or browser APIs beyond `Intl.NumberFormat` for
4412
+ * digit grouping.
4413
+ */
4414
+ type CurrencyMarket = Pick<Market, 'currency'>;
4415
+ type PhoneMarket = Pick<Market, 'phone'>;
4416
+ /**
4417
+ * `1850` reads as `KES 1,850`. The currency code leads and a space follows it on purpose:
4418
+ * `KES1,850` misreads, and a symbol like `Ksh` is ambiguous across markets. A non-finite amount
4419
+ * renders as `KES —` rather than a believable-looking number.
4420
+ */
4421
+ declare function formatMoney(amount: number, market: CurrencyMarket): string;
4422
+ /** The number alone, for rows that already say what currency they are in. */
4423
+ declare function formatAmount(amount: number, market: CurrencyMarket): string;
4424
+ /**
4425
+ * For dashboard figures where the magnitude matters more than the exact amount: `13500` reads as
4426
+ * `KES 13.5K`, `2400000` as `KES 2.4M`. Below 10,000 it falls back to the full amount.
4427
+ */
4428
+ declare function formatMoneyCompact(amount: number, market: CurrencyMarket): string;
4429
+ /**
4430
+ * Turn what a person typed into E.164 for this market, or `null` if it cannot be a number here.
4431
+ * Accepts `0712 345 678`, `712345678`, `254712345678` and `+254 712-345-678`. A leading `+` is
4432
+ * taken literally: it must carry this market's calling code. Without one, a trunk `0`, then the
4433
+ * calling code, then a bare national number are tried in that order.
4434
+ */
4435
+ declare function normalizePhone(input: string, market: PhoneMarket): string | null;
4436
+ /** True when `input` can be normalized to a number in this market. */
4437
+ declare function isValidPhone(input: string, market: PhoneMarket): boolean;
4438
+ /**
4439
+ * Reads an E.164 number in groups of three: `+254712345678` becomes `+254 712 345 678`. Anything
4440
+ * that is not a stored number for this market is returned untouched, because a half-formatted
4441
+ * number is worse than a raw one.
4442
+ */
4443
+ declare function formatPhone(value: string, market: PhoneMarket): string;
4444
+ /**
4445
+ * Hides the middle of a number where it only needs to prove which number it is:
4446
+ * `+254712345678` becomes `+254 712 ••• 678`. Untouched if it is not a stored number here.
4447
+ */
4448
+ declare function maskPhone(value: string, market: PhoneMarket): string;
4449
+ /** Find a market by UPPERCASE ISO 3166-1 alpha-2 code in a list read from `sdk.markets.list()`. */
4450
+ declare function findMarket(markets: readonly Market[], code: string): Market | undefined;
4451
+ /** Markets that can transact. A `coming_soon` market is for discovery only. */
4452
+ declare function activeMarkets(markets: readonly Market[]): Market[];
4453
+
4331
4454
  /**
4332
4455
  * Canonical go.mitumba.africa share URLs — the one place clients build listing, store and bale share links.
4333
4456
  *
@@ -4374,6 +4497,7 @@ declare class MitumbaClient {
4374
4497
  readonly reports: ReportsModule;
4375
4498
  readonly wholesale: WholesaleModule;
4376
4499
  readonly iam: IamModule;
4500
+ readonly markets: MarketsModule;
4377
4501
  constructor(config: MitumbaClientConfig);
4378
4502
  /**
4379
4503
  * Set the access token for authenticated requests.
@@ -4405,4 +4529,4 @@ declare class MitumbaClient {
4405
4529
  isAuthenticated(): Promise<boolean>;
4406
4530
  }
4407
4531
 
4408
- export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isConsentRequired, isMessagingAPIError, listingShareUrl, storeShareUrl };
4532
+ export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, type Market, type MarketCurrency, type MarketPhone, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, createTokenStore, findMarket, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, storeShareUrl };
package/dist/index.js CHANGED
@@ -2742,6 +2742,25 @@ var IamModule = class {
2742
2742
  }
2743
2743
  };
2744
2744
 
2745
+ // src/modules/markets.ts
2746
+ var MarketsModule = class {
2747
+ constructor(client) {
2748
+ this.client = client;
2749
+ }
2750
+ client;
2751
+ /**
2752
+ * List the platform's markets: the countries Mitumba operates in or plans to, with each
2753
+ * market's currency, locale, phone rules, region naming and payment rails.
2754
+ *
2755
+ * Public (no sign-in needed) and cacheable for a few minutes. Read this at runtime instead of
2756
+ * hardcoding a country, and pair it with the helpers exported from the package root
2757
+ * (`formatMoney`, `normalizePhone`, `findMarket`, ...).
2758
+ */
2759
+ async list(options) {
2760
+ return this.client.get("/markets", void 0, options);
2761
+ }
2762
+ };
2763
+
2745
2764
  // src/types/auth.ts
2746
2765
  var TWO_FACTOR_METHOD_TYPES = ["totp", "sms", "email", "passkey"];
2747
2766
 
@@ -2773,6 +2792,103 @@ var DISPUTE_STATUSES = ["open", "seller_responded", "under_review", "resolved_re
2773
2792
  // src/types/wholesale.ts
2774
2793
  var BALE_ORDER_STATUSES = ["pending_payment", "paid", "confirmed", "in_transit", "delivered", "completed", "cancelled"];
2775
2794
 
2795
+ // src/markets.ts
2796
+ var GAP = " ";
2797
+ function group(value, locale) {
2798
+ const rounded = Math.round(Math.abs(value));
2799
+ try {
2800
+ return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(rounded);
2801
+ } catch {
2802
+ return String(rounded).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2803
+ }
2804
+ }
2805
+ function formatMoney(amount, market) {
2806
+ const { code, locale } = market.currency;
2807
+ if (!Number.isFinite(amount)) return `${code}${GAP}\u2014`;
2808
+ return `${amount < 0 ? "-" : ""}${code}${GAP}${group(amount, locale)}`;
2809
+ }
2810
+ function formatAmount(amount, market) {
2811
+ if (!Number.isFinite(amount)) return "\u2014";
2812
+ return `${amount < 0 ? "-" : ""}${group(amount, market.currency.locale)}`;
2813
+ }
2814
+ function formatMoneyCompact(amount, market) {
2815
+ const absolute = Math.abs(amount);
2816
+ if (!Number.isFinite(amount) || absolute < 1e4) return formatMoney(amount, market);
2817
+ const { code } = market.currency;
2818
+ const sign = amount < 0 ? "-" : "";
2819
+ const trim = (n) => n.toFixed(1).replace(/\.0$/, "");
2820
+ if (absolute < 1e6) {
2821
+ const thousands = absolute / 1e3;
2822
+ if (Math.round(thousands) < 1e3) {
2823
+ return `${sign}${code}${GAP}${thousands < 100 ? trim(thousands) : String(Math.round(thousands))}K`;
2824
+ }
2825
+ }
2826
+ return `${sign}${code}${GAP}${trim(absolute / 1e6)}M`;
2827
+ }
2828
+ function digitsOnly(value) {
2829
+ return value.replace(/\D/g, "");
2830
+ }
2831
+ function normalizePhone(input, market) {
2832
+ const { calling_code, national_length } = market.phone;
2833
+ const callingDigits = digitsOnly(calling_code);
2834
+ const trimmed = input.trim();
2835
+ const digits = digitsOnly(trimmed);
2836
+ if (digits.length === 0) return null;
2837
+ const fits = (national) => national_length.includes(national.length) && !national.startsWith("0");
2838
+ const afterCallingCode = (rest) => {
2839
+ if (fits(rest)) return rest;
2840
+ if (rest.startsWith("0") && fits(rest.slice(1))) return rest.slice(1);
2841
+ return null;
2842
+ };
2843
+ if (trimmed.startsWith("+")) {
2844
+ if (!digits.startsWith(callingDigits)) return null;
2845
+ const national = afterCallingCode(digits.slice(callingDigits.length));
2846
+ return national === null ? null : `+${callingDigits}${national}`;
2847
+ }
2848
+ if (digits.startsWith("0") && fits(digits.slice(1))) return `+${callingDigits}${digits.slice(1)}`;
2849
+ if (digits.startsWith(callingDigits)) {
2850
+ const national = afterCallingCode(digits.slice(callingDigits.length));
2851
+ if (national !== null) return `+${callingDigits}${national}`;
2852
+ }
2853
+ if (fits(digits)) return `+${callingDigits}${digits}`;
2854
+ return null;
2855
+ }
2856
+ function isValidPhone(input, market) {
2857
+ return normalizePhone(input, market) !== null;
2858
+ }
2859
+ function splitNational(e164, market) {
2860
+ const calling = market.phone.calling_code;
2861
+ if (!e164.startsWith(calling)) return null;
2862
+ const national = e164.slice(calling.length);
2863
+ if (!/^\d+$/.test(national) || !market.phone.national_length.includes(national.length)) return null;
2864
+ return { calling, national };
2865
+ }
2866
+ function formatPhone(value, market) {
2867
+ const compact = value.replace(/[^\d+]/g, "");
2868
+ const parts = splitNational(compact, market);
2869
+ if (!parts) return value;
2870
+ const groups = parts.national.match(/\d{1,3}/g) ?? [];
2871
+ if (groups.length > 1 && groups[groups.length - 1].length === 1) {
2872
+ const last = groups.pop();
2873
+ groups[groups.length - 1] += last;
2874
+ }
2875
+ return `${parts.calling}${GAP}${groups.join(GAP)}`;
2876
+ }
2877
+ function maskPhone(value, market) {
2878
+ const compact = value.replace(/[^\d+]/g, "");
2879
+ const parts = splitNational(compact, market);
2880
+ if (!parts || parts.national.length < 7) return value;
2881
+ const head = parts.national.slice(0, 3);
2882
+ const tail = parts.national.slice(-3);
2883
+ return `${parts.calling}${GAP}${head}${GAP}\u2022\u2022\u2022${GAP}${tail}`;
2884
+ }
2885
+ function findMarket(markets, code) {
2886
+ return markets.find((market) => market.code === code);
2887
+ }
2888
+ function activeMarkets(markets) {
2889
+ return markets.filter((market) => market.status === "active");
2890
+ }
2891
+
2776
2892
  // src/share.ts
2777
2893
  var DEFAULT_SHARE_ORIGIN = "https://go.mitumba.africa";
2778
2894
  var ID_PATTERN = /^[0-9a-f]{32}$/;
@@ -2836,6 +2952,7 @@ var MitumbaClient = class {
2836
2952
  reports;
2837
2953
  wholesale;
2838
2954
  iam;
2955
+ markets;
2839
2956
  constructor(config) {
2840
2957
  this.api = new APIClient(config);
2841
2958
  this.auth = new AuthModule(this.api);
@@ -2860,6 +2977,7 @@ var MitumbaClient = class {
2860
2977
  this.reports = new ReportsModule(this.api);
2861
2978
  this.wholesale = new WholesaleModule(this.api);
2862
2979
  this.iam = new IamModule(this.api);
2980
+ this.markets = new MarketsModule(this.api);
2863
2981
  }
2864
2982
  /**
2865
2983
  * Set the access token for authenticated requests.
@@ -2918,6 +3036,7 @@ exports.IamModule = IamModule;
2918
3036
  exports.LISTING_STATUSES = LISTING_STATUSES;
2919
3037
  exports.ListingsModule = ListingsModule;
2920
3038
  exports.MailerModule = MailerModule;
3039
+ exports.MarketsModule = MarketsModule;
2921
3040
  exports.MemoryTokenStore = MemoryTokenStore;
2922
3041
  exports.MessagesModule = MessagesModule;
2923
3042
  exports.MitumbaClient = MitumbaClient;
@@ -2939,11 +3058,20 @@ exports.UploadsModule = UploadsModule;
2939
3058
  exports.VaziModule = VaziModule;
2940
3059
  exports.WholesaleModule = WholesaleModule;
2941
3060
  exports.WishlistsModule = WishlistsModule;
3061
+ exports.activeMarkets = activeMarkets;
2942
3062
  exports.baleShareUrl = baleShareUrl;
2943
3063
  exports.createTokenStore = createTokenStore;
3064
+ exports.findMarket = findMarket;
3065
+ exports.formatAmount = formatAmount;
3066
+ exports.formatMoney = formatMoney;
3067
+ exports.formatMoneyCompact = formatMoneyCompact;
3068
+ exports.formatPhone = formatPhone;
2944
3069
  exports.isConsentRequired = isConsentRequired;
2945
3070
  exports.isMessagingAPIError = isMessagingAPIError;
3071
+ exports.isValidPhone = isValidPhone;
2946
3072
  exports.listingShareUrl = listingShareUrl;
3073
+ exports.maskPhone = maskPhone;
3074
+ exports.normalizePhone = normalizePhone;
2947
3075
  exports.storeShareUrl = storeShareUrl;
2948
3076
  //# sourceMappingURL=index.js.map
2949
3077
  //# sourceMappingURL=index.js.map