@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/types/index.d.ts
ADDED
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supsis JS SDK TypeScript Definitions
|
|
3
|
+
* @module @supsis/supsis-js
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ==================== CONFIG TYPES ====================
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* SupsisJS konfigürasyon seçenekleri
|
|
11
|
+
*/
|
|
12
|
+
export interface SupsisConfig {
|
|
13
|
+
/** Kullanıcı email adresi */
|
|
14
|
+
email: string;
|
|
15
|
+
/** Kullanıcı şifresi */
|
|
16
|
+
password: string;
|
|
17
|
+
/** Site ID (multi-tenant) */
|
|
18
|
+
siteId: string;
|
|
19
|
+
/** Ortam: 'production' (default), 'stage', 'local' */
|
|
20
|
+
env?: 'production' | 'stage' | 'local';
|
|
21
|
+
/** Custom API adresi (OnPrem için) */
|
|
22
|
+
baseApiAddress?: string;
|
|
23
|
+
/** HTTP istek timeout süresi (ms) - default: 30000 */
|
|
24
|
+
timeout?: number;
|
|
25
|
+
/** Başarısız isteklerde retry sayısı - default: 3 */
|
|
26
|
+
retryCount?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* SupsisModuleAPI konfigürasyon seçenekleri
|
|
31
|
+
*/
|
|
32
|
+
export interface ModuleAPIConfig {
|
|
33
|
+
/** Developer access token (panelden alınır) */
|
|
34
|
+
accessToken: string;
|
|
35
|
+
/** Site ID (multi-tenant) */
|
|
36
|
+
siteId: string;
|
|
37
|
+
/** Ortam: 'production' (default), 'stage', 'local' */
|
|
38
|
+
env?: 'production' | 'stage' | 'local';
|
|
39
|
+
/** Custom API adresi (OnPrem için) */
|
|
40
|
+
baseApiAddress?: string;
|
|
41
|
+
/** HTTP istek timeout süresi (ms) */
|
|
42
|
+
timeout?: number;
|
|
43
|
+
/** Başarısız isteklerde retry sayısı */
|
|
44
|
+
retryCount?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ==================== RESPONSE TYPES ====================
|
|
48
|
+
|
|
49
|
+
export interface UserResponse {
|
|
50
|
+
_id: string;
|
|
51
|
+
siteId: string;
|
|
52
|
+
fullname: string;
|
|
53
|
+
email: string;
|
|
54
|
+
role?: string;
|
|
55
|
+
subjects?: string[];
|
|
56
|
+
status: 'Online' | 'Offline' | 'Away' | 'Busy';
|
|
57
|
+
isOnline: boolean;
|
|
58
|
+
profilePicture?: string;
|
|
59
|
+
createdDate: Date;
|
|
60
|
+
lastLoginDate?: Date;
|
|
61
|
+
permissions?: Record<string, boolean>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ChatResponse {
|
|
65
|
+
_id: string;
|
|
66
|
+
siteId: string;
|
|
67
|
+
status: 'new' | 'active' | 'lost' | 'destroyed' | 'chatbot' | 'private';
|
|
68
|
+
visitor: ContactResponse;
|
|
69
|
+
users: string[];
|
|
70
|
+
channel?: string;
|
|
71
|
+
ref?: 'whatsapp' | 'instagram' | 'telegram' | 'web' | 'messenger' | 'trendyol' | 'linkedin';
|
|
72
|
+
createdDate: Date;
|
|
73
|
+
destroyedDate?: Date;
|
|
74
|
+
point?: number;
|
|
75
|
+
description?: string;
|
|
76
|
+
note?: { representativeNote?: string; representativeName?: string };
|
|
77
|
+
tags?: string[];
|
|
78
|
+
handledBy?: 'chatbot' | 'live' | 'hybrid' | 'none';
|
|
79
|
+
avgResponseTime?: number;
|
|
80
|
+
firstAgentResponseTime?: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ContactResponse {
|
|
84
|
+
_id: string;
|
|
85
|
+
siteId: string;
|
|
86
|
+
fullname?: string;
|
|
87
|
+
email?: string;
|
|
88
|
+
phone?: string;
|
|
89
|
+
owner?: string;
|
|
90
|
+
tags?: string[];
|
|
91
|
+
platform?: string;
|
|
92
|
+
contactProperties?: Record<string, any>;
|
|
93
|
+
status?: 'online' | 'offline' | 'blocked';
|
|
94
|
+
createdDate: Date;
|
|
95
|
+
lastSeenDate?: Date;
|
|
96
|
+
lastConversation?: Partial<ChatResponse>;
|
|
97
|
+
whatsappNumber?: string;
|
|
98
|
+
instagramUserId?: string;
|
|
99
|
+
geoLocation?: Record<string, any>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface MessageResponse {
|
|
103
|
+
_id: string;
|
|
104
|
+
siteId: string;
|
|
105
|
+
conversationId: string;
|
|
106
|
+
message: string;
|
|
107
|
+
senderType: 'visitor' | 'user' | 'system' | 'chatbot';
|
|
108
|
+
senderId?: string;
|
|
109
|
+
messageType: 'text' | 'image' | 'file' | 'audio' | 'video' | 'location' | 'template';
|
|
110
|
+
createdDate: Date;
|
|
111
|
+
asset?: AssetResponse;
|
|
112
|
+
location?: { lat: number; lng: number };
|
|
113
|
+
isRead?: boolean;
|
|
114
|
+
readDate?: Date;
|
|
115
|
+
status?: 'sent' | 'delivered' | 'read' | 'failed';
|
|
116
|
+
replyTo?: Partial<MessageResponse>;
|
|
117
|
+
metadata?: Record<string, any>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface TaskResponse {
|
|
121
|
+
_id: string;
|
|
122
|
+
siteId: string;
|
|
123
|
+
title: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
workflowId: string;
|
|
126
|
+
pipelineId: string;
|
|
127
|
+
assignee?: string;
|
|
128
|
+
contactId?: string;
|
|
129
|
+
status: 'open' | 'done' | 'archived';
|
|
130
|
+
priority?: 'low' | 'medium' | 'high' | 'urgent';
|
|
131
|
+
dueDate?: Date;
|
|
132
|
+
createdAt: Date;
|
|
133
|
+
completedAt?: Date;
|
|
134
|
+
customFields?: Record<string, any>;
|
|
135
|
+
position?: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface WorkflowResponse {
|
|
139
|
+
_id: string;
|
|
140
|
+
siteId: string;
|
|
141
|
+
name: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
color?: string;
|
|
144
|
+
createdAt: Date;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface PipelineResponse {
|
|
148
|
+
_id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
color?: string;
|
|
151
|
+
position: number;
|
|
152
|
+
workflowId: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface AssetResponse {
|
|
156
|
+
_id: string;
|
|
157
|
+
siteId: string;
|
|
158
|
+
path: string;
|
|
159
|
+
mime: string;
|
|
160
|
+
ext: string;
|
|
161
|
+
size: number;
|
|
162
|
+
platform?: string;
|
|
163
|
+
externalUrl?: string;
|
|
164
|
+
createdAt: Date;
|
|
165
|
+
updatedAt: Date;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface TagResponse {
|
|
169
|
+
_id: string;
|
|
170
|
+
siteId: string;
|
|
171
|
+
name: string;
|
|
172
|
+
color?: string;
|
|
173
|
+
type?: 'visitor' | 'conversation' | 'ticket';
|
|
174
|
+
createdAt: Date;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface TableResponse {
|
|
178
|
+
_id: string;
|
|
179
|
+
siteId: string;
|
|
180
|
+
name: string;
|
|
181
|
+
description?: string;
|
|
182
|
+
icon?: string;
|
|
183
|
+
createdAt: Date;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface FieldResponse {
|
|
187
|
+
_id: string;
|
|
188
|
+
name: string;
|
|
189
|
+
slug: string;
|
|
190
|
+
type: string;
|
|
191
|
+
options?: Record<string, any>;
|
|
192
|
+
position?: number;
|
|
193
|
+
required?: boolean;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface RecordResponse {
|
|
197
|
+
_id: string;
|
|
198
|
+
tableId: string;
|
|
199
|
+
data: Record<string, any>;
|
|
200
|
+
createdAt: Date;
|
|
201
|
+
updatedAt: Date;
|
|
202
|
+
createdBy?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface CacheResponse {
|
|
206
|
+
_id: string;
|
|
207
|
+
siteId: string;
|
|
208
|
+
key: string;
|
|
209
|
+
value: any;
|
|
210
|
+
type: 'public' | 'private';
|
|
211
|
+
dataType: string;
|
|
212
|
+
createdByActorType: 'chatbot' | 'automation' | 'api' | 'user';
|
|
213
|
+
createdByAutomation?: string;
|
|
214
|
+
createdByChatbot?: string;
|
|
215
|
+
createdByUser?: string;
|
|
216
|
+
expiresAt?: Date;
|
|
217
|
+
createdAt: Date;
|
|
218
|
+
updatedAt: Date;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface CallResponse {
|
|
222
|
+
call_id: string;
|
|
223
|
+
agent_id: string;
|
|
224
|
+
call_status: 'registered' | 'ongoing' | 'ended' | 'error';
|
|
225
|
+
from_number?: string;
|
|
226
|
+
to_number?: string;
|
|
227
|
+
start_timestamp?: number;
|
|
228
|
+
end_timestamp?: number;
|
|
229
|
+
duration_ms?: number;
|
|
230
|
+
transcript?: string;
|
|
231
|
+
call_analysis?: Record<string, any>;
|
|
232
|
+
recording_url?: string;
|
|
233
|
+
metadata?: Record<string, any>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ==================== PAGINATION ====================
|
|
237
|
+
|
|
238
|
+
export interface PaginationOptions {
|
|
239
|
+
page?: number;
|
|
240
|
+
limit?: number;
|
|
241
|
+
offset?: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface PaginatedResponse<T> {
|
|
245
|
+
data: T[];
|
|
246
|
+
total: number;
|
|
247
|
+
page?: number;
|
|
248
|
+
limit?: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ==================== FILTER TYPES ====================
|
|
252
|
+
|
|
253
|
+
export interface FilterGroup {
|
|
254
|
+
filters: Filter[];
|
|
255
|
+
logic: 'and' | 'or';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface Filter {
|
|
259
|
+
field: string;
|
|
260
|
+
operator: 'equals' | 'notEquals' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'after' | 'before' | 'isEmpty' | 'isNotEmpty';
|
|
261
|
+
value: any;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ==================== MODULE CLASSES ====================
|
|
265
|
+
|
|
266
|
+
export class Chat {
|
|
267
|
+
get(chatId: string): Promise<ChatResponse>;
|
|
268
|
+
getMessages(chatId: string, options?: { limit?: number; before?: string }): Promise<MessageResponse[]>;
|
|
269
|
+
getMessageHistory(chatId: string, options?: PaginationOptions): Promise<PaginatedResponse<MessageResponse>>;
|
|
270
|
+
list(options?: { status?: string; channel?: string; userId?: string; visitorId?: string; startDate?: Date | string; endDate?: Date | string } & PaginationOptions): Promise<PaginatedResponse<ChatResponse>>;
|
|
271
|
+
getStats(): Promise<{ activeChats: number; waitingChats: number; lostChats: number; totalChats: number }>;
|
|
272
|
+
addNote(chatId: string, note: string): Promise<ChatResponse>;
|
|
273
|
+
updateTags(chatId: string, tagIds: string[]): Promise<ChatResponse>;
|
|
274
|
+
rate(chatId: string, rating: number, comment?: string): Promise<ChatResponse>;
|
|
275
|
+
sendTranscript(chatId: string, email: string): Promise<{ success: boolean }>;
|
|
276
|
+
destroy(chatId: string): Promise<ChatResponse>;
|
|
277
|
+
getByUser(userId: string, options?: Record<string, any>): Promise<ChatResponse[]>;
|
|
278
|
+
getWhatsAppContactList(options?: Record<string, any>): Promise<any>;
|
|
279
|
+
getContactListByChannel(channelId: string, options?: PaginationOptions): Promise<any>;
|
|
280
|
+
getLastMessages(chatIds: string[]): Promise<Record<string, MessageResponse>>;
|
|
281
|
+
updateField(chatId: string, key: string, value: any): Promise<ChatResponse>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export class Contact {
|
|
285
|
+
get(contactId: string): Promise<ContactResponse>;
|
|
286
|
+
list(options?: { search?: string; owner?: string; tags?: string[]; channel?: string } & PaginationOptions): Promise<PaginatedResponse<ContactResponse>>;
|
|
287
|
+
search(filters: { email?: string; phone?: string; fullname?: string; query?: string }, options?: PaginationOptions): Promise<PaginatedResponse<ContactResponse>>;
|
|
288
|
+
advancedSearch(filterGroups: FilterGroup[], options?: PaginationOptions, projectionFields?: string[]): Promise<PaginatedResponse<ContactResponse>>;
|
|
289
|
+
create(data: { fullname: string; email?: string; phone?: string; platform?: string; channelIds?: string[]; contactProperties?: Record<string, any> }): Promise<ContactResponse>;
|
|
290
|
+
update(contactId: string, data: Partial<ContactResponse>): Promise<ContactResponse>;
|
|
291
|
+
delete(contactId: string): Promise<{ success: boolean }>;
|
|
292
|
+
deleteMany(contactIds: string[]): Promise<{ success: boolean; deletedCount: number }>;
|
|
293
|
+
addTag(contactId: string, tagId: string): Promise<ContactResponse>;
|
|
294
|
+
removeTag(contactId: string, tagId: string): Promise<ContactResponse>;
|
|
295
|
+
block(contactId: string, reason?: string): Promise<ContactResponse>;
|
|
296
|
+
unblock(contactId: string): Promise<ContactResponse>;
|
|
297
|
+
getChatHistory(contactId: string, options?: PaginationOptions): Promise<ChatResponse[]>;
|
|
298
|
+
getNotes(contactId: string): Promise<any[]>;
|
|
299
|
+
addNote(contactId: string, content: string): Promise<any>;
|
|
300
|
+
updateNote(contactId: string, noteId: string, content: string): Promise<any>;
|
|
301
|
+
deleteNote(noteId: string): Promise<{ success: boolean }>;
|
|
302
|
+
updateProperty(contactId: string, propertyId: string, value: any): Promise<ContactResponse>;
|
|
303
|
+
changeOwner(contactId: string, ownerId: string): Promise<ContactResponse>;
|
|
304
|
+
updatePreferredAgents(contactId: string, agentIds: string[]): Promise<ContactResponse>;
|
|
305
|
+
getMedia(contactId: string, options?: Record<string, any>): Promise<AssetResponse[]>;
|
|
306
|
+
merge(primaryContactId: string, secondaryContactId: string): Promise<ContactResponse>;
|
|
307
|
+
downloadExcel(filters?: Record<string, any>): Promise<Blob>;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export class Message {
|
|
311
|
+
get(messageId: string): Promise<MessageResponse>;
|
|
312
|
+
list(conversationId: string, options?: { limit?: number; before?: string; after?: string }): Promise<MessageResponse[]>;
|
|
313
|
+
search(options: { query: string; conversationId?: string; visitorId?: string; userId?: string; startDate?: Date | string; endDate?: Date | string } & PaginationOptions): Promise<PaginatedResponse<MessageResponse>>;
|
|
314
|
+
getMany(messageIds: string[]): Promise<MessageResponse[]>;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export class Task {
|
|
318
|
+
get(taskId: string): Promise<TaskResponse>;
|
|
319
|
+
list(workflowId: string, options?: { pipelineId?: string; assignee?: string; status?: string }): Promise<TaskResponse[]>;
|
|
320
|
+
create(data: { title: string; workflowId: string; pipelineId: string; description?: string; assignee?: string; dueDate?: Date | string; priority?: string; contactId?: string; customFields?: Record<string, any> }): Promise<TaskResponse>;
|
|
321
|
+
createSimple(data: { title: string; workflowId: string; pipelineId: string }): Promise<TaskResponse>;
|
|
322
|
+
update(taskId: string, data: Partial<TaskResponse>): Promise<TaskResponse>;
|
|
323
|
+
delete(taskId: string): Promise<{ success: boolean }>;
|
|
324
|
+
move(taskId: string, pipelineId: string, position?: number): Promise<TaskResponse>;
|
|
325
|
+
complete(taskId: string): Promise<TaskResponse>;
|
|
326
|
+
archive(taskId: string): Promise<TaskResponse>;
|
|
327
|
+
deleteMany(taskIds: string[]): Promise<{ success: boolean; deletedCount: number }>;
|
|
328
|
+
moveMany(taskIds: string[], pipelineId: string): Promise<{ success: boolean }>;
|
|
329
|
+
completeMany(taskIds: string[]): Promise<{ success: boolean }>;
|
|
330
|
+
getActivities(taskId: string): Promise<any[]>;
|
|
331
|
+
listCompleted(options?: Record<string, any>): Promise<TaskResponse[]>;
|
|
332
|
+
listArchived(options?: Record<string, any>): Promise<TaskResponse[]>;
|
|
333
|
+
listByDate(date: Date | string): Promise<TaskResponse[]>;
|
|
334
|
+
listByContact(contactId: string): Promise<TaskResponse[]>;
|
|
335
|
+
listWorkflows(): Promise<WorkflowResponse[]>;
|
|
336
|
+
getWorkflow(workflowId: string): Promise<WorkflowResponse>;
|
|
337
|
+
createWorkflow(data: { name: string; description?: string; color?: string }): Promise<WorkflowResponse>;
|
|
338
|
+
updateWorkflow(workflowId: string, data: Partial<WorkflowResponse>): Promise<WorkflowResponse>;
|
|
339
|
+
deleteWorkflow(workflowId: string): Promise<{ success: boolean }>;
|
|
340
|
+
getWorkflowFull(workflowId: string): Promise<{ workflow: WorkflowResponse; pipelines: PipelineResponse[]; tasksByPipeline: Record<string, TaskResponse[]> }>;
|
|
341
|
+
getWorkflowReports(workflowId: string): Promise<any>;
|
|
342
|
+
listPipelines(workflowId: string): Promise<PipelineResponse[]>;
|
|
343
|
+
createPipeline(workflowId: string, data: { name: string; color?: string; position?: number }): Promise<PipelineResponse>;
|
|
344
|
+
updatePipeline(pipelineId: string, data: Partial<PipelineResponse>): Promise<PipelineResponse>;
|
|
345
|
+
deletePipeline(pipelineId: string): Promise<{ success: boolean }>;
|
|
346
|
+
updatePipelinePosition(workflowId: string, pipelineId: string, position: number): Promise<PipelineResponse>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export class AICall {
|
|
350
|
+
makeCall(options: { agentId: string; toNumber: string; fromNumber: string; variables?: Record<string, any>; metadata?: Record<string, any> }): Promise<CallResponse>;
|
|
351
|
+
makeWebCall(options: { agentId: string; variables?: Record<string, any> }): Promise<any>;
|
|
352
|
+
makeBatchCall(options: { agentId: string; fromNumber: string; calls: Array<{ toNumber: string; variables?: Record<string, any> }> }): Promise<any>;
|
|
353
|
+
getCall(callId: string): Promise<CallResponse>;
|
|
354
|
+
listCalls(options?: { agentId?: string; status?: string; startDate?: Date | string; endDate?: Date | string } & PaginationOptions): Promise<PaginatedResponse<CallResponse>>;
|
|
355
|
+
listBatchCalls(): Promise<any[]>;
|
|
356
|
+
listAgents(): Promise<any[]>;
|
|
357
|
+
getAgent(agentId: string): Promise<any>;
|
|
358
|
+
createAgent(data: { name: string; voiceId?: string; llmId?: string; settings?: Record<string, any> }): Promise<any>;
|
|
359
|
+
updateAgent(agentId: string, data: Record<string, any>): Promise<any>;
|
|
360
|
+
deleteAgent(agentId: string): Promise<{ success: boolean }>;
|
|
361
|
+
listNumbers(): Promise<any[]>;
|
|
362
|
+
getNumber(phoneNumber: string): Promise<any>;
|
|
363
|
+
listVoices(): Promise<any[]>;
|
|
364
|
+
getVoice(voiceId: string): Promise<any>;
|
|
365
|
+
listKnowledgeBases(): Promise<any[]>;
|
|
366
|
+
getKnowledgeBase(knowledgeBaseId: string): Promise<any>;
|
|
367
|
+
deleteKnowledgeBase(knowledgeBaseId: string): Promise<{ success: boolean }>;
|
|
368
|
+
listLLMs(): Promise<any[]>;
|
|
369
|
+
getLLM(llmId: string): Promise<any>;
|
|
370
|
+
createLLM(data: Record<string, any>): Promise<any>;
|
|
371
|
+
updateLLM(llmId: string, data: Record<string, any>): Promise<any>;
|
|
372
|
+
deleteLLM(llmId: string): Promise<{ success: boolean }>;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export class Asset {
|
|
376
|
+
get(assetId: string): Promise<AssetResponse>;
|
|
377
|
+
getUrl(path: string): string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export class Table {
|
|
381
|
+
list(): Promise<TableResponse[]>;
|
|
382
|
+
get(tableId: string): Promise<TableResponse>;
|
|
383
|
+
create(data: { name: string; description?: string; icon?: string }): Promise<TableResponse>;
|
|
384
|
+
update(tableId: string, data: Partial<TableResponse>): Promise<TableResponse>;
|
|
385
|
+
delete(tableId: string): Promise<{ success: boolean }>;
|
|
386
|
+
duplicate(tableId: string): Promise<TableResponse>;
|
|
387
|
+
export(tableId: string): Promise<Record<string, any>>;
|
|
388
|
+
import(data: Record<string, any>): Promise<TableResponse>;
|
|
389
|
+
listFields(tableId: string): Promise<FieldResponse[]>;
|
|
390
|
+
createField(tableId: string, data: { name: string; type: string; options?: Record<string, any> }): Promise<FieldResponse>;
|
|
391
|
+
updateField(tableId: string, fieldId: string, data: Partial<FieldResponse>): Promise<FieldResponse>;
|
|
392
|
+
deleteField(tableId: string, fieldId: string): Promise<{ success: boolean }>;
|
|
393
|
+
listRecords(tableId: string, options?: { filters?: Record<string, any>; sort?: Record<string, any>; viewId?: string } & PaginationOptions): Promise<PaginatedResponse<RecordResponse>>;
|
|
394
|
+
getRecord(tableId: string, recordId: string): Promise<RecordResponse>;
|
|
395
|
+
createRecord(tableId: string, data: Record<string, any>): Promise<RecordResponse>;
|
|
396
|
+
createEmptyRecord(tableId: string): Promise<RecordResponse>;
|
|
397
|
+
createManyRecords(tableId: string, records: Record<string, any>[]): Promise<RecordResponse[]>;
|
|
398
|
+
updateRecord(tableId: string, recordId: string, data: Record<string, any>): Promise<RecordResponse>;
|
|
399
|
+
updateManyRecords(tableId: string, fieldId: string, recordIds: string[], value: any): Promise<{ success: boolean }>;
|
|
400
|
+
deleteRecord(tableId: string, recordId: string): Promise<{ success: boolean }>;
|
|
401
|
+
deleteManyRecords(tableId: string, recordIds: string[]): Promise<{ success: boolean; deletedCount: number }>;
|
|
402
|
+
duplicateRecords(tableId: string, recordIds: string[]): Promise<RecordResponse[]>;
|
|
403
|
+
searchFieldValues(tableId: string, fieldId: string, query: string): Promise<any[]>;
|
|
404
|
+
listViews(tableId: string): Promise<any[]>;
|
|
405
|
+
createView(tableId: string, data: { name: string; type?: string; filters?: Record<string, any>; sort?: Record<string, any> }): Promise<any>;
|
|
406
|
+
updateView(tableId: string, viewId: string, data: Record<string, any>): Promise<any>;
|
|
407
|
+
deleteView(tableId: string, viewId: string): Promise<{ success: boolean }>;
|
|
408
|
+
listPages(tableId: string): Promise<any[]>;
|
|
409
|
+
getPage(tableId: string, pageId: string): Promise<any>;
|
|
410
|
+
createPage(tableId: string, data: Record<string, any>): Promise<any>;
|
|
411
|
+
listWidgets(tableId: string, pageId: string): Promise<any[]>;
|
|
412
|
+
getWidgetChartData(tableId: string, widgetId: string, options?: Record<string, any>): Promise<any>;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export class Module {
|
|
416
|
+
list(): Promise<any[]>;
|
|
417
|
+
create(data: { name: string; displayName: string; fields?: any[] }): Promise<any>;
|
|
418
|
+
update(moduleName: string, data: Record<string, any>): Promise<any>;
|
|
419
|
+
delete(moduleId: string): Promise<{ success: boolean }>;
|
|
420
|
+
listRecords(moduleName: string, options?: { filters?: Record<string, any>; sort?: Record<string, any> } & PaginationOptions): Promise<PaginatedResponse<any>>;
|
|
421
|
+
listAllRecords(moduleName: string): Promise<any[]>;
|
|
422
|
+
searchRecords(moduleName: string, query: string): Promise<any[]>;
|
|
423
|
+
getRecord(moduleName: string, recordId: string): Promise<any>;
|
|
424
|
+
createRecord(moduleName: string, data: Record<string, any>): Promise<any>;
|
|
425
|
+
createManyRecords(moduleName: string, records: Record<string, any>[]): Promise<any[]>;
|
|
426
|
+
updateRecord(moduleName: string, recordId: string, data: Record<string, any>): Promise<any>;
|
|
427
|
+
deleteRecord(moduleName: string, recordId: string): Promise<{ success: boolean }>;
|
|
428
|
+
listContactRelatedRecords(contactId: string): Promise<Record<string, any[]>>;
|
|
429
|
+
listModuleRelatedRecords(moduleName: string, recordId: string): Promise<Record<string, any>>;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export class User {
|
|
433
|
+
me(): Promise<UserResponse>;
|
|
434
|
+
updateMe(data: Partial<UserResponse>): Promise<UserResponse>;
|
|
435
|
+
get(userId: string): Promise<UserResponse>;
|
|
436
|
+
list(options?: { status?: string } & PaginationOptions): Promise<PaginatedResponse<UserResponse>>;
|
|
437
|
+
listOnline(): Promise<UserResponse[]>;
|
|
438
|
+
create(data: { fullname: string; email: string; password: string; role?: string; subjects?: string[] }): Promise<UserResponse>;
|
|
439
|
+
update(userId: string, data: Partial<UserResponse>): Promise<UserResponse>;
|
|
440
|
+
delete(userId: string): Promise<{ success: boolean }>;
|
|
441
|
+
updatePassword(userId: string, newPassword: string): Promise<{ success: boolean }>;
|
|
442
|
+
updateOnlineStatus(userId: string, isOnline: boolean): Promise<UserResponse>;
|
|
443
|
+
updateStatus(userId: string, status: 'Online' | 'Offline' | 'Away' | 'Busy'): Promise<UserResponse>;
|
|
444
|
+
getActiveCount(): Promise<{ count: number }>;
|
|
445
|
+
getNotificationSettings(): Promise<any>;
|
|
446
|
+
completeTutorial(tutorialKey: string): Promise<{ success: boolean }>;
|
|
447
|
+
logout(): Promise<{ success: boolean }>;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export class Tag {
|
|
451
|
+
list(type?: 'visitor' | 'conversation' | 'ticket'): Promise<TagResponse[]>;
|
|
452
|
+
create(data: { name: string; color?: string; type?: string }): Promise<TagResponse>;
|
|
453
|
+
update(data: { _id: string; name?: string; color?: string }): Promise<TagResponse>;
|
|
454
|
+
delete(tagId: string): Promise<{ success: boolean }>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export class Site {
|
|
458
|
+
getCurrentPlan(): Promise<any>;
|
|
459
|
+
getFeatures(): Promise<any>;
|
|
460
|
+
getWallet(): Promise<any[]>;
|
|
461
|
+
getWalletActivities(options?: { walletType?: string; startDate?: Date | string; endDate?: Date | string }): Promise<any[]>;
|
|
462
|
+
depositWallet(walletType: string, amount: number): Promise<any>;
|
|
463
|
+
getAutoRebalanceSettings(walletType: string): Promise<any>;
|
|
464
|
+
updateAutoRebalanceSettings(walletType: string, settings: Record<string, any>): Promise<any>;
|
|
465
|
+
getConversationUsage(): Promise<any>;
|
|
466
|
+
getStorageUsage(options?: Record<string, any>): Promise<any>;
|
|
467
|
+
checkIntegrationStatus(options?: Record<string, any>): Promise<any>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export class Cache {
|
|
471
|
+
list(options?: { pattern?: string; type?: string; actorType?: string } & PaginationOptions): Promise<PaginatedResponse<CacheResponse>>;
|
|
472
|
+
write(key: string, value: any, options?: { type?: 'public' | 'private'; dataType?: string; expiresIn?: { value: number; unit: 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' }; expiresAt?: Date | string }): Promise<CacheResponse>;
|
|
473
|
+
read(key: string, defaultValue?: any): Promise<any>;
|
|
474
|
+
update(cacheId: string, value: any): Promise<CacheResponse>;
|
|
475
|
+
extend(cacheId: string, expiresIn: { value: number; unit: string }): Promise<CacheResponse>;
|
|
476
|
+
makeNeverExpire(cacheId: string): Promise<CacheResponse>;
|
|
477
|
+
delete(cacheId: string): Promise<{ success: boolean }>;
|
|
478
|
+
deleteMany(cacheIds: string[]): Promise<{ success: boolean; deletedCount: number }>;
|
|
479
|
+
deleteByActor(actorType: string, actorId: string): Promise<{ success: boolean; deletedCount: number }>;
|
|
480
|
+
deleteByPattern(pattern: string): Promise<{ success: boolean; deletedCount: number }>;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// ==================== CORE CLASSES ====================
|
|
484
|
+
|
|
485
|
+
export class HttpClient {
|
|
486
|
+
constructor(config: { env?: string; baseApiAddress?: string; siteId?: string; timeout?: number; retryCount?: number });
|
|
487
|
+
setToken(token: string): void;
|
|
488
|
+
setSiteId(siteId: string): void;
|
|
489
|
+
request(method: string, endpoint: string, options?: { body?: any; query?: Record<string, any>; headers?: Record<string, string>; skipAuth?: boolean }): Promise<any>;
|
|
490
|
+
get(endpoint: string, options?: Record<string, any>): Promise<any>;
|
|
491
|
+
post(endpoint: string, body?: any, options?: Record<string, any>): Promise<any>;
|
|
492
|
+
put(endpoint: string, body?: any, options?: Record<string, any>): Promise<any>;
|
|
493
|
+
patch(endpoint: string, body?: any, options?: Record<string, any>): Promise<any>;
|
|
494
|
+
delete(endpoint: string, options?: Record<string, any>): Promise<any>;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export class SupsisAPIError extends Error {
|
|
498
|
+
statusCode: number;
|
|
499
|
+
response?: any;
|
|
500
|
+
constructor(message: string, statusCode: number, response?: any);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export class BaseModule {
|
|
504
|
+
constructor(httpClient: HttpClient);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// ==================== MAIN CLASSES ====================
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Supsis API SDK Ana Sınıfı
|
|
511
|
+
*/
|
|
512
|
+
export class SupsisJS {
|
|
513
|
+
constructor(config: SupsisConfig);
|
|
514
|
+
|
|
515
|
+
/** Chat modülü */
|
|
516
|
+
chat: Chat;
|
|
517
|
+
/** Contact modülü */
|
|
518
|
+
contact: Contact;
|
|
519
|
+
/** Message modülü */
|
|
520
|
+
message: Message;
|
|
521
|
+
/** Task modülü */
|
|
522
|
+
task: Task;
|
|
523
|
+
/** AI Call modülü */
|
|
524
|
+
aicall: AICall;
|
|
525
|
+
/** Asset modülü */
|
|
526
|
+
asset: Asset;
|
|
527
|
+
/** Table modülü */
|
|
528
|
+
table: Table;
|
|
529
|
+
/** Module modülü */
|
|
530
|
+
module: Module;
|
|
531
|
+
/** User modülü */
|
|
532
|
+
user: User;
|
|
533
|
+
/** Tag modülü */
|
|
534
|
+
tag: Tag;
|
|
535
|
+
/** Site modülü */
|
|
536
|
+
site: Site;
|
|
537
|
+
/** Cache modülü */
|
|
538
|
+
cache: Cache;
|
|
539
|
+
|
|
540
|
+
/** API'ye bağlanır */
|
|
541
|
+
connect(): Promise<UserResponse>;
|
|
542
|
+
/** Bağlantıyı kapatır */
|
|
543
|
+
disconnect(): Promise<void>;
|
|
544
|
+
/** Bağlı mı */
|
|
545
|
+
readonly isConnected: boolean;
|
|
546
|
+
/** Mevcut kullanıcı */
|
|
547
|
+
readonly currentUser: UserResponse | null;
|
|
548
|
+
/** JWT token */
|
|
549
|
+
readonly token: string | null;
|
|
550
|
+
/** SDK versiyonu */
|
|
551
|
+
readonly version: string;
|
|
552
|
+
/** HttpClient */
|
|
553
|
+
readonly http: HttpClient;
|
|
554
|
+
/** Token'ı manuel set eder */
|
|
555
|
+
setToken(token: string): void;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Supsis Module API Sınıfı (Developer Token ile)
|
|
560
|
+
*/
|
|
561
|
+
export class SupsisModuleAPI {
|
|
562
|
+
constructor(config: ModuleAPIConfig);
|
|
563
|
+
|
|
564
|
+
/** Table modülü */
|
|
565
|
+
table: Table;
|
|
566
|
+
/** Module modülü */
|
|
567
|
+
module: Module;
|
|
568
|
+
/** Cache modülü */
|
|
569
|
+
cache: Cache;
|
|
570
|
+
|
|
571
|
+
/** SDK versiyonu */
|
|
572
|
+
readonly version: string;
|
|
573
|
+
/** HttpClient */
|
|
574
|
+
readonly http: HttpClient;
|
|
575
|
+
/** Access token'ı günceller */
|
|
576
|
+
setAccessToken(token: string): void;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// ==================== CONSTANTS ====================
|
|
580
|
+
|
|
581
|
+
export const ENVIRONMENTS: {
|
|
582
|
+
production: string;
|
|
583
|
+
stage: string;
|
|
584
|
+
local: string;
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
export const DEFAULT_CONFIG: {
|
|
588
|
+
env: string;
|
|
589
|
+
baseApiAddress: null;
|
|
590
|
+
timeout: number;
|
|
591
|
+
retryCount: number;
|
|
592
|
+
retryDelay: number;
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
export const SDK_VERSION: string;
|
|
596
|
+
|
|
597
|
+
// Default export
|
|
598
|
+
export default SupsisJS;
|
|
599
|
+
|