@mitumba/sdk 5.32.0 → 5.34.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.mjs CHANGED
@@ -2250,6 +2250,31 @@ var NotificationsModule = class {
2250
2250
  async markRead(ids, options) {
2251
2251
  return this.client.post("/notify/notifications/read", ids ? { ids } : {}, options);
2252
2252
  }
2253
+ /**
2254
+ * The caller's notification settings: categories with their channels, which channels can reach
2255
+ * them now, quiet hours, muted pop-ups and marketing consent.
2256
+ */
2257
+ async getPreferences(options) {
2258
+ return this.client.get("/notify/notifications/preferences", void 0, options);
2259
+ }
2260
+ /**
2261
+ * Set (or, with `enabled: null`, reset to default) 1 to 64 category × channel cells. A cell
2262
+ * applies to every event in its category. Answers the whole updated preferences.
2263
+ */
2264
+ async updatePreferences(cells, options) {
2265
+ return this.client.put("/notify/notifications/preferences", { cells }, options);
2266
+ }
2267
+ /** Change quiet hours, muted pop-up kinds, or both. Answers the whole updated preferences. */
2268
+ async updatePreferenceSettings(input, options) {
2269
+ return this.client.put("/notify/notifications/preferences/settings", input, options);
2270
+ }
2271
+ /**
2272
+ * Opt in to or out of marketing on one channel. The server records its own consent wording
2273
+ * (shown to the person as `consentWording`). Answers the whole updated preferences.
2274
+ */
2275
+ async setMarketingConsent(input, options) {
2276
+ return this.client.put("/notify/notifications/preferences/consent", { channel: input.channel, granted: input.granted }, options);
2277
+ }
2253
2278
  /** Create an inert live notification stream. Register listeners before `start()`. */
2254
2279
  stream(options) {
2255
2280
  return new ManagedNotificationStream(this.client, options);
@@ -2312,7 +2337,8 @@ var StoresModule = class {
2312
2337
  );
2313
2338
  }
2314
2339
  /**
2315
- * Get all stores owned by the authenticated user.
2340
+ * The shops the authenticated user works in, owned or joined, each with their role in it and the
2341
+ * permissions it grants. Show only the actions those permissions allow.
2316
2342
  */
2317
2343
  async getMyStores(options) {
2318
2344
  return this.client.get("/listings/stores/mine", void 0, options);
@@ -2472,6 +2498,112 @@ var StoresModule = class {
2472
2498
  destinationPath(storeId, destinationId, suffix) {
2473
2499
  return `/listings/stores/${encodeURIComponent(storeId)}/payout-destinations/${encodeURIComponent(destinationId)}${suffix}`;
2474
2500
  }
2501
+ // ── Team ──────────────────────────────────────────────────────────────────
2502
+ /**
2503
+ * The shop's members, and the roles the caller may give. `store:members.manage`.
2504
+ *
2505
+ * Errors: 403 store_forbidden; 404 not_found.
2506
+ */
2507
+ async getMembers(storeId, options) {
2508
+ return this.client.get(`${this.storePath(storeId)}/members`, void 0, options);
2509
+ }
2510
+ /**
2511
+ * Change a member's role. The owner manages every role; a manager, the roles below manager.
2512
+ * Needs a second factor used in the last 10 minutes.
2513
+ *
2514
+ * Errors: 400 invalid_input; 403 store_forbidden, step_up_required, role_not_allowed; 404 member_not_found.
2515
+ */
2516
+ async changeMemberRole(storeId, memberId, role, options) {
2517
+ return this.client.patch(`${this.storePath(storeId)}/members/${encodeURIComponent(memberId)}`, { role }, options);
2518
+ }
2519
+ /**
2520
+ * Remove a member. They lose access on their next request. Needs a recent second factor.
2521
+ *
2522
+ * Errors: 403 store_forbidden, step_up_required, role_not_allowed; 404 member_not_found.
2523
+ */
2524
+ async removeMember(storeId, memberId, options) {
2525
+ return this.client.delete(`${this.storePath(storeId)}/members/${encodeURIComponent(memberId)}`, void 0, options);
2526
+ }
2527
+ /**
2528
+ * Leave a shop's team. The owner cannot leave their own shop.
2529
+ *
2530
+ * Errors: 404 member_not_found; 409 owner_cannot_leave.
2531
+ */
2532
+ async leave(storeId, options) {
2533
+ return this.client.post(`${this.storePath(storeId)}/leave`, void 0, options);
2534
+ }
2535
+ /**
2536
+ * Invite someone by email address or Kenyan phone number. The answer is the same whether or not an
2537
+ * account uses the address. Needs a recent second factor. The invitation lasts 7 days.
2538
+ *
2539
+ * Errors: 400 invalid_input, invalid_address; 403 store_forbidden, step_up_required, role_not_allowed;
2540
+ * 404 not_found; 409 too_many_invitations.
2541
+ */
2542
+ async invite(storeId, input, options) {
2543
+ return this.client.post(`${this.storePath(storeId)}/invitations`, input, options);
2544
+ }
2545
+ /**
2546
+ * The shop's open invitations, newest first. `store:members.manage`.
2547
+ *
2548
+ * Errors: 403 store_forbidden; 404 not_found.
2549
+ */
2550
+ async getInvitations(storeId, options) {
2551
+ return this.client.get(`${this.storePath(storeId)}/invitations`, void 0, options);
2552
+ }
2553
+ /**
2554
+ * Revoke an open invitation. Needs a recent second factor.
2555
+ *
2556
+ * Errors: 403 store_forbidden, step_up_required, role_not_allowed; 404 invitation_not_found.
2557
+ */
2558
+ async revokeInvitation(storeId, invitationId, options) {
2559
+ return this.client.delete(`${this.storePath(storeId)}/invitations/${encodeURIComponent(invitationId)}`, void 0, options);
2560
+ }
2561
+ /** Invitations the caller received and can still answer, newest first. */
2562
+ async getReceivedInvitations(options) {
2563
+ return this.client.get("/listings/store-invitations", void 0, options);
2564
+ }
2565
+ /**
2566
+ * Join a shop. Needs a verified phone number; the manager role also needs a recent second factor.
2567
+ *
2568
+ * Errors: 403 step_up_required; 404 invitation_not_found, not_found; 409 phone_not_verified,
2569
+ * membership_limit, already_member.
2570
+ */
2571
+ async acceptInvitation(invitationId, options) {
2572
+ return this.client.post(`/listings/store-invitations/${encodeURIComponent(invitationId)}/accept`, void 0, options);
2573
+ }
2574
+ /**
2575
+ * Decline an invitation.
2576
+ *
2577
+ * Errors: 404 invitation_not_found.
2578
+ */
2579
+ async declineInvitation(invitationId, options) {
2580
+ return this.client.post(`/listings/store-invitations/${encodeURIComponent(invitationId)}/decline`, void 0, options);
2581
+ }
2582
+ /**
2583
+ * The shop's audit log, newest first, 50 per page. `store:audit.read`.
2584
+ *
2585
+ * Errors: 403 store_forbidden; 404 not_found.
2586
+ */
2587
+ async getAuditLog(storeId, params, options) {
2588
+ return this.client.get(`${this.storePath(storeId)}/audit`, params, options);
2589
+ }
2590
+ // ── Shop limit ────────────────────────────────────────────────────────────
2591
+ /** The caller's shop limit, how many shops they own, and their latest request for more. */
2592
+ async getStoreLimit(options) {
2593
+ return this.client.get("/listings/store-limit-request", void 0, options);
2594
+ }
2595
+ /**
2596
+ * Ask for a higher shop limit, at the limit, with a reason of at least 30 characters. One request
2597
+ * at a time.
2598
+ *
2599
+ * Errors: 400 invalid_input; 403 not_a_retail_seller; 409 not_at_limit, request_pending.
2600
+ */
2601
+ async requestStoreLimit(input, options) {
2602
+ return this.client.post("/listings/store-limit-request", input, options);
2603
+ }
2604
+ storePath(storeId) {
2605
+ return `/listings/stores/${encodeURIComponent(storeId)}`;
2606
+ }
2475
2607
  };
2476
2608
  function stepUpRequired(error) {
2477
2609
  return error instanceof APIError && error.code === "step_up_required";
@@ -2856,6 +2988,13 @@ var AdminModule = class {
2856
2988
  return this.client.post(`/admin/stores/${storeId}/unverify`, void 0, options);
2857
2989
  }
2858
2990
  // ── Verification Queue ──
2991
+ /**
2992
+ * Read a private document as an operator. Dispute evidence needs `admin:read`; identity documents
2993
+ * and wholesale verification photos need `sellers:verify`.
2994
+ */
2995
+ async getDocument(documentId, options) {
2996
+ return this.client.getFile(`/admin/documents/${encodeURIComponent(documentId)}`, void 0, options);
2997
+ }
2859
2998
  async listVerifications(params, options) {
2860
2999
  return this.client.get("/admin/verifications", params, options);
2861
3000
  }
@@ -2920,6 +3059,24 @@ var AdminModule = class {
2920
3059
  async sendRefund(refundId, options) {
2921
3060
  return this.client.post(`/admin/refunds/${encodeURIComponent(refundId)}/send`, void 0, options);
2922
3061
  }
3062
+ /**
3063
+ * Requests for a higher shop limit, 25 per page: pending oldest first, decided latest first.
3064
+ * `admin:read`.
3065
+ *
3066
+ * Errors: 400 invalid_input (unknown status).
3067
+ */
3068
+ async listShopLimitRequests(params, options) {
3069
+ return this.client.get("/admin/shop-limit-requests", params, options);
3070
+ }
3071
+ /**
3072
+ * Approve a request with a new limit (above the current one, at most 50), or reject it with a note
3073
+ * of at least 10 characters. The owner is told. `sellers:verify`.
3074
+ *
3075
+ * Errors: 400 invalid_input; 403 forbidden; 404 not_found (not pending).
3076
+ */
3077
+ async decideShopLimitRequest(requestId, input, options) {
3078
+ return this.client.post(`/admin/shop-limit-requests/${encodeURIComponent(requestId)}/decide`, input, options);
3079
+ }
2923
3080
  // ── Reports Moderation ──
2924
3081
  async listReports(params, options) {
2925
3082
  return this.client.get("/admin/reports", params, options);
@@ -3199,6 +3356,28 @@ var UploadsModule = class {
3199
3356
  }
3200
3357
  };
3201
3358
 
3359
+ // src/modules/documents.ts
3360
+ function isDocumentId(value) {
3361
+ return /^doc_[a-z0-9]{1,60}$/.test(value);
3362
+ }
3363
+ var DocumentsModule = class {
3364
+ constructor(client) {
3365
+ this.client = client;
3366
+ }
3367
+ /** Upload a private document. Returns its id; the file itself is never public. */
3368
+ async upload(input, options) {
3369
+ const formData = new FormData();
3370
+ formData.append("purpose", input.purpose);
3371
+ formData.append("subject_id", input.subjectId);
3372
+ formData.append("file", input.file);
3373
+ return this.client.post("/listings/documents", formData, options);
3374
+ }
3375
+ /** Read a private document the signed-in user may see. 404 for any other. */
3376
+ async get(documentId, options) {
3377
+ return this.client.getFile(`/listings/documents/${encodeURIComponent(documentId)}`, void 0, options);
3378
+ }
3379
+ };
3380
+
3202
3381
  // src/modules/reports.ts
3203
3382
  var ReportsModule = class {
3204
3383
  constructor(client) {
@@ -3579,6 +3758,9 @@ var DISPUTE_REASONS = ["not_received", "not_as_described", "damaged", "counterfe
3579
3758
  var DESIRED_RESOLUTIONS = ["refund", "replacement", "partial_refund"];
3580
3759
  var DISPUTE_STATUSES = ["open", "seller_responded", "under_review", "resolved_refund", "resolved_release", "resolved_partial", "withdrawn"];
3581
3760
 
3761
+ // src/types/documents.ts
3762
+ var DOCUMENT_PURPOSES = ["dispute_evidence", "identity_document", "wholesale_verification"];
3763
+
3582
3764
  // src/types/wholesale.ts
3583
3765
  var BALE_ORDER_STATUSES = ["pending_payment", "paid", "confirmed", "in_transit", "delivered", "completed", "cancelled"];
3584
3766
 
@@ -3787,6 +3969,7 @@ var MitumbaClient = class {
3787
3969
  admin;
3788
3970
  disputes;
3789
3971
  uploads;
3972
+ documents;
3790
3973
  reports;
3791
3974
  wholesale;
3792
3975
  iam;
@@ -3813,6 +3996,7 @@ var MitumbaClient = class {
3813
3996
  this.admin = new AdminModule(this.api);
3814
3997
  this.disputes = new DisputesModule(this.api);
3815
3998
  this.uploads = new UploadsModule(this.api);
3999
+ this.documents = new DocumentsModule(this.api);
3816
4000
  this.reports = new ReportsModule(this.api);
3817
4001
  this.wholesale = new WholesaleModule(this.api);
3818
4002
  this.iam = new IamModule(this.api);
@@ -3857,6 +4041,6 @@ var MitumbaClient = class {
3857
4041
  }
3858
4042
  };
3859
4043
 
3860
- export { APIClient, APIError, AdminModule, AuthModule, BALE_ORDER_STATUSES, BusinessesModule, CONDITIONS, CartModule, CheckoutsModule, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, DisputesModule, IDBTokenStore, IamModule, LISTING_STATUSES, ListingsModule, MailerModule, MarketsModule, MemoryTokenStore, MessagesModule, MitumbaClient, NotificationsModule, OAuthModule, ORDER_STATUSES, OrdersModule, PAYMENT_STATUSES, PayModule, RealtimeProtocolError, RealtimeUnavailableError, ReportsModule, ReviewsModule, SearchModule, SettingsModule, StoresModule, TWO_FACTOR_METHOD_TYPES, UploadsModule, VaziModule, WholesaleModule, WishlistsModule, activeMarkets, baleShareUrl, cartLineAvailability, categoriesBySection, categorySection, checkoutRefusal, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isCartLineBuyable, isConditionAllowed, isConsentRequired, isMessagingAPIError, isNewOnlyCategory, isValidPhone, listingShareUrl, maskPhone, normalizePhone, partitionCart, regionById, stepUpRequired, storeShareUrl };
4044
+ export { APIClient, APIError, AdminModule, AuthModule, BALE_ORDER_STATUSES, BusinessesModule, CONDITIONS, CartModule, CheckoutsModule, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, DOCUMENT_PURPOSES, DisputesModule, DocumentsModule, IDBTokenStore, IamModule, LISTING_STATUSES, ListingsModule, MailerModule, MarketsModule, MemoryTokenStore, MessagesModule, MitumbaClient, NotificationsModule, OAuthModule, ORDER_STATUSES, OrdersModule, PAYMENT_STATUSES, PayModule, RealtimeProtocolError, RealtimeUnavailableError, ReportsModule, ReviewsModule, SearchModule, SettingsModule, StoresModule, TWO_FACTOR_METHOD_TYPES, UploadsModule, VaziModule, WholesaleModule, WishlistsModule, activeMarkets, baleShareUrl, cartLineAvailability, categoriesBySection, categorySection, checkoutRefusal, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isCartLineBuyable, isConditionAllowed, isConsentRequired, isDocumentId, isMessagingAPIError, isNewOnlyCategory, isValidPhone, listingShareUrl, maskPhone, normalizePhone, partitionCart, regionById, stepUpRequired, storeShareUrl };
3861
4045
  //# sourceMappingURL=index.mjs.map
3862
4046
  //# sourceMappingURL=index.mjs.map