@mitumba/sdk 5.5.0 → 5.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/dist/index.d.mts +141 -1
- package/dist/index.d.ts +141 -1
- package/dist/index.js +142 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -2629,6 +2687,10 @@ interface VerifyIamMethodResult {
|
|
|
2629
2687
|
ok: true;
|
|
2630
2688
|
backup_codes?: string[];
|
|
2631
2689
|
}
|
|
2690
|
+
/** A fresh set of IAM recovery codes, shown once. */
|
|
2691
|
+
interface RegenerateIamBackupCodesResult {
|
|
2692
|
+
backup_codes: string[];
|
|
2693
|
+
}
|
|
2632
2694
|
/** Create an organization. */
|
|
2633
2695
|
interface CreateOrganizationInput {
|
|
2634
2696
|
alias: string;
|
|
@@ -4289,6 +4351,18 @@ declare class IamModule {
|
|
|
4289
4351
|
verifyMethod(methodId: string, code: string, options?: RequestOptions): Promise<VerifyIamMethodResult>;
|
|
4290
4352
|
/** Finish and enable a pending IAM passkey method. */
|
|
4291
4353
|
finishPasskeyEnrollment(methodId: string, credential: FinishIamPasskeyEnrollmentInput, options?: RequestOptions): Promise<VerifyIamMethodResult>;
|
|
4354
|
+
/**
|
|
4355
|
+
* Replace this IAM principal's recovery codes after re-proving the password. The previous set
|
|
4356
|
+
* stops working immediately; the returned codes are shown once and never retrievable again.
|
|
4357
|
+
*/
|
|
4358
|
+
regenerateBackupCodes(password: string, options?: RequestOptions): Promise<RegenerateIamBackupCodesResult>;
|
|
4359
|
+
/**
|
|
4360
|
+
* Remove one of this principal's own second-factor methods after re-proving the password.
|
|
4361
|
+
* Refused with `last_factor` (409) when it is the only verified factor left.
|
|
4362
|
+
*/
|
|
4363
|
+
deleteMethod(methodId: string, password: string, options?: RequestOptions): Promise<{
|
|
4364
|
+
ok: true;
|
|
4365
|
+
}>;
|
|
4292
4366
|
/** List organizations the current root/global operator may administer. */
|
|
4293
4367
|
listOrganizations(options?: RequestOptions): Promise<{
|
|
4294
4368
|
organizations: OrganizationSummary[];
|
|
@@ -4328,6 +4402,71 @@ declare class IamModule {
|
|
|
4328
4402
|
}>;
|
|
4329
4403
|
}
|
|
4330
4404
|
|
|
4405
|
+
declare class MarketsModule {
|
|
4406
|
+
private readonly client;
|
|
4407
|
+
constructor(client: APIClient);
|
|
4408
|
+
/**
|
|
4409
|
+
* List the platform's markets: the countries Mitumba operates in or plans to, with each
|
|
4410
|
+
* market's currency, locale, phone rules, region naming and payment rails.
|
|
4411
|
+
*
|
|
4412
|
+
* Public (no sign-in needed) and cacheable for a few minutes. Read this at runtime instead of
|
|
4413
|
+
* hardcoding a country, and pair it with the helpers exported from the package root
|
|
4414
|
+
* (`formatMoney`, `normalizePhone`, `findMarket`, ...).
|
|
4415
|
+
*/
|
|
4416
|
+
list(options?: RequestOptions): Promise<MarketsResponse>;
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
/**
|
|
4420
|
+
* Market-aware formatting and validation. Everything here is driven by a `Market` read from
|
|
4421
|
+
* `sdk.markets.list()`: no country, currency or calling code is hardcoded, so adding a market
|
|
4422
|
+
* needs no client change.
|
|
4423
|
+
*
|
|
4424
|
+
* Amounts are WHOLE major units (1850 means KES 1,850), exactly as the platform stores catalogue
|
|
4425
|
+
* and order prices. Phone numbers are stored in E.164.
|
|
4426
|
+
*
|
|
4427
|
+
* Pure and isomorphic: no network, no Node or browser APIs beyond `Intl.NumberFormat` for
|
|
4428
|
+
* digit grouping.
|
|
4429
|
+
*/
|
|
4430
|
+
type CurrencyMarket = Pick<Market, 'currency'>;
|
|
4431
|
+
type PhoneMarket = Pick<Market, 'phone'>;
|
|
4432
|
+
/**
|
|
4433
|
+
* `1850` reads as `KES 1,850`. The currency code leads and a space follows it on purpose:
|
|
4434
|
+
* `KES1,850` misreads, and a symbol like `Ksh` is ambiguous across markets. A non-finite amount
|
|
4435
|
+
* renders as `KES —` rather than a believable-looking number.
|
|
4436
|
+
*/
|
|
4437
|
+
declare function formatMoney(amount: number, market: CurrencyMarket): string;
|
|
4438
|
+
/** The number alone, for rows that already say what currency they are in. */
|
|
4439
|
+
declare function formatAmount(amount: number, market: CurrencyMarket): string;
|
|
4440
|
+
/**
|
|
4441
|
+
* For dashboard figures where the magnitude matters more than the exact amount: `13500` reads as
|
|
4442
|
+
* `KES 13.5K`, `2400000` as `KES 2.4M`. Below 10,000 it falls back to the full amount.
|
|
4443
|
+
*/
|
|
4444
|
+
declare function formatMoneyCompact(amount: number, market: CurrencyMarket): string;
|
|
4445
|
+
/**
|
|
4446
|
+
* Turn what a person typed into E.164 for this market, or `null` if it cannot be a number here.
|
|
4447
|
+
* Accepts `0712 345 678`, `712345678`, `254712345678` and `+254 712-345-678`. A leading `+` is
|
|
4448
|
+
* taken literally: it must carry this market's calling code. Without one, a trunk `0`, then the
|
|
4449
|
+
* calling code, then a bare national number are tried in that order.
|
|
4450
|
+
*/
|
|
4451
|
+
declare function normalizePhone(input: string, market: PhoneMarket): string | null;
|
|
4452
|
+
/** True when `input` can be normalized to a number in this market. */
|
|
4453
|
+
declare function isValidPhone(input: string, market: PhoneMarket): boolean;
|
|
4454
|
+
/**
|
|
4455
|
+
* Reads an E.164 number in groups of three: `+254712345678` becomes `+254 712 345 678`. Anything
|
|
4456
|
+
* that is not a stored number for this market is returned untouched, because a half-formatted
|
|
4457
|
+
* number is worse than a raw one.
|
|
4458
|
+
*/
|
|
4459
|
+
declare function formatPhone(value: string, market: PhoneMarket): string;
|
|
4460
|
+
/**
|
|
4461
|
+
* Hides the middle of a number where it only needs to prove which number it is:
|
|
4462
|
+
* `+254712345678` becomes `+254 712 ••• 678`. Untouched if it is not a stored number here.
|
|
4463
|
+
*/
|
|
4464
|
+
declare function maskPhone(value: string, market: PhoneMarket): string;
|
|
4465
|
+
/** Find a market by UPPERCASE ISO 3166-1 alpha-2 code in a list read from `sdk.markets.list()`. */
|
|
4466
|
+
declare function findMarket(markets: readonly Market[], code: string): Market | undefined;
|
|
4467
|
+
/** Markets that can transact. A `coming_soon` market is for discovery only. */
|
|
4468
|
+
declare function activeMarkets(markets: readonly Market[]): Market[];
|
|
4469
|
+
|
|
4331
4470
|
/**
|
|
4332
4471
|
* Canonical go.mitumba.africa share URLs — the one place clients build listing, store and bale share links.
|
|
4333
4472
|
*
|
|
@@ -4374,6 +4513,7 @@ declare class MitumbaClient {
|
|
|
4374
4513
|
readonly reports: ReportsModule;
|
|
4375
4514
|
readonly wholesale: WholesaleModule;
|
|
4376
4515
|
readonly iam: IamModule;
|
|
4516
|
+
readonly markets: MarketsModule;
|
|
4377
4517
|
constructor(config: MitumbaClientConfig);
|
|
4378
4518
|
/**
|
|
4379
4519
|
* Set the access token for authenticated requests.
|
|
@@ -4405,4 +4545,4 @@ declare class MitumbaClient {
|
|
|
4405
4545
|
isAuthenticated(): Promise<boolean>;
|
|
4406
4546
|
}
|
|
4407
4547
|
|
|
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 };
|
|
4548
|
+
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 RegenerateIamBackupCodesResult, 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;
|
|
@@ -2629,6 +2687,10 @@ interface VerifyIamMethodResult {
|
|
|
2629
2687
|
ok: true;
|
|
2630
2688
|
backup_codes?: string[];
|
|
2631
2689
|
}
|
|
2690
|
+
/** A fresh set of IAM recovery codes, shown once. */
|
|
2691
|
+
interface RegenerateIamBackupCodesResult {
|
|
2692
|
+
backup_codes: string[];
|
|
2693
|
+
}
|
|
2632
2694
|
/** Create an organization. */
|
|
2633
2695
|
interface CreateOrganizationInput {
|
|
2634
2696
|
alias: string;
|
|
@@ -4289,6 +4351,18 @@ declare class IamModule {
|
|
|
4289
4351
|
verifyMethod(methodId: string, code: string, options?: RequestOptions): Promise<VerifyIamMethodResult>;
|
|
4290
4352
|
/** Finish and enable a pending IAM passkey method. */
|
|
4291
4353
|
finishPasskeyEnrollment(methodId: string, credential: FinishIamPasskeyEnrollmentInput, options?: RequestOptions): Promise<VerifyIamMethodResult>;
|
|
4354
|
+
/**
|
|
4355
|
+
* Replace this IAM principal's recovery codes after re-proving the password. The previous set
|
|
4356
|
+
* stops working immediately; the returned codes are shown once and never retrievable again.
|
|
4357
|
+
*/
|
|
4358
|
+
regenerateBackupCodes(password: string, options?: RequestOptions): Promise<RegenerateIamBackupCodesResult>;
|
|
4359
|
+
/**
|
|
4360
|
+
* Remove one of this principal's own second-factor methods after re-proving the password.
|
|
4361
|
+
* Refused with `last_factor` (409) when it is the only verified factor left.
|
|
4362
|
+
*/
|
|
4363
|
+
deleteMethod(methodId: string, password: string, options?: RequestOptions): Promise<{
|
|
4364
|
+
ok: true;
|
|
4365
|
+
}>;
|
|
4292
4366
|
/** List organizations the current root/global operator may administer. */
|
|
4293
4367
|
listOrganizations(options?: RequestOptions): Promise<{
|
|
4294
4368
|
organizations: OrganizationSummary[];
|
|
@@ -4328,6 +4402,71 @@ declare class IamModule {
|
|
|
4328
4402
|
}>;
|
|
4329
4403
|
}
|
|
4330
4404
|
|
|
4405
|
+
declare class MarketsModule {
|
|
4406
|
+
private readonly client;
|
|
4407
|
+
constructor(client: APIClient);
|
|
4408
|
+
/**
|
|
4409
|
+
* List the platform's markets: the countries Mitumba operates in or plans to, with each
|
|
4410
|
+
* market's currency, locale, phone rules, region naming and payment rails.
|
|
4411
|
+
*
|
|
4412
|
+
* Public (no sign-in needed) and cacheable for a few minutes. Read this at runtime instead of
|
|
4413
|
+
* hardcoding a country, and pair it with the helpers exported from the package root
|
|
4414
|
+
* (`formatMoney`, `normalizePhone`, `findMarket`, ...).
|
|
4415
|
+
*/
|
|
4416
|
+
list(options?: RequestOptions): Promise<MarketsResponse>;
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
/**
|
|
4420
|
+
* Market-aware formatting and validation. Everything here is driven by a `Market` read from
|
|
4421
|
+
* `sdk.markets.list()`: no country, currency or calling code is hardcoded, so adding a market
|
|
4422
|
+
* needs no client change.
|
|
4423
|
+
*
|
|
4424
|
+
* Amounts are WHOLE major units (1850 means KES 1,850), exactly as the platform stores catalogue
|
|
4425
|
+
* and order prices. Phone numbers are stored in E.164.
|
|
4426
|
+
*
|
|
4427
|
+
* Pure and isomorphic: no network, no Node or browser APIs beyond `Intl.NumberFormat` for
|
|
4428
|
+
* digit grouping.
|
|
4429
|
+
*/
|
|
4430
|
+
type CurrencyMarket = Pick<Market, 'currency'>;
|
|
4431
|
+
type PhoneMarket = Pick<Market, 'phone'>;
|
|
4432
|
+
/**
|
|
4433
|
+
* `1850` reads as `KES 1,850`. The currency code leads and a space follows it on purpose:
|
|
4434
|
+
* `KES1,850` misreads, and a symbol like `Ksh` is ambiguous across markets. A non-finite amount
|
|
4435
|
+
* renders as `KES —` rather than a believable-looking number.
|
|
4436
|
+
*/
|
|
4437
|
+
declare function formatMoney(amount: number, market: CurrencyMarket): string;
|
|
4438
|
+
/** The number alone, for rows that already say what currency they are in. */
|
|
4439
|
+
declare function formatAmount(amount: number, market: CurrencyMarket): string;
|
|
4440
|
+
/**
|
|
4441
|
+
* For dashboard figures where the magnitude matters more than the exact amount: `13500` reads as
|
|
4442
|
+
* `KES 13.5K`, `2400000` as `KES 2.4M`. Below 10,000 it falls back to the full amount.
|
|
4443
|
+
*/
|
|
4444
|
+
declare function formatMoneyCompact(amount: number, market: CurrencyMarket): string;
|
|
4445
|
+
/**
|
|
4446
|
+
* Turn what a person typed into E.164 for this market, or `null` if it cannot be a number here.
|
|
4447
|
+
* Accepts `0712 345 678`, `712345678`, `254712345678` and `+254 712-345-678`. A leading `+` is
|
|
4448
|
+
* taken literally: it must carry this market's calling code. Without one, a trunk `0`, then the
|
|
4449
|
+
* calling code, then a bare national number are tried in that order.
|
|
4450
|
+
*/
|
|
4451
|
+
declare function normalizePhone(input: string, market: PhoneMarket): string | null;
|
|
4452
|
+
/** True when `input` can be normalized to a number in this market. */
|
|
4453
|
+
declare function isValidPhone(input: string, market: PhoneMarket): boolean;
|
|
4454
|
+
/**
|
|
4455
|
+
* Reads an E.164 number in groups of three: `+254712345678` becomes `+254 712 345 678`. Anything
|
|
4456
|
+
* that is not a stored number for this market is returned untouched, because a half-formatted
|
|
4457
|
+
* number is worse than a raw one.
|
|
4458
|
+
*/
|
|
4459
|
+
declare function formatPhone(value: string, market: PhoneMarket): string;
|
|
4460
|
+
/**
|
|
4461
|
+
* Hides the middle of a number where it only needs to prove which number it is:
|
|
4462
|
+
* `+254712345678` becomes `+254 712 ••• 678`. Untouched if it is not a stored number here.
|
|
4463
|
+
*/
|
|
4464
|
+
declare function maskPhone(value: string, market: PhoneMarket): string;
|
|
4465
|
+
/** Find a market by UPPERCASE ISO 3166-1 alpha-2 code in a list read from `sdk.markets.list()`. */
|
|
4466
|
+
declare function findMarket(markets: readonly Market[], code: string): Market | undefined;
|
|
4467
|
+
/** Markets that can transact. A `coming_soon` market is for discovery only. */
|
|
4468
|
+
declare function activeMarkets(markets: readonly Market[]): Market[];
|
|
4469
|
+
|
|
4331
4470
|
/**
|
|
4332
4471
|
* Canonical go.mitumba.africa share URLs — the one place clients build listing, store and bale share links.
|
|
4333
4472
|
*
|
|
@@ -4374,6 +4513,7 @@ declare class MitumbaClient {
|
|
|
4374
4513
|
readonly reports: ReportsModule;
|
|
4375
4514
|
readonly wholesale: WholesaleModule;
|
|
4376
4515
|
readonly iam: IamModule;
|
|
4516
|
+
readonly markets: MarketsModule;
|
|
4377
4517
|
constructor(config: MitumbaClientConfig);
|
|
4378
4518
|
/**
|
|
4379
4519
|
* Set the access token for authenticated requests.
|
|
@@ -4405,4 +4545,4 @@ declare class MitumbaClient {
|
|
|
4405
4545
|
isAuthenticated(): Promise<boolean>;
|
|
4406
4546
|
}
|
|
4407
4547
|
|
|
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 };
|
|
4548
|
+
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 RegenerateIamBackupCodesResult, 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
|
@@ -2688,6 +2688,20 @@ var IamModule = class {
|
|
|
2688
2688
|
async finishPasskeyEnrollment(methodId, credential, options) {
|
|
2689
2689
|
return this.client.post(`/auth/iam/2fa/methods/${encodeURIComponent(methodId)}/passkey/finish`, credential, options);
|
|
2690
2690
|
}
|
|
2691
|
+
/**
|
|
2692
|
+
* Replace this IAM principal's recovery codes after re-proving the password. The previous set
|
|
2693
|
+
* stops working immediately; the returned codes are shown once and never retrievable again.
|
|
2694
|
+
*/
|
|
2695
|
+
async regenerateBackupCodes(password, options) {
|
|
2696
|
+
return this.client.post("/auth/iam/2fa/backup-codes/regenerate", { password }, options);
|
|
2697
|
+
}
|
|
2698
|
+
/**
|
|
2699
|
+
* Remove one of this principal's own second-factor methods after re-proving the password.
|
|
2700
|
+
* Refused with `last_factor` (409) when it is the only verified factor left.
|
|
2701
|
+
*/
|
|
2702
|
+
async deleteMethod(methodId, password, options) {
|
|
2703
|
+
return this.client.delete(`/auth/iam/2fa/methods/${encodeURIComponent(methodId)}`, { password }, options);
|
|
2704
|
+
}
|
|
2691
2705
|
/** List organizations the current root/global operator may administer. */
|
|
2692
2706
|
async listOrganizations(options) {
|
|
2693
2707
|
return this.client.get("/auth/orgs", void 0, options);
|
|
@@ -2742,6 +2756,25 @@ var IamModule = class {
|
|
|
2742
2756
|
}
|
|
2743
2757
|
};
|
|
2744
2758
|
|
|
2759
|
+
// src/modules/markets.ts
|
|
2760
|
+
var MarketsModule = class {
|
|
2761
|
+
constructor(client) {
|
|
2762
|
+
this.client = client;
|
|
2763
|
+
}
|
|
2764
|
+
client;
|
|
2765
|
+
/**
|
|
2766
|
+
* List the platform's markets: the countries Mitumba operates in or plans to, with each
|
|
2767
|
+
* market's currency, locale, phone rules, region naming and payment rails.
|
|
2768
|
+
*
|
|
2769
|
+
* Public (no sign-in needed) and cacheable for a few minutes. Read this at runtime instead of
|
|
2770
|
+
* hardcoding a country, and pair it with the helpers exported from the package root
|
|
2771
|
+
* (`formatMoney`, `normalizePhone`, `findMarket`, ...).
|
|
2772
|
+
*/
|
|
2773
|
+
async list(options) {
|
|
2774
|
+
return this.client.get("/markets", void 0, options);
|
|
2775
|
+
}
|
|
2776
|
+
};
|
|
2777
|
+
|
|
2745
2778
|
// src/types/auth.ts
|
|
2746
2779
|
var TWO_FACTOR_METHOD_TYPES = ["totp", "sms", "email", "passkey"];
|
|
2747
2780
|
|
|
@@ -2773,6 +2806,103 @@ var DISPUTE_STATUSES = ["open", "seller_responded", "under_review", "resolved_re
|
|
|
2773
2806
|
// src/types/wholesale.ts
|
|
2774
2807
|
var BALE_ORDER_STATUSES = ["pending_payment", "paid", "confirmed", "in_transit", "delivered", "completed", "cancelled"];
|
|
2775
2808
|
|
|
2809
|
+
// src/markets.ts
|
|
2810
|
+
var GAP = " ";
|
|
2811
|
+
function group(value, locale) {
|
|
2812
|
+
const rounded = Math.round(Math.abs(value));
|
|
2813
|
+
try {
|
|
2814
|
+
return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(rounded);
|
|
2815
|
+
} catch {
|
|
2816
|
+
return String(rounded).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
function formatMoney(amount, market) {
|
|
2820
|
+
const { code, locale } = market.currency;
|
|
2821
|
+
if (!Number.isFinite(amount)) return `${code}${GAP}\u2014`;
|
|
2822
|
+
return `${amount < 0 ? "-" : ""}${code}${GAP}${group(amount, locale)}`;
|
|
2823
|
+
}
|
|
2824
|
+
function formatAmount(amount, market) {
|
|
2825
|
+
if (!Number.isFinite(amount)) return "\u2014";
|
|
2826
|
+
return `${amount < 0 ? "-" : ""}${group(amount, market.currency.locale)}`;
|
|
2827
|
+
}
|
|
2828
|
+
function formatMoneyCompact(amount, market) {
|
|
2829
|
+
const absolute = Math.abs(amount);
|
|
2830
|
+
if (!Number.isFinite(amount) || absolute < 1e4) return formatMoney(amount, market);
|
|
2831
|
+
const { code } = market.currency;
|
|
2832
|
+
const sign = amount < 0 ? "-" : "";
|
|
2833
|
+
const trim = (n) => n.toFixed(1).replace(/\.0$/, "");
|
|
2834
|
+
if (absolute < 1e6) {
|
|
2835
|
+
const thousands = absolute / 1e3;
|
|
2836
|
+
if (Math.round(thousands) < 1e3) {
|
|
2837
|
+
return `${sign}${code}${GAP}${thousands < 100 ? trim(thousands) : String(Math.round(thousands))}K`;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
return `${sign}${code}${GAP}${trim(absolute / 1e6)}M`;
|
|
2841
|
+
}
|
|
2842
|
+
function digitsOnly(value) {
|
|
2843
|
+
return value.replace(/\D/g, "");
|
|
2844
|
+
}
|
|
2845
|
+
function normalizePhone(input, market) {
|
|
2846
|
+
const { calling_code, national_length } = market.phone;
|
|
2847
|
+
const callingDigits = digitsOnly(calling_code);
|
|
2848
|
+
const trimmed = input.trim();
|
|
2849
|
+
const digits = digitsOnly(trimmed);
|
|
2850
|
+
if (digits.length === 0) return null;
|
|
2851
|
+
const fits = (national) => national_length.includes(national.length) && !national.startsWith("0");
|
|
2852
|
+
const afterCallingCode = (rest) => {
|
|
2853
|
+
if (fits(rest)) return rest;
|
|
2854
|
+
if (rest.startsWith("0") && fits(rest.slice(1))) return rest.slice(1);
|
|
2855
|
+
return null;
|
|
2856
|
+
};
|
|
2857
|
+
if (trimmed.startsWith("+")) {
|
|
2858
|
+
if (!digits.startsWith(callingDigits)) return null;
|
|
2859
|
+
const national = afterCallingCode(digits.slice(callingDigits.length));
|
|
2860
|
+
return national === null ? null : `+${callingDigits}${national}`;
|
|
2861
|
+
}
|
|
2862
|
+
if (digits.startsWith("0") && fits(digits.slice(1))) return `+${callingDigits}${digits.slice(1)}`;
|
|
2863
|
+
if (digits.startsWith(callingDigits)) {
|
|
2864
|
+
const national = afterCallingCode(digits.slice(callingDigits.length));
|
|
2865
|
+
if (national !== null) return `+${callingDigits}${national}`;
|
|
2866
|
+
}
|
|
2867
|
+
if (fits(digits)) return `+${callingDigits}${digits}`;
|
|
2868
|
+
return null;
|
|
2869
|
+
}
|
|
2870
|
+
function isValidPhone(input, market) {
|
|
2871
|
+
return normalizePhone(input, market) !== null;
|
|
2872
|
+
}
|
|
2873
|
+
function splitNational(e164, market) {
|
|
2874
|
+
const calling = market.phone.calling_code;
|
|
2875
|
+
if (!e164.startsWith(calling)) return null;
|
|
2876
|
+
const national = e164.slice(calling.length);
|
|
2877
|
+
if (!/^\d+$/.test(national) || !market.phone.national_length.includes(national.length)) return null;
|
|
2878
|
+
return { calling, national };
|
|
2879
|
+
}
|
|
2880
|
+
function formatPhone(value, market) {
|
|
2881
|
+
const compact = value.replace(/[^\d+]/g, "");
|
|
2882
|
+
const parts = splitNational(compact, market);
|
|
2883
|
+
if (!parts) return value;
|
|
2884
|
+
const groups = parts.national.match(/\d{1,3}/g) ?? [];
|
|
2885
|
+
if (groups.length > 1 && groups[groups.length - 1].length === 1) {
|
|
2886
|
+
const last = groups.pop();
|
|
2887
|
+
groups[groups.length - 1] += last;
|
|
2888
|
+
}
|
|
2889
|
+
return `${parts.calling}${GAP}${groups.join(GAP)}`;
|
|
2890
|
+
}
|
|
2891
|
+
function maskPhone(value, market) {
|
|
2892
|
+
const compact = value.replace(/[^\d+]/g, "");
|
|
2893
|
+
const parts = splitNational(compact, market);
|
|
2894
|
+
if (!parts || parts.national.length < 7) return value;
|
|
2895
|
+
const head = parts.national.slice(0, 3);
|
|
2896
|
+
const tail = parts.national.slice(-3);
|
|
2897
|
+
return `${parts.calling}${GAP}${head}${GAP}\u2022\u2022\u2022${GAP}${tail}`;
|
|
2898
|
+
}
|
|
2899
|
+
function findMarket(markets, code) {
|
|
2900
|
+
return markets.find((market) => market.code === code);
|
|
2901
|
+
}
|
|
2902
|
+
function activeMarkets(markets) {
|
|
2903
|
+
return markets.filter((market) => market.status === "active");
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2776
2906
|
// src/share.ts
|
|
2777
2907
|
var DEFAULT_SHARE_ORIGIN = "https://go.mitumba.africa";
|
|
2778
2908
|
var ID_PATTERN = /^[0-9a-f]{32}$/;
|
|
@@ -2836,6 +2966,7 @@ var MitumbaClient = class {
|
|
|
2836
2966
|
reports;
|
|
2837
2967
|
wholesale;
|
|
2838
2968
|
iam;
|
|
2969
|
+
markets;
|
|
2839
2970
|
constructor(config) {
|
|
2840
2971
|
this.api = new APIClient(config);
|
|
2841
2972
|
this.auth = new AuthModule(this.api);
|
|
@@ -2860,6 +2991,7 @@ var MitumbaClient = class {
|
|
|
2860
2991
|
this.reports = new ReportsModule(this.api);
|
|
2861
2992
|
this.wholesale = new WholesaleModule(this.api);
|
|
2862
2993
|
this.iam = new IamModule(this.api);
|
|
2994
|
+
this.markets = new MarketsModule(this.api);
|
|
2863
2995
|
}
|
|
2864
2996
|
/**
|
|
2865
2997
|
* Set the access token for authenticated requests.
|
|
@@ -2918,6 +3050,7 @@ exports.IamModule = IamModule;
|
|
|
2918
3050
|
exports.LISTING_STATUSES = LISTING_STATUSES;
|
|
2919
3051
|
exports.ListingsModule = ListingsModule;
|
|
2920
3052
|
exports.MailerModule = MailerModule;
|
|
3053
|
+
exports.MarketsModule = MarketsModule;
|
|
2921
3054
|
exports.MemoryTokenStore = MemoryTokenStore;
|
|
2922
3055
|
exports.MessagesModule = MessagesModule;
|
|
2923
3056
|
exports.MitumbaClient = MitumbaClient;
|
|
@@ -2939,11 +3072,20 @@ exports.UploadsModule = UploadsModule;
|
|
|
2939
3072
|
exports.VaziModule = VaziModule;
|
|
2940
3073
|
exports.WholesaleModule = WholesaleModule;
|
|
2941
3074
|
exports.WishlistsModule = WishlistsModule;
|
|
3075
|
+
exports.activeMarkets = activeMarkets;
|
|
2942
3076
|
exports.baleShareUrl = baleShareUrl;
|
|
2943
3077
|
exports.createTokenStore = createTokenStore;
|
|
3078
|
+
exports.findMarket = findMarket;
|
|
3079
|
+
exports.formatAmount = formatAmount;
|
|
3080
|
+
exports.formatMoney = formatMoney;
|
|
3081
|
+
exports.formatMoneyCompact = formatMoneyCompact;
|
|
3082
|
+
exports.formatPhone = formatPhone;
|
|
2944
3083
|
exports.isConsentRequired = isConsentRequired;
|
|
2945
3084
|
exports.isMessagingAPIError = isMessagingAPIError;
|
|
3085
|
+
exports.isValidPhone = isValidPhone;
|
|
2946
3086
|
exports.listingShareUrl = listingShareUrl;
|
|
3087
|
+
exports.maskPhone = maskPhone;
|
|
3088
|
+
exports.normalizePhone = normalizePhone;
|
|
2947
3089
|
exports.storeShareUrl = storeShareUrl;
|
|
2948
3090
|
//# sourceMappingURL=index.js.map
|
|
2949
3091
|
//# sourceMappingURL=index.js.map
|