@mitumba/sdk 1.32.1 → 2.0.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 +104 -32
- package/dist/index.d.ts +104 -32
- package/dist/index.js +61 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1400,61 +1400,23 @@ var MessagesModule = class {
|
|
|
1400
1400
|
this.client = client;
|
|
1401
1401
|
}
|
|
1402
1402
|
client;
|
|
1403
|
-
/**
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
);
|
|
1403
|
+
/**
|
|
1404
|
+
* Create a bilateral block from a v2 inbox perspective. A buyer blocks a store (`{ store_id }`);
|
|
1405
|
+
* a store blocks a buyer (`{ buyer_id }`). Idempotent.
|
|
1406
|
+
*/
|
|
1407
|
+
async createMessagingBlock(perspective, input, options) {
|
|
1408
|
+
const value = await this.client.post(`${perspectiveBase(perspective)}/blocks`, input, options);
|
|
1409
|
+
return unwrap(value, isIdentified);
|
|
1410
1410
|
}
|
|
1411
|
-
/**
|
|
1412
|
-
async
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
storeId ? { store_id: storeId } : void 0,
|
|
1416
|
-
options
|
|
1417
|
-
);
|
|
1411
|
+
/** Remove a block the current perspective created. */
|
|
1412
|
+
async removeMessagingBlock(perspective, blockId, options) {
|
|
1413
|
+
const value = await this.client.delete(`${perspectiveBase(perspective)}/blocks/${encode(blockId)}`, void 0, options);
|
|
1414
|
+
return unwrap(value, isRecord2);
|
|
1418
1415
|
}
|
|
1419
|
-
/**
|
|
1420
|
-
async
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
/** @deprecated Use advanceThreadReadCursor for precise monotonic state. */
|
|
1424
|
-
async markRead(partnerId, storeId, options) {
|
|
1425
|
-
const path = storeId ? `/notify/messages/${partnerId}/read?store_id=${storeId}` : `/notify/messages/${partnerId}/read`;
|
|
1426
|
-
return this.client.post(path, void 0, options);
|
|
1427
|
-
}
|
|
1428
|
-
/** @deprecated Use managed messaging realtime. */
|
|
1429
|
-
connectTyping(partnerId) {
|
|
1430
|
-
const token = this.client.getToken();
|
|
1431
|
-
const wsUrl = this.client.getBaseUrl().replace(/^http/, "ws") + `/notify/messages/${partnerId}/ws?token=${token}`;
|
|
1432
|
-
return new WebSocket(wsUrl);
|
|
1433
|
-
}
|
|
1434
|
-
/** @deprecated Use managed messaging realtime. */
|
|
1435
|
-
connectInbox() {
|
|
1436
|
-
const token = this.client.getToken();
|
|
1437
|
-
const wsUrl = this.client.getBaseUrl().replace(/^http/, "ws") + `/notify/messages/inbox?token=${token}`;
|
|
1438
|
-
return new WebSocket(wsUrl);
|
|
1439
|
-
}
|
|
1440
|
-
/** Create a legacy inbox socket only after hydrating/refreshing the access token. */
|
|
1441
|
-
async connectInboxFresh(options) {
|
|
1442
|
-
await this.client.ensureFreshToken(options);
|
|
1443
|
-
const token = this.client.getToken() ?? "";
|
|
1444
|
-
const wsUrl = this.client.getBaseUrl().replace(/^http/, "ws") + `/notify/messages/inbox?token=${encode(token)}`;
|
|
1445
|
-
return this.client.createWebSocket(wsUrl, []);
|
|
1446
|
-
}
|
|
1447
|
-
/** Create a report for a message or conversation. */
|
|
1448
|
-
async createReport(input, options) {
|
|
1449
|
-
return this.client.post("/notify/messages/reports", input, options);
|
|
1450
|
-
}
|
|
1451
|
-
/** Create an idempotent bilateral buyer/store relationship block. */
|
|
1452
|
-
async createBlock(input, options) {
|
|
1453
|
-
return this.client.post("/notify/messages/blocks", input, options);
|
|
1454
|
-
}
|
|
1455
|
-
/** Remove a block created by the current perspective. */
|
|
1456
|
-
async removeBlock(blockId, options) {
|
|
1457
|
-
return this.client.delete(`/notify/messages/blocks/${encode(blockId)}`, void 0, options);
|
|
1416
|
+
/** File a message or conversation report from a v2 inbox perspective. Idempotent on open reports. */
|
|
1417
|
+
async createMessagingReport(perspective, input, options) {
|
|
1418
|
+
const value = await this.client.post(`${perspectiveBase(perspective)}/reports`, input, options);
|
|
1419
|
+
return unwrap(value, isIdentified);
|
|
1458
1420
|
}
|
|
1459
1421
|
/** Discover server messaging capabilities. */
|
|
1460
1422
|
async getMessagingCapabilities(options) {
|
|
@@ -2313,6 +2275,33 @@ var WholesaleModule = class {
|
|
|
2313
2275
|
async myBales(options) {
|
|
2314
2276
|
return this.client.get("/listings/wholesale/mine/bales", void 0, options);
|
|
2315
2277
|
}
|
|
2278
|
+
// ── Bale Images ──
|
|
2279
|
+
/**
|
|
2280
|
+
* Presign a bale image upload slot (requires the owning wholesale store).
|
|
2281
|
+
*
|
|
2282
|
+
* @param baleId - The bale to attach the image to
|
|
2283
|
+
* @param index - The slot index; slot 0 is the cover
|
|
2284
|
+
* @returns The storage key and image id for the slot
|
|
2285
|
+
* @throws {APIError} On network or server errors
|
|
2286
|
+
*/
|
|
2287
|
+
async presignBaleImage(baleId, index, options) {
|
|
2288
|
+
return this.client.post(`/listings/bales/${baleId}/images/presign`, { index }, options);
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Upload a bale image file directly. Uses multipart/form-data. Slot 0 is the cover.
|
|
2292
|
+
*
|
|
2293
|
+
* @param baleId - The bale to attach the image to
|
|
2294
|
+
* @param file - The image file as a `Blob` (React Native passes a `{ uri, name, type }` part)
|
|
2295
|
+
* @param index - The slot index; slot 0 is the cover
|
|
2296
|
+
* @returns The storage key, image id, and public URL
|
|
2297
|
+
* @throws {APIError} On network or server errors
|
|
2298
|
+
*/
|
|
2299
|
+
async uploadBaleImage(baleId, file, index, options) {
|
|
2300
|
+
const formData = new FormData();
|
|
2301
|
+
formData.append("file", file);
|
|
2302
|
+
formData.append("index", String(index));
|
|
2303
|
+
return this.client.post(`/listings/bales/${baleId}/images/upload`, formData, options);
|
|
2304
|
+
}
|
|
2316
2305
|
// ── Feed ──
|
|
2317
2306
|
/** Browse the wholesale bale feed (public). */
|
|
2318
2307
|
async wholesaleFeed(params, options) {
|
|
@@ -2343,6 +2332,25 @@ var WholesaleModule = class {
|
|
|
2343
2332
|
async transitionBaleOrder(id, action, options) {
|
|
2344
2333
|
return this.client.post(`/listings/bale-orders/${id}/transition`, { action }, options);
|
|
2345
2334
|
}
|
|
2335
|
+
// ── Analytics ──
|
|
2336
|
+
/**
|
|
2337
|
+
* Get performance analytics for the current user's wholesale store (bale_seller only).
|
|
2338
|
+
*
|
|
2339
|
+
* The wholesale store is resolved server-side from the session, so no store id is passed — the
|
|
2340
|
+
* same way `getWholesaleStore`, `myBales`, and `incomingBaleOrders` work.
|
|
2341
|
+
*
|
|
2342
|
+
* @param period - Optional granularity; defaults to the server's default window
|
|
2343
|
+
* @returns Revenue series, order breakdown, top bales, and totals
|
|
2344
|
+
* @throws {APIError} On network or server errors
|
|
2345
|
+
*
|
|
2346
|
+
* @example
|
|
2347
|
+
* ```typescript
|
|
2348
|
+
* const analytics = await sdk.wholesale.getAnalytics('weekly')
|
|
2349
|
+
* ```
|
|
2350
|
+
*/
|
|
2351
|
+
async getAnalytics(period, options) {
|
|
2352
|
+
return this.client.get("/listings/wholesale/analytics", period ? { period } : void 0, options);
|
|
2353
|
+
}
|
|
2346
2354
|
};
|
|
2347
2355
|
|
|
2348
2356
|
// src/types/auth.ts
|