@mitumba/sdk 5.18.0 → 5.20.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.ts CHANGED
@@ -1460,6 +1460,56 @@ interface LibraryListing {
1460
1460
  /** True when the caller holds `library:read_all` and so sees every document. */
1461
1461
  can_read_all: boolean;
1462
1462
  }
1463
+ type PlatformSettingKind = 'boolean' | 'domains' | 'text';
1464
+ type PlatformSettingGroup = 'Sign-in' | 'Operator access' | 'Messaging' | 'Payments' | 'Other';
1465
+ /** One platform setting with its current value, from `admin.listSettings()`. */
1466
+ interface PlatformSetting {
1467
+ key: string;
1468
+ label: string;
1469
+ description: string;
1470
+ group: PlatformSettingGroup;
1471
+ kind: PlatformSettingKind;
1472
+ /** True when `admin.changeSetting()` may change it (with `roles:grant` and a recent passkey). */
1473
+ editable: boolean;
1474
+ /** What changing it does to real people; shown before a change. */
1475
+ warning?: string;
1476
+ /** For read-only settings: where they are changed instead. */
1477
+ managedBy?: string;
1478
+ /** Shown when the setting has never been set. */
1479
+ defaultValue?: string;
1480
+ /** The current value, or null when never set (the default applies). */
1481
+ value: string | null;
1482
+ is_default: boolean;
1483
+ changed_at: string | null;
1484
+ changed_by: string | null;
1485
+ reason: string | null;
1486
+ /** How many times it has been set. */
1487
+ changes: number;
1488
+ }
1489
+ interface PlatformSettingChange {
1490
+ id: string;
1491
+ key: string;
1492
+ value: string;
1493
+ changed_by: string;
1494
+ reason: string | null;
1495
+ effective_at: string;
1496
+ }
1497
+ interface PlatformSettingDetail {
1498
+ setting: PlatformSetting;
1499
+ /** Newest first, at most 50. */
1500
+ history: PlatformSettingChange[];
1501
+ }
1502
+ interface ChangePlatformSettingInput {
1503
+ value: string;
1504
+ /** Why, in 3 to 500 characters. Recorded with the change and on the audit trail. */
1505
+ reason: string;
1506
+ }
1507
+ interface ChangePlatformSettingResult {
1508
+ ok: true;
1509
+ /** True when the value was already this; nothing was recorded. */
1510
+ unchanged: boolean;
1511
+ setting: PlatformSetting;
1512
+ }
1463
1513
 
1464
1514
  interface AuthTokens {
1465
1515
  access_token: string;
@@ -2768,6 +2818,91 @@ interface CartItem {
2768
2818
  delivery_fee: number;
2769
2819
  }
2770
2820
 
2821
+ /** An amount in a currency's minor units (cents for KES). */
2822
+ interface CheckoutMoney {
2823
+ currency: string;
2824
+ minor_units: number;
2825
+ }
2826
+ interface CreateCheckoutInput {
2827
+ /** One of the buyer's saved addresses. */
2828
+ address_id: string;
2829
+ /** One per buyer intent, 8 to 128 characters. A retry with the same key returns the same checkout. */
2830
+ idempotency_key: string;
2831
+ /** Exactly one per shop in the cart: the delivery quote picked for that shop. */
2832
+ deliveries: Array<{
2833
+ store_id: string;
2834
+ quote_id: string;
2835
+ }>;
2836
+ }
2837
+ type CheckoutState = 'awaiting_payment' | 'paid' | 'expired' | 'cancelled';
2838
+ /** One shop's order within a checkout. */
2839
+ interface CheckoutShopOrder {
2840
+ order_id: string;
2841
+ store_id: string;
2842
+ items_total: CheckoutMoney;
2843
+ delivery_fee: CheckoutMoney;
2844
+ /** The buyer protection fee (BPF) on this shop's order; zero when none. */
2845
+ bpf: CheckoutMoney;
2846
+ /** What the buyer pays for this shop's order: items + delivery + BPF. */
2847
+ total: CheckoutMoney;
2848
+ }
2849
+ /** One cart submission, holding one order per shop. */
2850
+ interface Checkout {
2851
+ id: string;
2852
+ invoice_number: string;
2853
+ status: CheckoutState;
2854
+ market_code: string;
2855
+ items_total: CheckoutMoney;
2856
+ delivery_total: CheckoutMoney;
2857
+ /** The BPF across every shop's order; zero when none. */
2858
+ bpf_total: CheckoutMoney;
2859
+ /** What the buyer pays: items + delivery + BPF. */
2860
+ total: CheckoutMoney;
2861
+ /** Payment due-by (ISO 8601). */
2862
+ due_at: string;
2863
+ created_at: string;
2864
+ orders: CheckoutShopOrder[];
2865
+ }
2866
+ interface CreateCheckoutResponse {
2867
+ checkout: Checkout;
2868
+ order_ids: string[];
2869
+ count: number;
2870
+ }
2871
+ interface GetCheckoutResponse {
2872
+ checkout: Checkout;
2873
+ }
2874
+ /** Why a checkout was refused: the error body, keyed by `error`. */
2875
+ type CheckoutRefusal = {
2876
+ error: 'invalid_input' | 'empty_cart' | 'cannot_buy_own' | 'invalid_deliveries';
2877
+ } | {
2878
+ error: 'address_not_found';
2879
+ } | {
2880
+ error: 'idempotency_conflict';
2881
+ } | {
2882
+ error: 'listing_unavailable';
2883
+ listings: Array<{
2884
+ listing_id: string;
2885
+ available: number;
2886
+ }>;
2887
+ } | {
2888
+ error: 'mixed_market_cart' | 'market_not_active';
2889
+ } | {
2890
+ error: 'checkout_payment_in_progress';
2891
+ checkout_id: string;
2892
+ } | {
2893
+ error: 'delivery_quote_rejected';
2894
+ store_id: string | null;
2895
+ reason: string;
2896
+ } | {
2897
+ error: 'address_region_invalid';
2898
+ } | {
2899
+ error: 'delivery_required';
2900
+ store_ids: string[];
2901
+ } | {
2902
+ error: 'delivery_quotes_unavailable';
2903
+ };
2904
+ type CheckoutRefusalCode = CheckoutRefusal['error'];
2905
+
2771
2906
  /**
2772
2907
  * Fields a user may change on their own profile via `PUT /auth/me`. Every field is optional;
2773
2908
  * only the ones provided are updated. The server enforces the profile contract:
@@ -3123,6 +3258,43 @@ interface IamPasskeyLoginOptions {
3123
3258
  interface IamMethodsResult {
3124
3259
  methods: TwoFactorMethod[];
3125
3260
  }
3261
+ /** One live sign-in session of an IAM user. */
3262
+ interface IamSession {
3263
+ id: string;
3264
+ /** The browser or device that signed in, as it identified itself. */
3265
+ device: string;
3266
+ ip_address: string | null;
3267
+ created_at: string;
3268
+ /** Updated whenever the session renews its access, roughly every 15 minutes while in use. */
3269
+ last_active_at: string;
3270
+ expires_at: string;
3271
+ /** How the session signed in (`passkey`, `totp`, `password`), when recorded. */
3272
+ strength: string | null;
3273
+ /** True for the session making the request (always false in administration views). */
3274
+ current: boolean;
3275
+ }
3276
+ interface IamSessionsResult {
3277
+ sessions: IamSession[];
3278
+ }
3279
+ /** Why a sign-in was refused. New reasons may be added; treat unknown values as opaque. */
3280
+ type IamSignInFailureReason = 'unknown_user' | 'not_activated' | 'wrong_password' | 'principal_disabled' | 'organization_suspended' | 'invalid_code' | 'passkey_not_recognised' | 'passkey_unverified' | 'too_many_codes';
3281
+ /** One sign-in attempt against an IAM user, successful or refused. */
3282
+ interface IamSignIn {
3283
+ id: string;
3284
+ at: string;
3285
+ outcome: 'ok' | 'failed';
3286
+ /** The step the attempt reached: `password`, `totp` or `passkey`. */
3287
+ step: string | null;
3288
+ reason: IamSignInFailureReason | string | null;
3289
+ strength: string | null;
3290
+ /** This attempt reached the limit; further attempts were refused for a while. */
3291
+ locked: boolean;
3292
+ ip: string | null;
3293
+ device: string | null;
3294
+ }
3295
+ interface IamSignInsResult {
3296
+ signins: IamSignIn[];
3297
+ }
3126
3298
 
3127
3299
  interface MitumbaClientConfig {
3128
3300
  baseUrl: string;
@@ -3196,7 +3368,9 @@ declare class APIError extends Error {
3196
3368
  readonly code: string;
3197
3369
  readonly status: number;
3198
3370
  readonly details?: unknown;
3199
- constructor(status: number, data: APIErrorResponse);
3371
+ /** The decoded error body as the server sent it, for errors whose details are top-level fields. */
3372
+ readonly body?: unknown;
3373
+ constructor(status: number, data: APIErrorResponse, body?: unknown);
3200
3374
  }
3201
3375
  declare class APIClient {
3202
3376
  private config;
@@ -4122,6 +4296,8 @@ declare class CartModule {
4122
4296
  }>;
4123
4297
  /**
4124
4298
  * Checkout the cart — creates orders grouped by store and clears the cart.
4299
+ * @deprecated Use `sdk.checkouts.create`: checkout needs an address, an idempotency key and a
4300
+ * delivery quote per shop, and returns the checkout with its totals.
4125
4301
  */
4126
4302
  checkout(options?: RequestOptions): Promise<{
4127
4303
  order_ids: string[];
@@ -4129,6 +4305,25 @@ declare class CartModule {
4129
4305
  }>;
4130
4306
  }
4131
4307
 
4308
+ /**
4309
+ * The checkout refusal carried by an error thrown from `checkouts.create`, or null when the error is
4310
+ * not one. The body is the server's own, so the refusal's details (such as `listings` for
4311
+ * `listing_unavailable`) are present.
4312
+ */
4313
+ declare function checkoutRefusal(error: unknown): CheckoutRefusal | null;
4314
+ declare class CheckoutsModule {
4315
+ private readonly client;
4316
+ constructor(client: APIClient);
4317
+ /**
4318
+ * Create a checkout from the buyer's cart: one order per shop, each at the delivery quote picked
4319
+ * for it, held until the checkout's due-by. A retry with the same `idempotency_key` returns the
4320
+ * same checkout. A refusal throws an `APIError`; read it with `checkoutRefusal(error)`.
4321
+ */
4322
+ create(input: CreateCheckoutInput, options?: RequestOptions): Promise<CreateCheckoutResponse>;
4323
+ /** Read one of the buyer's checkouts. Anyone else gets a 404. */
4324
+ get(checkoutId: string, options?: RequestOptions): Promise<GetCheckoutResponse>;
4325
+ }
4326
+
4132
4327
  declare class SettingsModule {
4133
4328
  private readonly client;
4134
4329
  constructor(client: APIClient);
@@ -4489,6 +4684,19 @@ declare class AdminModule {
4489
4684
  * (`deduplicated: true`); a different resolution of an already resolved report is 409.
4490
4685
  */
4491
4686
  resolveMessageReport(reportId: string, input: ResolveMessageReportInput, options?: RequestOptions): Promise<ResolveMessageReportResult>;
4687
+ /** Every platform setting with its current value and whether it can be changed here. Requires `admin:read`. */
4688
+ listSettings(options?: RequestOptions): Promise<{
4689
+ settings: PlatformSetting[];
4690
+ }>;
4691
+ /** One setting and its change history, newest first. Requires `admin:read`. */
4692
+ getSetting(key: string, options?: RequestOptions): Promise<PlatformSettingDetail>;
4693
+ /**
4694
+ * Change an editable setting. Requires `roles:grant` and a recent passkey (403
4695
+ * `reauthentication_required` otherwise). Errors: 403 `not_editable` for payment and messaging
4696
+ * settings, 400 `invalid_value`, 409 `would_lock_you_out` when an operator-domain change would
4697
+ * remove the caller's own domain. Recorded on the audit trail as `config.changed`.
4698
+ */
4699
+ changeSetting(key: string, input: ChangePlatformSettingInput, options?: RequestOptions): Promise<ChangePlatformSettingResult>;
4492
4700
  listVaziOutfits(params?: {
4493
4701
  page?: number;
4494
4702
  }, options?: RequestOptions): Promise<{
@@ -4857,6 +5065,33 @@ declare class IamModule {
4857
5065
  }>;
4858
5066
  /** Get the current IAM principal, organization and effective access state. */
4859
5067
  me(options?: RequestOptions): Promise<IamProfile>;
5068
+ /** This IAM user's live sessions, most recently active first; `current` marks this one. */
5069
+ listSessions(options?: RequestOptions): Promise<IamSessionsResult>;
5070
+ /**
5071
+ * End one of this IAM user's sessions. It can no longer be renewed; its current access lapses
5072
+ * within 15 minutes. 404 for a session that does not exist or is not this user's.
5073
+ */
5074
+ endSession(sessionId: string, options?: RequestOptions): Promise<{
5075
+ ok: true;
5076
+ }>;
5077
+ /** This IAM user's recent sign-in attempts, newest first, successful and refused (at most 100). */
5078
+ listSignIns(params?: {
5079
+ limit?: number;
5080
+ }, options?: RequestOptions): Promise<IamSignInsResult>;
5081
+ /** An IAM user's live sessions. Requires `roles:grant`; IAM users cannot call it. */
5082
+ listUserSessions(orgId: string, iamUserId: string, options?: RequestOptions): Promise<IamSessionsResult>;
5083
+ /** End one of an IAM user's sessions (its current access lapses within 15 minutes). Requires `roles:grant`. */
5084
+ endUserSession(orgId: string, iamUserId: string, sessionId: string, options?: RequestOptions): Promise<{
5085
+ ok: true;
5086
+ }>;
5087
+ /** Sign an IAM user out of every device now, without disabling them. Requires `roles:grant`. */
5088
+ endAllUserSessions(orgId: string, iamUserId: string, options?: RequestOptions): Promise<{
5089
+ ok: true;
5090
+ }>;
5091
+ /** An IAM user's recent sign-in attempts, successful and refused. Requires `roles:grant`. */
5092
+ listUserSignIns(orgId: string, iamUserId: string, params?: {
5093
+ limit?: number;
5094
+ }, options?: RequestOptions): Promise<IamSignInsResult>;
4860
5095
  /** List this IAM principal's enrolled second-factor methods. */
4861
5096
  listMethods(options?: RequestOptions): Promise<IamMethodsResult>;
4862
5097
  /** Begin adding an authenticator app or passkey. */
@@ -5035,6 +5270,7 @@ declare class MitumbaClient {
5035
5270
  readonly reviews: ReviewsModule;
5036
5271
  readonly wishlists: WishlistsModule;
5037
5272
  readonly cart: CartModule;
5273
+ readonly checkouts: CheckoutsModule;
5038
5274
  readonly settings: SettingsModule;
5039
5275
  readonly mailer: MailerModule;
5040
5276
  readonly businesses: BusinessesModule;
@@ -5076,4 +5312,4 @@ declare class MitumbaClient {
5076
5312
  isAuthenticated(): Promise<boolean>;
5077
5313
  }
5078
5314
 
5079
- 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 AdminAuditActor, type AdminAuditEntry, type AdminAuditQuery, type AdminAuthStrength, type AdminListingItem, type AdminMessageReport, type AdminMessageReportDetail, type AdminMessageReportList, type AdminMessageReportThreadMessage, 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 FileResponse, 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 LibraryCadence, type LibraryCompleter, type LibraryDocument, type LibraryDocumentSummary, type LibraryKind, type LibraryListing, type LibraryOccurrence, type LibraryOccurrenceRecorded, type LibraryOccurrenceStatus, type LibraryRoutineState, type LibrarySchedule, type LibraryScheduleRule, type LibrarySeason, type LibraryWeekday, 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 MarketRegion, type MarketRegionsResponse, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportOutcome, type MessageReportReason, type MessageReportStatus, 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, type MessagingSide, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthClient, type OAuthClientSummary, type OAuthClientTrustLevel, type OAuthClientType, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OidcSigningKey, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderDocument, type OrderDocumentKind, 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 RegisterOAuthClientInput, type RegisteredOAuthClient, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveMessageReportInput, type ResolveMessageReportResult, 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 WholesaleReviewStatus, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
5315
+ 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 AdminAuditActor, type AdminAuditEntry, type AdminAuditQuery, type AdminAuthStrength, type AdminListingItem, type AdminMessageReport, type AdminMessageReportDetail, type AdminMessageReportList, type AdminMessageReportThreadMessage, 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 ChangePlatformSettingInput, type ChangePlatformSettingResult, type Checkout, type CheckoutMoney, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutRefusal, type CheckoutRefusalCode, type CheckoutShopOrder, type CheckoutState, type CheckoutStatus, type CheckoutStatusResponse, CheckoutsModule, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateCheckoutInput, type CreateCheckoutResponse, 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 FileResponse, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, type GetCheckoutResponse, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamSession, type IamSessionsResult, type IamSignIn, type IamSignInFailureReason, type IamSignInsResult, 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 LibraryCadence, type LibraryCompleter, type LibraryDocument, type LibraryDocumentSummary, type LibraryKind, type LibraryListing, type LibraryOccurrence, type LibraryOccurrenceRecorded, type LibraryOccurrenceStatus, type LibraryRoutineState, type LibrarySchedule, type LibraryScheduleRule, type LibrarySeason, type LibraryWeekday, 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 MarketRegion, type MarketRegionsResponse, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportOutcome, type MessageReportReason, type MessageReportStatus, 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, type MessagingSide, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthClient, type OAuthClientSummary, type OAuthClientTrustLevel, type OAuthClientType, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OidcSigningKey, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderDocument, type OrderDocumentKind, 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 PlatformSetting, type PlatformSettingChange, type PlatformSettingDetail, type PlatformSettingGroup, type PlatformSettingKind, 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 RegisterOAuthClientInput, type RegisteredOAuthClient, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveMessageReportInput, type ResolveMessageReportResult, 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 WholesaleReviewStatus, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, checkoutRefusal, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
package/dist/index.js CHANGED
@@ -134,12 +134,15 @@ var APIError = class extends Error {
134
134
  code;
135
135
  status;
136
136
  details;
137
- constructor(status, data) {
137
+ /** The decoded error body as the server sent it, for errors whose details are top-level fields. */
138
+ body;
139
+ constructor(status, data, body) {
138
140
  super(data.message || data.error);
139
141
  this.name = "APIError";
140
142
  this.code = data.error;
141
143
  this.status = status;
142
144
  this.details = data.details;
145
+ this.body = body;
143
146
  }
144
147
  };
145
148
  function isExpiringSoon(token, thresholdSeconds) {
@@ -385,7 +388,7 @@ var APIClient = class {
385
388
  } catch {
386
389
  decoded = null;
387
390
  }
388
- throw new APIError(response.status, normalizeAPIErrorResponse(decoded, response.statusText));
391
+ throw new APIError(response.status, normalizeAPIErrorResponse(decoded, response.statusText), decoded ?? void 0);
389
392
  }
390
393
  return response;
391
394
  }
@@ -2104,12 +2107,57 @@ var CartModule = class {
2104
2107
  }
2105
2108
  /**
2106
2109
  * Checkout the cart — creates orders grouped by store and clears the cart.
2110
+ * @deprecated Use `sdk.checkouts.create`: checkout needs an address, an idempotency key and a
2111
+ * delivery quote per shop, and returns the checkout with its totals.
2107
2112
  */
2108
2113
  async checkout(options) {
2109
2114
  return this.client.post("/orders/checkout", void 0, options);
2110
2115
  }
2111
2116
  };
2112
2117
 
2118
+ // src/modules/checkouts.ts
2119
+ var REFUSAL_CODES = /* @__PURE__ */ new Set([
2120
+ "invalid_input",
2121
+ "empty_cart",
2122
+ "cannot_buy_own",
2123
+ "invalid_deliveries",
2124
+ "address_not_found",
2125
+ "idempotency_conflict",
2126
+ "listing_unavailable",
2127
+ "mixed_market_cart",
2128
+ "market_not_active",
2129
+ "checkout_payment_in_progress",
2130
+ "delivery_quote_rejected",
2131
+ "address_region_invalid",
2132
+ "delivery_required",
2133
+ "delivery_quotes_unavailable"
2134
+ ]);
2135
+ function checkoutRefusal(error) {
2136
+ if (!(error instanceof APIError)) return null;
2137
+ const body = error.body;
2138
+ if (typeof body !== "object" || body === null) return null;
2139
+ const code = body.error;
2140
+ if (typeof code !== "string" || !REFUSAL_CODES.has(code)) return null;
2141
+ return body;
2142
+ }
2143
+ var CheckoutsModule = class {
2144
+ constructor(client) {
2145
+ this.client = client;
2146
+ }
2147
+ /**
2148
+ * Create a checkout from the buyer's cart: one order per shop, each at the delivery quote picked
2149
+ * for it, held until the checkout's due-by. A retry with the same `idempotency_key` returns the
2150
+ * same checkout. A refusal throws an `APIError`; read it with `checkoutRefusal(error)`.
2151
+ */
2152
+ async create(input, options) {
2153
+ return this.client.post("/orders/checkout", input, options);
2154
+ }
2155
+ /** Read one of the buyer's checkouts. Anyone else gets a 404. */
2156
+ async get(checkoutId, options) {
2157
+ return this.client.get(`/orders/checkouts/${encodeURIComponent(checkoutId)}`, void 0, options);
2158
+ }
2159
+ };
2160
+
2113
2161
  // src/modules/settings.ts
2114
2162
  var SettingsModule = class {
2115
2163
  constructor(client) {
@@ -2426,6 +2474,24 @@ var AdminModule = class {
2426
2474
  async resolveMessageReport(reportId, input, options) {
2427
2475
  return this.client.post(`/admin/message-reports/${encodeURIComponent(reportId)}/resolve`, input, options);
2428
2476
  }
2477
+ // ── Platform settings ──
2478
+ /** Every platform setting with its current value and whether it can be changed here. Requires `admin:read`. */
2479
+ async listSettings(options) {
2480
+ return this.client.get("/admin/settings", void 0, options);
2481
+ }
2482
+ /** One setting and its change history, newest first. Requires `admin:read`. */
2483
+ async getSetting(key, options) {
2484
+ return this.client.get(`/admin/settings/${encodeURIComponent(key)}`, void 0, options);
2485
+ }
2486
+ /**
2487
+ * Change an editable setting. Requires `roles:grant` and a recent passkey (403
2488
+ * `reauthentication_required` otherwise). Errors: 403 `not_editable` for payment and messaging
2489
+ * settings, 400 `invalid_value`, 409 `would_lock_you_out` when an operator-domain change would
2490
+ * remove the caller's own domain. Recorded on the audit trail as `config.changed`.
2491
+ */
2492
+ async changeSetting(key, input, options) {
2493
+ return this.client.put(`/admin/settings/${encodeURIComponent(key)}`, input, options);
2494
+ }
2429
2495
  // ── VAZI Moderation ──
2430
2496
  async listVaziOutfits(params, options) {
2431
2497
  return this.client.get("/admin/vazi/outfits", params, options);
@@ -2836,6 +2902,46 @@ var IamModule = class {
2836
2902
  async me(options) {
2837
2903
  return this.client.get("/auth/iam/me", void 0, options);
2838
2904
  }
2905
+ // ── Sessions and sign-in history ──
2906
+ /** This IAM user's live sessions, most recently active first; `current` marks this one. */
2907
+ async listSessions(options) {
2908
+ return this.client.get("/auth/iam/sessions", void 0, options);
2909
+ }
2910
+ /**
2911
+ * End one of this IAM user's sessions. It can no longer be renewed; its current access lapses
2912
+ * within 15 minutes. 404 for a session that does not exist or is not this user's.
2913
+ */
2914
+ async endSession(sessionId, options) {
2915
+ return this.client.post(`/auth/iam/sessions/${encodeURIComponent(sessionId)}/revoke`, void 0, options);
2916
+ }
2917
+ /** This IAM user's recent sign-in attempts, newest first, successful and refused (at most 100). */
2918
+ async listSignIns(params, options) {
2919
+ return this.client.get("/auth/iam/signins", params, options);
2920
+ }
2921
+ /** An IAM user's live sessions. Requires `roles:grant`; IAM users cannot call it. */
2922
+ async listUserSessions(orgId, iamUserId, options) {
2923
+ return this.client.get(`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/sessions`, void 0, options);
2924
+ }
2925
+ /** End one of an IAM user's sessions (its current access lapses within 15 minutes). Requires `roles:grant`. */
2926
+ async endUserSession(orgId, iamUserId, sessionId, options) {
2927
+ return this.client.post(
2928
+ `/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/sessions/${encodeURIComponent(sessionId)}/revoke`,
2929
+ void 0,
2930
+ options
2931
+ );
2932
+ }
2933
+ /** Sign an IAM user out of every device now, without disabling them. Requires `roles:grant`. */
2934
+ async endAllUserSessions(orgId, iamUserId, options) {
2935
+ return this.client.post(`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/sessions/revoke-all`, void 0, options);
2936
+ }
2937
+ /** An IAM user's recent sign-in attempts, successful and refused. Requires `roles:grant`. */
2938
+ async listUserSignIns(orgId, iamUserId, params, options) {
2939
+ return this.client.get(
2940
+ `/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/signins`,
2941
+ params,
2942
+ options
2943
+ );
2944
+ }
2839
2945
  /** List this IAM principal's enrolled second-factor methods. */
2840
2946
  async listMethods(options) {
2841
2947
  return this.client.get("/auth/iam/2fa/methods", void 0, options);
@@ -3140,6 +3246,7 @@ var MitumbaClient = class {
3140
3246
  reviews;
3141
3247
  wishlists;
3142
3248
  cart;
3249
+ checkouts;
3143
3250
  settings;
3144
3251
  mailer;
3145
3252
  businesses;
@@ -3165,6 +3272,7 @@ var MitumbaClient = class {
3165
3272
  this.reviews = new ReviewsModule(this.api);
3166
3273
  this.wishlists = new WishlistsModule(this.api);
3167
3274
  this.cart = new CartModule(this.api);
3275
+ this.checkouts = new CheckoutsModule(this.api);
3168
3276
  this.settings = new SettingsModule(this.api);
3169
3277
  this.mailer = new MailerModule(this.api);
3170
3278
  this.businesses = new BusinessesModule(this.api);
@@ -3223,6 +3331,7 @@ exports.BALE_ORDER_STATUSES = BALE_ORDER_STATUSES;
3223
3331
  exports.BusinessesModule = BusinessesModule;
3224
3332
  exports.CONDITIONS = CONDITIONS;
3225
3333
  exports.CartModule = CartModule;
3334
+ exports.CheckoutsModule = CheckoutsModule;
3226
3335
  exports.DEFAULT_SHARE_ORIGIN = DEFAULT_SHARE_ORIGIN;
3227
3336
  exports.DESIRED_RESOLUTIONS = DESIRED_RESOLUTIONS;
3228
3337
  exports.DISPUTE_REASONS = DISPUTE_REASONS;
@@ -3257,6 +3366,7 @@ exports.WholesaleModule = WholesaleModule;
3257
3366
  exports.WishlistsModule = WishlistsModule;
3258
3367
  exports.activeMarkets = activeMarkets;
3259
3368
  exports.baleShareUrl = baleShareUrl;
3369
+ exports.checkoutRefusal = checkoutRefusal;
3260
3370
  exports.createTokenStore = createTokenStore;
3261
3371
  exports.findMarket = findMarket;
3262
3372
  exports.findRegion = findRegion;