@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.mts +238 -2
- package/dist/index.d.ts +238 -2
- package/dist/index.js +112 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -132,12 +132,15 @@ var APIError = class extends Error {
|
|
|
132
132
|
code;
|
|
133
133
|
status;
|
|
134
134
|
details;
|
|
135
|
-
|
|
135
|
+
/** The decoded error body as the server sent it, for errors whose details are top-level fields. */
|
|
136
|
+
body;
|
|
137
|
+
constructor(status, data, body) {
|
|
136
138
|
super(data.message || data.error);
|
|
137
139
|
this.name = "APIError";
|
|
138
140
|
this.code = data.error;
|
|
139
141
|
this.status = status;
|
|
140
142
|
this.details = data.details;
|
|
143
|
+
this.body = body;
|
|
141
144
|
}
|
|
142
145
|
};
|
|
143
146
|
function isExpiringSoon(token, thresholdSeconds) {
|
|
@@ -383,7 +386,7 @@ var APIClient = class {
|
|
|
383
386
|
} catch {
|
|
384
387
|
decoded = null;
|
|
385
388
|
}
|
|
386
|
-
throw new APIError(response.status, normalizeAPIErrorResponse(decoded, response.statusText));
|
|
389
|
+
throw new APIError(response.status, normalizeAPIErrorResponse(decoded, response.statusText), decoded ?? void 0);
|
|
387
390
|
}
|
|
388
391
|
return response;
|
|
389
392
|
}
|
|
@@ -2102,12 +2105,57 @@ var CartModule = class {
|
|
|
2102
2105
|
}
|
|
2103
2106
|
/**
|
|
2104
2107
|
* Checkout the cart — creates orders grouped by store and clears the cart.
|
|
2108
|
+
* @deprecated Use `sdk.checkouts.create`: checkout needs an address, an idempotency key and a
|
|
2109
|
+
* delivery quote per shop, and returns the checkout with its totals.
|
|
2105
2110
|
*/
|
|
2106
2111
|
async checkout(options) {
|
|
2107
2112
|
return this.client.post("/orders/checkout", void 0, options);
|
|
2108
2113
|
}
|
|
2109
2114
|
};
|
|
2110
2115
|
|
|
2116
|
+
// src/modules/checkouts.ts
|
|
2117
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([
|
|
2118
|
+
"invalid_input",
|
|
2119
|
+
"empty_cart",
|
|
2120
|
+
"cannot_buy_own",
|
|
2121
|
+
"invalid_deliveries",
|
|
2122
|
+
"address_not_found",
|
|
2123
|
+
"idempotency_conflict",
|
|
2124
|
+
"listing_unavailable",
|
|
2125
|
+
"mixed_market_cart",
|
|
2126
|
+
"market_not_active",
|
|
2127
|
+
"checkout_payment_in_progress",
|
|
2128
|
+
"delivery_quote_rejected",
|
|
2129
|
+
"address_region_invalid",
|
|
2130
|
+
"delivery_required",
|
|
2131
|
+
"delivery_quotes_unavailable"
|
|
2132
|
+
]);
|
|
2133
|
+
function checkoutRefusal(error) {
|
|
2134
|
+
if (!(error instanceof APIError)) return null;
|
|
2135
|
+
const body = error.body;
|
|
2136
|
+
if (typeof body !== "object" || body === null) return null;
|
|
2137
|
+
const code = body.error;
|
|
2138
|
+
if (typeof code !== "string" || !REFUSAL_CODES.has(code)) return null;
|
|
2139
|
+
return body;
|
|
2140
|
+
}
|
|
2141
|
+
var CheckoutsModule = class {
|
|
2142
|
+
constructor(client) {
|
|
2143
|
+
this.client = client;
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* Create a checkout from the buyer's cart: one order per shop, each at the delivery quote picked
|
|
2147
|
+
* for it, held until the checkout's due-by. A retry with the same `idempotency_key` returns the
|
|
2148
|
+
* same checkout. A refusal throws an `APIError`; read it with `checkoutRefusal(error)`.
|
|
2149
|
+
*/
|
|
2150
|
+
async create(input, options) {
|
|
2151
|
+
return this.client.post("/orders/checkout", input, options);
|
|
2152
|
+
}
|
|
2153
|
+
/** Read one of the buyer's checkouts. Anyone else gets a 404. */
|
|
2154
|
+
async get(checkoutId, options) {
|
|
2155
|
+
return this.client.get(`/orders/checkouts/${encodeURIComponent(checkoutId)}`, void 0, options);
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2111
2159
|
// src/modules/settings.ts
|
|
2112
2160
|
var SettingsModule = class {
|
|
2113
2161
|
constructor(client) {
|
|
@@ -2424,6 +2472,24 @@ var AdminModule = class {
|
|
|
2424
2472
|
async resolveMessageReport(reportId, input, options) {
|
|
2425
2473
|
return this.client.post(`/admin/message-reports/${encodeURIComponent(reportId)}/resolve`, input, options);
|
|
2426
2474
|
}
|
|
2475
|
+
// ── Platform settings ──
|
|
2476
|
+
/** Every platform setting with its current value and whether it can be changed here. Requires `admin:read`. */
|
|
2477
|
+
async listSettings(options) {
|
|
2478
|
+
return this.client.get("/admin/settings", void 0, options);
|
|
2479
|
+
}
|
|
2480
|
+
/** One setting and its change history, newest first. Requires `admin:read`. */
|
|
2481
|
+
async getSetting(key, options) {
|
|
2482
|
+
return this.client.get(`/admin/settings/${encodeURIComponent(key)}`, void 0, options);
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Change an editable setting. Requires `roles:grant` and a recent passkey (403
|
|
2486
|
+
* `reauthentication_required` otherwise). Errors: 403 `not_editable` for payment and messaging
|
|
2487
|
+
* settings, 400 `invalid_value`, 409 `would_lock_you_out` when an operator-domain change would
|
|
2488
|
+
* remove the caller's own domain. Recorded on the audit trail as `config.changed`.
|
|
2489
|
+
*/
|
|
2490
|
+
async changeSetting(key, input, options) {
|
|
2491
|
+
return this.client.put(`/admin/settings/${encodeURIComponent(key)}`, input, options);
|
|
2492
|
+
}
|
|
2427
2493
|
// ── VAZI Moderation ──
|
|
2428
2494
|
async listVaziOutfits(params, options) {
|
|
2429
2495
|
return this.client.get("/admin/vazi/outfits", params, options);
|
|
@@ -2834,6 +2900,46 @@ var IamModule = class {
|
|
|
2834
2900
|
async me(options) {
|
|
2835
2901
|
return this.client.get("/auth/iam/me", void 0, options);
|
|
2836
2902
|
}
|
|
2903
|
+
// ── Sessions and sign-in history ──
|
|
2904
|
+
/** This IAM user's live sessions, most recently active first; `current` marks this one. */
|
|
2905
|
+
async listSessions(options) {
|
|
2906
|
+
return this.client.get("/auth/iam/sessions", void 0, options);
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* End one of this IAM user's sessions. It can no longer be renewed; its current access lapses
|
|
2910
|
+
* within 15 minutes. 404 for a session that does not exist or is not this user's.
|
|
2911
|
+
*/
|
|
2912
|
+
async endSession(sessionId, options) {
|
|
2913
|
+
return this.client.post(`/auth/iam/sessions/${encodeURIComponent(sessionId)}/revoke`, void 0, options);
|
|
2914
|
+
}
|
|
2915
|
+
/** This IAM user's recent sign-in attempts, newest first, successful and refused (at most 100). */
|
|
2916
|
+
async listSignIns(params, options) {
|
|
2917
|
+
return this.client.get("/auth/iam/signins", params, options);
|
|
2918
|
+
}
|
|
2919
|
+
/** An IAM user's live sessions. Requires `roles:grant`; IAM users cannot call it. */
|
|
2920
|
+
async listUserSessions(orgId, iamUserId, options) {
|
|
2921
|
+
return this.client.get(`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/sessions`, void 0, options);
|
|
2922
|
+
}
|
|
2923
|
+
/** End one of an IAM user's sessions (its current access lapses within 15 minutes). Requires `roles:grant`. */
|
|
2924
|
+
async endUserSession(orgId, iamUserId, sessionId, options) {
|
|
2925
|
+
return this.client.post(
|
|
2926
|
+
`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/sessions/${encodeURIComponent(sessionId)}/revoke`,
|
|
2927
|
+
void 0,
|
|
2928
|
+
options
|
|
2929
|
+
);
|
|
2930
|
+
}
|
|
2931
|
+
/** Sign an IAM user out of every device now, without disabling them. Requires `roles:grant`. */
|
|
2932
|
+
async endAllUserSessions(orgId, iamUserId, options) {
|
|
2933
|
+
return this.client.post(`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/sessions/revoke-all`, void 0, options);
|
|
2934
|
+
}
|
|
2935
|
+
/** An IAM user's recent sign-in attempts, successful and refused. Requires `roles:grant`. */
|
|
2936
|
+
async listUserSignIns(orgId, iamUserId, params, options) {
|
|
2937
|
+
return this.client.get(
|
|
2938
|
+
`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/signins`,
|
|
2939
|
+
params,
|
|
2940
|
+
options
|
|
2941
|
+
);
|
|
2942
|
+
}
|
|
2837
2943
|
/** List this IAM principal's enrolled second-factor methods. */
|
|
2838
2944
|
async listMethods(options) {
|
|
2839
2945
|
return this.client.get("/auth/iam/2fa/methods", void 0, options);
|
|
@@ -3138,6 +3244,7 @@ var MitumbaClient = class {
|
|
|
3138
3244
|
reviews;
|
|
3139
3245
|
wishlists;
|
|
3140
3246
|
cart;
|
|
3247
|
+
checkouts;
|
|
3141
3248
|
settings;
|
|
3142
3249
|
mailer;
|
|
3143
3250
|
businesses;
|
|
@@ -3163,6 +3270,7 @@ var MitumbaClient = class {
|
|
|
3163
3270
|
this.reviews = new ReviewsModule(this.api);
|
|
3164
3271
|
this.wishlists = new WishlistsModule(this.api);
|
|
3165
3272
|
this.cart = new CartModule(this.api);
|
|
3273
|
+
this.checkouts = new CheckoutsModule(this.api);
|
|
3166
3274
|
this.settings = new SettingsModule(this.api);
|
|
3167
3275
|
this.mailer = new MailerModule(this.api);
|
|
3168
3276
|
this.businesses = new BusinessesModule(this.api);
|
|
@@ -3213,6 +3321,6 @@ var MitumbaClient = class {
|
|
|
3213
3321
|
}
|
|
3214
3322
|
};
|
|
3215
3323
|
|
|
3216
|
-
export { APIClient, APIError, AdminModule, AuthModule, BALE_ORDER_STATUSES, BusinessesModule, CONDITIONS, CartModule, 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, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
|
|
3324
|
+
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, checkoutRefusal, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
|
|
3217
3325
|
//# sourceMappingURL=index.mjs.map
|
|
3218
3326
|
//# sourceMappingURL=index.mjs.map
|