@scryme/chat 2.91.27 → 2.91.29
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 +66 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# Scryme Chat TypeScript SDK (`@scryme/chat`)
|
|
2
2
|
|
|
3
|
-
A high-performance, developer-friendly, fully typed TypeScript/JavaScript SDK for interacting with the
|
|
3
|
+
A high-performance, developer-friendly, fully typed TypeScript/JavaScript SDK for interacting with the Scryme Chat V2 and V3 Enterprise APIs.
|
|
4
4
|
|
|
5
|
-
Designed primarily for backend integrations, servers, and automated Machine-to-Machine (M2M) environments, this SDK provides unmatched DX with automatic OAuth2 token management, dynamic API proxying, and fluent nested helper chains.
|
|
5
|
+
Designed primarily for backend integrations, servers, and automated Machine-to-Machine (M2M) environments, this SDK provides unmatched DX with automatic OAuth2 token management, dynamic API proxying, custom message builders, and fluent nested helper chains.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
- **OAuth2 Client Credentials Grant**: Built-in, fully automated caching and renewal of M2M access tokens with timing-safe, proactive expiration buffers.
|
|
12
|
-
- **Dynamic Method Proxying (`sdk.raw`)**: Automatic injection of Bearer token and Base URL headers into any of the
|
|
13
|
-
- **Fluent Nested Namespaces**: High-level, developer-friendly helper routes (`sdk.workspace`, `sdk.channel`, `sdk.message`,
|
|
12
|
+
- **Dynamic Method Proxying (`sdk.raw`)**: Automatic injection of Bearer token and Base URL headers into any of the generated V3 API endpoints with complete TypeScript autocompletion.
|
|
13
|
+
- **Fluent Nested Namespaces**: High-level, developer-friendly helper routes (`sdk.workspace`, `sdk.channel`, `sdk.message`, `sdk.webhooks`, `sdk.bot`) for seamless workspace, department, team, and member administration.
|
|
14
|
+
- **Custom Message Builders**: Type-safe helpers (`createCustomMessageSchema`, `createFormCustomMessageSchema`) for generating node-based interactive in-chat forms, surveys, and approval cards.
|
|
14
15
|
- **Isomorphic Support**: Works out-of-the-box in Node.js, Next.js (server/client), Vite, and React Native.
|
|
15
16
|
|
|
16
17
|
---
|
|
@@ -114,35 +115,73 @@ const channel = await sdk.workspace.channels.create('acme-corp', {
|
|
|
114
115
|
metadata: { department: 'eng' },
|
|
115
116
|
});
|
|
116
117
|
|
|
117
|
-
//
|
|
118
|
-
await sdk.channel.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
// Send a message to a channel with interactive buttons
|
|
119
|
+
await sdk.channel.message.create('channel_id_123', {
|
|
120
|
+
content: 'Please approve the deployment request',
|
|
121
|
+
messageType: 'approval',
|
|
122
|
+
metadata: {
|
|
123
|
+
callbackUrl: 'https://my-app.example.com/api/actions/callback',
|
|
124
|
+
},
|
|
125
|
+
actions: [
|
|
126
|
+
{ actionId: 'approve', label: 'Approve', style: 'primary' },
|
|
127
|
+
{ actionId: 'reject', label: 'Reject', style: 'danger' }
|
|
128
|
+
]
|
|
123
129
|
});
|
|
124
130
|
|
|
125
|
-
//
|
|
126
|
-
await sdk.channel.
|
|
127
|
-
|
|
128
|
-
role: 'moderator',
|
|
129
|
-
permissions: '2048',
|
|
130
|
-
});
|
|
131
|
+
// Fetch channel messages
|
|
132
|
+
const messages = await sdk.channel.message.list('channel_id_123', { limit: 10 });
|
|
133
|
+
```
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
#### Webhooks Management
|
|
136
|
+
```typescript
|
|
137
|
+
// List workspace webhooks
|
|
138
|
+
const webhooks = await sdk.webhooks.list('acme-corp');
|
|
139
|
+
|
|
140
|
+
// Create outgoing workspace webhook
|
|
141
|
+
const newWebhook = await sdk.webhooks.create('acme-corp', {
|
|
142
|
+
name: 'CI Notifier',
|
|
143
|
+
url: 'https://my-app.example.com/api/webhooks',
|
|
144
|
+
events: ['message.sent', 'message.action_response'],
|
|
135
145
|
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
136
149
|
|
|
137
|
-
|
|
150
|
+
### Custom Message Builders
|
|
138
151
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
Use `@scryme/chat` custom message builders to construct rich, interactive forms and surveys to attach to messages:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { createFormCustomMessageSchema } from '@scryme/chat';
|
|
156
|
+
|
|
157
|
+
const feedbackSchema = createFormCustomMessageSchema({
|
|
158
|
+
title: 'Quarterly Team Feedback',
|
|
159
|
+
description: 'Please submit your thoughts on team performance',
|
|
160
|
+
icon: 'HelpCircle',
|
|
161
|
+
inputs: [
|
|
162
|
+
{
|
|
163
|
+
id: 'rating',
|
|
164
|
+
label: 'Performance Rating (1-5)',
|
|
165
|
+
placeholder: 'Enter 1 to 5',
|
|
166
|
+
required: true,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'comments',
|
|
170
|
+
label: 'Additional Comments',
|
|
171
|
+
placeholder: 'Optional feedback...',
|
|
172
|
+
multiline: true,
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
submitLabel: 'Send Feedback',
|
|
176
|
+
callbackId: 'team-feedback-submit',
|
|
142
177
|
});
|
|
143
178
|
|
|
144
|
-
//
|
|
145
|
-
|
|
179
|
+
// Send the custom form message to a channel
|
|
180
|
+
await sdk.channel.message.create('channel_id_123', {
|
|
181
|
+
content: 'New feedback survey',
|
|
182
|
+
messageType: 'custom',
|
|
183
|
+
metadata: feedbackSchema,
|
|
184
|
+
});
|
|
146
185
|
```
|
|
147
186
|
|
|
148
187
|
---
|
|
@@ -165,7 +204,7 @@ const users = await sdk.raw.usersControllerSearchUsers({ q: 'alice' });
|
|
|
165
204
|
|
|
166
205
|
// Fully typed update workspace webhook call
|
|
167
206
|
const webhook = await sdk.raw.v3WebhooksControllerCreateWebhook('acme-corp', {
|
|
168
|
-
name: 'Slack Sync
|
|
207
|
+
name: 'Slack Sync',
|
|
169
208
|
url: 'https://hooks.slack.com/services/...',
|
|
170
209
|
events: ['message.created'],
|
|
171
210
|
});
|
|
@@ -189,4 +228,4 @@ pnpm test
|
|
|
189
228
|
|
|
190
229
|
## License
|
|
191
230
|
|
|
192
|
-
MIT ©
|
|
231
|
+
MIT © Scryme Chat Enterprise
|