@supsis/supsis-js 1.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/supsis.cjs.js +4069 -0
- package/dist/supsis.d.ts +599 -0
- package/dist/supsis.esm.js +4045 -0
- package/dist/supsis.js +4075 -0
- package/dist/supsis.min.js +38 -0
- package/dist/supsis.min.js.map +1 -0
- package/package.json +57 -0
- package/readme.md +375 -0
- package/types/index.d.ts +599 -0
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supsis/supsis-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Supsis API SDK - Browser ve Node.js için omnichannel messaging, chatbot, automation, task, ticket ve voice agent entegrasyonu",
|
|
5
|
+
"main": "dist/supsis.cjs.js",
|
|
6
|
+
"module": "dist/supsis.esm.js",
|
|
7
|
+
"browser": "dist/supsis.min.js",
|
|
8
|
+
"types": "dist/supsis.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"types",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rollup -c",
|
|
16
|
+
"build:watch": "rollup -c -w",
|
|
17
|
+
"build:types": "node scripts/build-types.js",
|
|
18
|
+
"publish:npm": "./scripts/publish-npm.sh",
|
|
19
|
+
"upload:s3": "./scripts/upload-s3.sh",
|
|
20
|
+
"release": "npm run build && npm run build:types && npm run publish:npm && npm run upload:s3",
|
|
21
|
+
"release:s3": "npm run build && npm run build:types && npm run upload:s3",
|
|
22
|
+
"release:npm": "npm run build && npm run build:types && npm run publish:npm"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/nictonik/supsis-js.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"supsis",
|
|
30
|
+
"omnichannel",
|
|
31
|
+
"messaging",
|
|
32
|
+
"chatbot",
|
|
33
|
+
"automation",
|
|
34
|
+
"whatsapp",
|
|
35
|
+
"instagram",
|
|
36
|
+
"live-chat",
|
|
37
|
+
"customer-support",
|
|
38
|
+
"crm",
|
|
39
|
+
"voice-agent",
|
|
40
|
+
"ai"
|
|
41
|
+
],
|
|
42
|
+
"author": "Supsis Ai <info@softcand.com>",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/nictonik/supsis-js/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://supsis.com",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
50
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
51
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
52
|
+
"rollup": "^4.9.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=14.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Supsis JS SDK
|
|
2
|
+
|
|
3
|
+
Supsis API'sine browser ve Node.js ortamlarından erişim sağlayan JavaScript SDK.
|
|
4
|
+
|
|
5
|
+
## Özellikler
|
|
6
|
+
|
|
7
|
+
- 🌐 **Çoklu Platform**: Browser (UMD) ve Node.js (CommonJS/ESM) desteği
|
|
8
|
+
- 📝 **TypeScript Desteği**: Tam TypeScript declaration dosyaları
|
|
9
|
+
- 🔒 **Güvenli**: Token tabanlı authentication
|
|
10
|
+
- 🔄 **Otomatik Retry**: Başarısız isteklerde otomatik yeniden deneme
|
|
11
|
+
- 📦 **Modüler**: Sadece ihtiyacınız olan modülleri kullanın
|
|
12
|
+
- 🤖 **LLM-Friendly**: Detaylı JSDoc açıklamaları
|
|
13
|
+
|
|
14
|
+
## Kurulum
|
|
15
|
+
|
|
16
|
+
### npm
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @supsis/supsis-js
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### CDN
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<!-- Latest -->
|
|
26
|
+
<script src="https://static.supsis.live/supsis-js/latest/supsis.min.js"></script>
|
|
27
|
+
|
|
28
|
+
<!-- Specific version -->
|
|
29
|
+
<script src="https://static.supsis.live/supsis-js/1.0.0/supsis.min.js"></script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Hızlı Başlangıç
|
|
33
|
+
|
|
34
|
+
### Browser
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<script src="https://static.supsis.live/supsis-js/latest/supsis.min.js"></script>
|
|
38
|
+
<script>
|
|
39
|
+
const supsis = new SupsisJS({
|
|
40
|
+
email: 'user@example.com',
|
|
41
|
+
password: 'secret',
|
|
42
|
+
siteId: 'site123'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
supsis.connect().then(async () => {
|
|
46
|
+
const chats = await supsis.chat.list({ status: 'active' });
|
|
47
|
+
console.log(chats);
|
|
48
|
+
});
|
|
49
|
+
</script>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Node.js (CommonJS)
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
const { SupsisJS } = require('@supsis/supsis-js');
|
|
56
|
+
|
|
57
|
+
const supsis = new SupsisJS({
|
|
58
|
+
email: 'user@example.com',
|
|
59
|
+
password: 'secret',
|
|
60
|
+
siteId: 'site123'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
await supsis.connect();
|
|
64
|
+
|
|
65
|
+
const chat = await supsis.chat.get('chatId');
|
|
66
|
+
const contacts = await supsis.contact.list({ limit: 10 });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Node.js (ESM)
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import { SupsisJS } from '@supsis/supsis-js';
|
|
73
|
+
|
|
74
|
+
const supsis = new SupsisJS({
|
|
75
|
+
email: 'user@example.com',
|
|
76
|
+
password: 'secret',
|
|
77
|
+
siteId: 'site123'
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await supsis.connect();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Konfigürasyon
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
const supsis = new SupsisJS({
|
|
87
|
+
// Zorunlu
|
|
88
|
+
email: 'user@example.com',
|
|
89
|
+
password: 'secret',
|
|
90
|
+
siteId: 'site123',
|
|
91
|
+
|
|
92
|
+
// Opsiyonel
|
|
93
|
+
env: 'production', // 'production' | 'stage' | 'local' (default: 'production')
|
|
94
|
+
baseApiAddress: null, // OnPrem için custom API URL
|
|
95
|
+
timeout: 30000, // HTTP timeout (ms)
|
|
96
|
+
retryCount: 3 // Başarısız isteklerde retry sayısı
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Ortamlar
|
|
101
|
+
|
|
102
|
+
| env | API URL |
|
|
103
|
+
|-----|---------|
|
|
104
|
+
| `production` | https://api.supsis.live |
|
|
105
|
+
| `stage` | https://beta-api.supsis.live |
|
|
106
|
+
| `local` | https://tablet-api-local.supsis.live |
|
|
107
|
+
|
|
108
|
+
### OnPrem Kullanımı
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
const supsis = new SupsisJS({
|
|
112
|
+
email: 'user@company.com',
|
|
113
|
+
password: 'secret',
|
|
114
|
+
siteId: 'site123',
|
|
115
|
+
baseApiAddress: 'https://api.company-supsis.com'
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Modüller
|
|
120
|
+
|
|
121
|
+
### Chat (Conversation)
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
// Chat getir
|
|
125
|
+
const chat = await supsis.chat.get('chatId');
|
|
126
|
+
|
|
127
|
+
// Chat listele
|
|
128
|
+
const chats = await supsis.chat.list({
|
|
129
|
+
status: 'active',
|
|
130
|
+
startDate: '2024-01-01',
|
|
131
|
+
limit: 20
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Chat mesajlarını getir
|
|
135
|
+
const messages = await supsis.chat.getMessages('chatId', { limit: 100 });
|
|
136
|
+
|
|
137
|
+
// Chat'e not ekle
|
|
138
|
+
await supsis.chat.addNote('chatId', 'Müşteri geri aranacak');
|
|
139
|
+
|
|
140
|
+
// Chat etiketlerini güncelle
|
|
141
|
+
await supsis.chat.updateTags('chatId', ['tagId1', 'tagId2']);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Contact (Visitor)
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
// Contact getir
|
|
148
|
+
const contact = await supsis.contact.get('contactId');
|
|
149
|
+
|
|
150
|
+
// Contact ara
|
|
151
|
+
const results = await supsis.contact.search({ email: 'user@example.com' });
|
|
152
|
+
|
|
153
|
+
// Contact oluştur
|
|
154
|
+
const newContact = await supsis.contact.create({
|
|
155
|
+
fullname: 'John Doe',
|
|
156
|
+
email: 'john@example.com',
|
|
157
|
+
phone: '+905551234567'
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Contact güncelle
|
|
161
|
+
await supsis.contact.update('contactId', { fullname: 'Jane Doe' });
|
|
162
|
+
|
|
163
|
+
// Etiket ekle/kaldır
|
|
164
|
+
await supsis.contact.addTag('contactId', 'tagId');
|
|
165
|
+
await supsis.contact.removeTag('contactId', 'tagId');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Message
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
// Mesaj getir
|
|
172
|
+
const message = await supsis.message.get('messageId');
|
|
173
|
+
|
|
174
|
+
// Sohbetteki mesajları listele
|
|
175
|
+
const messages = await supsis.message.list('conversationId', { limit: 50 });
|
|
176
|
+
|
|
177
|
+
// Mesajlarda ara
|
|
178
|
+
const results = await supsis.message.search({
|
|
179
|
+
query: 'sipariş numarası',
|
|
180
|
+
startDate: '2024-01-01'
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Task
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
// Görev oluştur
|
|
188
|
+
const task = await supsis.task.create({
|
|
189
|
+
title: 'Müşteriyi ara',
|
|
190
|
+
workflowId: 'workflowId',
|
|
191
|
+
pipelineId: 'pipelineId',
|
|
192
|
+
assignee: 'userId',
|
|
193
|
+
dueDate: '2024-12-31'
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Görevleri listele
|
|
197
|
+
const tasks = await supsis.task.list('workflowId');
|
|
198
|
+
|
|
199
|
+
// Görevi taşı
|
|
200
|
+
await supsis.task.move('taskId', 'newPipelineId');
|
|
201
|
+
|
|
202
|
+
// Görevi tamamla
|
|
203
|
+
await supsis.task.complete('taskId');
|
|
204
|
+
|
|
205
|
+
// İş akışlarını listele
|
|
206
|
+
const workflows = await supsis.task.listWorkflows();
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### AI Call (Voice Agent)
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
// Arama başlat
|
|
213
|
+
const call = await supsis.aicall.makeCall({
|
|
214
|
+
agentId: 'agentId',
|
|
215
|
+
toNumber: '+905551234567',
|
|
216
|
+
fromNumber: '+908501234567',
|
|
217
|
+
variables: {
|
|
218
|
+
customerName: 'John Doe'
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Arama detayını getir
|
|
223
|
+
const callDetails = await supsis.aicall.getCall('callId');
|
|
224
|
+
|
|
225
|
+
// Aramaları listele
|
|
226
|
+
const calls = await supsis.aicall.listCalls({
|
|
227
|
+
agentId: 'agentId',
|
|
228
|
+
status: 'ended'
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Table (CustomerTable)
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
// Tabloları listele
|
|
236
|
+
const tables = await supsis.table.list();
|
|
237
|
+
|
|
238
|
+
// Kayıtları listele
|
|
239
|
+
const records = await supsis.table.listRecords('tableId', {
|
|
240
|
+
filters: { status: 'active' },
|
|
241
|
+
limit: 50
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// Kayıt oluştur
|
|
245
|
+
const record = await supsis.table.createRecord('tableId', {
|
|
246
|
+
name: 'John Doe',
|
|
247
|
+
email: 'john@example.com'
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Module (Dynamic Modules)
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
// Modülleri listele
|
|
255
|
+
const modules = await supsis.module.list();
|
|
256
|
+
|
|
257
|
+
// Modül kayıtlarını listele
|
|
258
|
+
const leads = await supsis.module.listRecords('Leads', {
|
|
259
|
+
filters: { status: 'new' }
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Kayıt oluştur
|
|
263
|
+
const lead = await supsis.module.createRecord('Leads', {
|
|
264
|
+
name: 'John Doe',
|
|
265
|
+
company: 'ACME Corp'
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Cache
|
|
270
|
+
|
|
271
|
+
```javascript
|
|
272
|
+
// Cache yaz
|
|
273
|
+
await supsis.cache.write('user:123', { name: 'John' }, {
|
|
274
|
+
expiresIn: { value: 1, unit: 'hours' }
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// Cache oku
|
|
278
|
+
const data = await supsis.cache.read('user:123');
|
|
279
|
+
|
|
280
|
+
// Cache sil
|
|
281
|
+
await supsis.cache.delete('cacheId');
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### User
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
// Mevcut kullanıcı
|
|
288
|
+
const me = await supsis.user.me();
|
|
289
|
+
|
|
290
|
+
// Kullanıcıları listele
|
|
291
|
+
const users = await supsis.user.list();
|
|
292
|
+
|
|
293
|
+
// Logout
|
|
294
|
+
await supsis.user.logout();
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Tag
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
// Etiketleri listele
|
|
301
|
+
const tags = await supsis.tag.list();
|
|
302
|
+
|
|
303
|
+
// Etiket oluştur
|
|
304
|
+
const tag = await supsis.tag.create({
|
|
305
|
+
name: 'VIP',
|
|
306
|
+
color: '#FF0000',
|
|
307
|
+
type: 'visitor'
|
|
308
|
+
});
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Site
|
|
312
|
+
|
|
313
|
+
```javascript
|
|
314
|
+
// Özellikleri getir
|
|
315
|
+
const features = await supsis.site.getFeatures();
|
|
316
|
+
|
|
317
|
+
// Cüzdan bilgisi
|
|
318
|
+
const wallet = await supsis.site.getWallet();
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Module API (Developer Token)
|
|
322
|
+
|
|
323
|
+
Panelden alınan developer token ile kısıtlı API erişimi:
|
|
324
|
+
|
|
325
|
+
```javascript
|
|
326
|
+
const { SupsisModuleAPI } = require('@supsis/supsis-js');
|
|
327
|
+
|
|
328
|
+
const api = new SupsisModuleAPI({
|
|
329
|
+
accessToken: 'dev_token_xxx',
|
|
330
|
+
siteId: 'site123'
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
const records = await api.module.listRecords('Leads');
|
|
334
|
+
const tables = await api.table.list();
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Hata Yönetimi
|
|
338
|
+
|
|
339
|
+
```javascript
|
|
340
|
+
const { SupsisJS, SupsisAPIError } = require('@supsis/supsis-js');
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
const chat = await supsis.chat.get('invalidId');
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if (error instanceof SupsisAPIError) {
|
|
346
|
+
console.error('API Error:', error.message);
|
|
347
|
+
console.error('Status:', error.statusCode);
|
|
348
|
+
console.error('Response:', error.response);
|
|
349
|
+
} else {
|
|
350
|
+
throw error;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## TypeScript
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
import { SupsisJS, ChatResponse, ContactResponse } from '@supsis/supsis-js';
|
|
359
|
+
|
|
360
|
+
const supsis = new SupsisJS({
|
|
361
|
+
email: 'user@example.com',
|
|
362
|
+
password: 'secret',
|
|
363
|
+
siteId: 'site123'
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
await supsis.connect();
|
|
367
|
+
|
|
368
|
+
const chat: ChatResponse = await supsis.chat.get('chatId');
|
|
369
|
+
const contacts: ContactResponse[] = (await supsis.contact.list()).data;
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Lisans
|
|
373
|
+
|
|
374
|
+
MIT
|
|
375
|
+
|