@medalsocial/sdk 1.3.0 → 1.5.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/README.md +33 -1
- package/dist/openapi/medal-social.openapi.json +553 -40
- package/dist/pilot/index.d.mts +64 -324
- package/dist/pilot/index.d.ts +64 -324
- package/dist/pilot/index.js +5 -5
- package/dist/pilot/index.js.map +1 -1
- package/dist/pilot/index.mjs +5 -5
- package/dist/pilot/index.mjs.map +1 -1
- package/dist/src/index.d.mts +184 -5
- package/dist/src/index.d.ts +184 -5
- package/dist/src/index.js +71 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +70 -2
- package/dist/src/index.mjs.map +1 -1
- package/dist/src/openapi.generated.d.mts +305 -1
- package/dist/src/openapi.generated.d.ts +305 -1
- package/dist/src/openapi.generated.js.map +1 -1
- package/openapi/medal-social.openapi.yaml +315 -3
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -298,6 +298,36 @@ await medal.webhooks.test(endpoint.id); // queues a 'test.ping' delivery
|
|
|
298
298
|
|
|
299
299
|
Failed deliveries retry with exponential backoff (up to 6 attempts) before being dead-lettered.
|
|
300
300
|
|
|
301
|
+
### Channels (partner connect)
|
|
302
|
+
|
|
303
|
+
Mint hosted connect links that let an external person — e.g. a partner's operator, with no Medal account — attach a channel account (today `telegram_inbox`) to the workspace's helpdesk, then track and disconnect the resulting connections. Requires the `channel.connect.manage` scope; OAuth callers additionally need the workspace `admin` role for the writes.
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
// Mint a single-use hosted connect link. `data.url` carries the one-time link
|
|
307
|
+
// token EXACTLY ONCE — an idempotent replay (same Idempotency-Key) omits it,
|
|
308
|
+
// so store it immediately (or revoke and mint a new link if lost).
|
|
309
|
+
const { data: link } = await medal.channels.connectLinks.create(
|
|
310
|
+
{
|
|
311
|
+
channel_type: 'telegram_inbox',
|
|
312
|
+
label: 'Acme support', // shown on the hosted page
|
|
313
|
+
redirect_url: 'https://partner.example.com/done', // optional, https only
|
|
314
|
+
},
|
|
315
|
+
{ idempotencyKey: crypto.randomUUID() },
|
|
316
|
+
);
|
|
317
|
+
console.log(link.url); // send this to the person who should connect
|
|
318
|
+
|
|
319
|
+
// Track links (tokens are never returned) and revoke unused ones
|
|
320
|
+
const { data: links } = await medal.channels.connectLinks.list({ status: 'pending' });
|
|
321
|
+
await medal.channels.connectLinks.revoke(link.id);
|
|
322
|
+
|
|
323
|
+
// List the workspace's channel connections and disconnect one
|
|
324
|
+
const { data: connections } = await medal.channels.connections.list();
|
|
325
|
+
// state: 'connecting' | 'active' | 'disconnected' | 'disabled'
|
|
326
|
+
await medal.channels.connections.disconnect(connections[0].id);
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
When the person completes the hosted sign-in, the link flips to `consumed` and your webhook endpoint receives `helpdesk.channel_connected` (subscribe via the Webhooks resource above); disconnects emit `helpdesk.channel_disconnected` with a `reason`. Inbound messages on the connected account then flow into the helpdesk — consume them via `helpdesk.message_received` and reply with `medal.helpdesk.replies.create`.
|
|
330
|
+
|
|
301
331
|
### Workspaces
|
|
302
332
|
|
|
303
333
|
```ts
|
|
@@ -365,7 +395,9 @@ export async function handleWebhook(request: Request): Promise<Response> {
|
|
|
365
395
|
}
|
|
366
396
|
```
|
|
367
397
|
|
|
368
|
-
Event types: `helpdesk.conversation_created`, `helpdesk.conversation_assigned`, `helpdesk.conversation_status_changed`, `helpdesk.message_received`, `helpdesk.message_sent`, `helpdesk.message_delivery_updated`, and `test.ping`. All are discriminated on `event.type` — TypeScript narrows `event.data` automatically in a `switch`.
|
|
398
|
+
Event types: `helpdesk.conversation_created`, `helpdesk.conversation_assigned`, `helpdesk.conversation_status_changed`, `helpdesk.message_received`, `helpdesk.message_sent`, `helpdesk.message_delivery_updated`, `helpdesk.channel_connected`, `helpdesk.channel_disconnected`, and `test.ping`. All are discriminated on `event.type` — TypeScript narrows `event.data` automatically in a `switch`.
|
|
399
|
+
|
|
400
|
+
Channel lifecycle events (`helpdesk.channel_connected` / `helpdesk.channel_disconnected`) fire when a channel account is attached to or removed from the workspace — e.g. via a partner connect link (see the Channels resource above). Their `data` is channel-generic: `channel`, `channelConnectionId`, `channel_type`, `connection_ref`, `label`, `masked_identity`, and (disconnect only) `reason` — one of `api_disconnect`, `user_revoked`, `member_disconnect`.
|
|
369
401
|
|
|
370
402
|
Notes:
|
|
371
403
|
|