whio-api-sdk 1.0.187-bet-staging → 1.0.188-bet-staging

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.
@@ -0,0 +1,244 @@
1
+ # Logs SDK Usage Guide
2
+
3
+ ## Overview
4
+ The SDK provides comprehensive logging functionality to query and analyze application logs with user context.
5
+
6
+ ## Installation & Setup
7
+
8
+ ```typescript
9
+ import { ApiSDK, FilterLogsDto, LogsResponse, LogStats } from './sdk';
10
+
11
+ const sdk = new ApiSDK({
12
+ baseUrl: 'https://your-api.com/api',
13
+ storage: localStorage // or your preferred storage
14
+ });
15
+
16
+ // Authenticate first
17
+ await sdk.login({ email: 'user@example.com', password: 'password' });
18
+ ```
19
+
20
+ ## Available Methods
21
+
22
+ ### 1. Get Logs with Advanced Filtering
23
+
24
+ ```typescript
25
+ // Get all logs with flexible filtering
26
+ const filters: FilterLogsDto = {
27
+ controller: 'SessionsController',
28
+ userId: 'user-123',
29
+ level: 'error',
30
+ startDate: '2024-01-15T00:00:00Z',
31
+ endDate: '2024-01-16T00:00:00Z',
32
+ limit: 50,
33
+ offset: 0
34
+ };
35
+
36
+ const response: LogsResponse = await sdk.getLogs(filters);
37
+ console.log(`Found ${response.total} logs`);
38
+ response.logs.forEach(log => {
39
+ console.log(`[${log.level}] ${log.message}`, log.meta);
40
+ });
41
+ ```
42
+
43
+ ### 2. Get User Logs
44
+
45
+ ```typescript
46
+ // Get logs for a specific user
47
+ const userLogs = await sdk.getLogsByUser('user-123', 100, 0);
48
+
49
+ // Get your own logs
50
+ const myLogs = await sdk.getMyLogs(50, 0);
51
+ ```
52
+
53
+ ### 3. Get Controller Logs
54
+
55
+ ```typescript
56
+ // Monitor specific controller activity
57
+ const controllerLogs = await sdk.getLogsByController('SessionsController', 100, 0);
58
+ ```
59
+
60
+ ### 4. Get Logs by Date Range
61
+
62
+ ```typescript
63
+ // Get logs for last 7 days
64
+ const startDate = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
65
+ const endDate = new Date().toISOString();
66
+
67
+ const recentLogs = await sdk.getLogsByDateRange(startDate, endDate, 100, 0);
68
+ ```
69
+
70
+ ### 5. Get Log Statistics
71
+
72
+ ```typescript
73
+ // Get system-wide logging statistics
74
+ const stats: LogStats = await sdk.getLogStats();
75
+ console.log(`Total logs: ${stats.totalLogs}`);
76
+ console.log(`Errors: ${stats.errorLogs}`);
77
+ console.log(`Recent activity: ${stats.recentLogs}`);
78
+ ```
79
+
80
+ ## Response Format
81
+
82
+ All log methods return a `LogsResponse` object:
83
+
84
+ ```typescript
85
+ interface LogsResponse {
86
+ logs: Log[];
87
+ total: number;
88
+ limit: number;
89
+ offset: number;
90
+ hasMore: boolean;
91
+ }
92
+
93
+ interface Log {
94
+ id: number;
95
+ level: string;
96
+ message: string;
97
+ meta: {
98
+ userId?: string;
99
+ userEmail?: string;
100
+ organizationId?: string;
101
+ requestId?: string;
102
+ context?: string;
103
+ [key: string]: any;
104
+ };
105
+ timestamp: string;
106
+ }
107
+ ```
108
+
109
+ ## Advanced Usage Examples
110
+
111
+ ### 1. Debug User Issues
112
+
113
+ ```typescript
114
+ // Find all errors for a specific user in the last 24 hours
115
+ const userErrors = await sdk.getLogs({
116
+ userId: 'user-123',
117
+ level: 'error',
118
+ startDate: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
119
+ });
120
+
121
+ userErrors.logs.forEach(log => {
122
+ console.error(`User Error: ${log.message}`, {
123
+ timestamp: log.timestamp,
124
+ context: log.meta.context,
125
+ requestId: log.meta.requestId
126
+ });
127
+ });
128
+ ```
129
+
130
+ ### 2. Monitor System Health
131
+
132
+ ```typescript
133
+ // Get error statistics
134
+ const stats = await sdk.getLogStats();
135
+ const errorRate = (stats.errorLogs / stats.totalLogs) * 100;
136
+
137
+ if (errorRate > 5) {
138
+ console.warn(`High error rate detected: ${errorRate.toFixed(2)}%`);
139
+ }
140
+ ```
141
+
142
+ ### 3. Audit Organization Activity
143
+
144
+ ```typescript
145
+ // Get all activity for an organization
146
+ const orgActivity = await sdk.getLogs({
147
+ organizationId: 'org-456',
148
+ startDate: '2024-01-01T00:00:00Z',
149
+ endDate: '2024-01-31T23:59:59Z'
150
+ });
151
+
152
+ // Group by user
153
+ const userActivity = orgActivity.logs.reduce((acc, log) => {
154
+ const userId = log.meta.userId;
155
+ if (userId) {
156
+ acc[userId] = (acc[userId] || 0) + 1;
157
+ }
158
+ return acc;
159
+ }, {} as Record<string, number>);
160
+
161
+ console.log('User activity:', userActivity);
162
+ ```
163
+
164
+ ### 4. Pagination Example
165
+
166
+ ```typescript
167
+ // Paginate through all logs
168
+ let offset = 0;
169
+ const limit = 100;
170
+ let hasMore = true;
171
+
172
+ while (hasMore) {
173
+ const response = await sdk.getLogs({ limit, offset });
174
+
175
+ // Process logs
176
+ response.logs.forEach(log => {
177
+ console.log(`[${log.level}] ${log.message}`);
178
+ });
179
+
180
+ // Update pagination
181
+ offset += limit;
182
+ hasMore = response.hasMore;
183
+ }
184
+ ```
185
+
186
+ ### 5. Real-time Log Monitoring
187
+
188
+ ```typescript
189
+ // Poll for new logs every 30 seconds
190
+ setInterval(async () => {
191
+ const recentLogs = await sdk.getLogs({
192
+ startDate: new Date(Date.now() - 30 * 1000).toISOString(),
193
+ level: 'error'
194
+ });
195
+
196
+ if (recentLogs.logs.length > 0) {
197
+ console.log(`Found ${recentLogs.logs.length} new errors`);
198
+ recentLogs.logs.forEach(log => {
199
+ console.error(log.message, log.meta);
200
+ });
201
+ }
202
+ }, 30000);
203
+ ```
204
+
205
+ ## Error Handling
206
+
207
+ ```typescript
208
+ try {
209
+ const logs = await sdk.getLogs({ userId: 'invalid-user' });
210
+ } catch (error) {
211
+ if (error.status === 403) {
212
+ console.error('Insufficient permissions to view logs');
213
+ } else if (error.status === 404) {
214
+ console.error('User not found');
215
+ } else {
216
+ console.error('Failed to fetch logs:', error.message);
217
+ }
218
+ }
219
+ ```
220
+
221
+ ## Permissions
222
+
223
+ - **Users**: Can view their own logs via `getMyLogs()`
224
+ - **Organization Admins**: Can view logs from users in their organization
225
+ - **Superusers**: Can view all logs system-wide
226
+
227
+ The SDK automatically handles permission restrictions based on your authentication level.
228
+
229
+ ## TypeScript Support
230
+
231
+ All methods are fully typed for excellent IDE support:
232
+
233
+ ```typescript
234
+ import type { FilterLogsDto, LogsResponse, LogStats } from './sdk/types';
235
+
236
+ // Type-safe filtering
237
+ const filters: FilterLogsDto = {
238
+ level: 'error', // TypeScript will suggest valid log levels
239
+ startDate: '2024-01-01T00:00:00Z' // ISO string expected
240
+ };
241
+
242
+ const response: LogsResponse = await sdk.getLogs(filters);
243
+ // response.logs is properly typed as Log[]
244
+ ```
@@ -1,4 +1,4 @@
1
- import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto, AgentSettings, CreateAgentSettingsDto, UpdateAgentSettingsDto, Workflow, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse } from './types';
1
+ import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto, AgentSettings, CreateAgentSettingsDto, UpdateAgentSettingsDto, Workflow, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse, Log, LogsResponse, LogStats, FilterLogsDto, CreateLogDto } from './types';
2
2
  export declare class ApiSDK {
3
3
  private baseUrl;
4
4
  private storage;
@@ -139,4 +139,39 @@ export declare class ApiSDK {
139
139
  getWorkflowsByOrganization(organizationId?: string): Promise<Workflow[]>;
140
140
  updateWorkflow(id: string, name: string, organizationId?: string): Promise<Workflow>;
141
141
  deleteWorkflow(id: string): Promise<void>;
142
+ /**
143
+ * Get logs with advanced filtering options
144
+ */
145
+ getLogs(filters?: FilterLogsDto): Promise<LogsResponse>;
146
+ /**
147
+ * Get logs for a specific user
148
+ */
149
+ getLogsByUser(userId: string, limit?: number, offset?: number): Promise<LogsResponse>;
150
+ /**
151
+ * Get logs for a specific controller
152
+ */
153
+ getLogsByController(controller: string, limit?: number, offset?: number): Promise<LogsResponse>;
154
+ /**
155
+ * Get logs for the current authenticated user
156
+ */
157
+ getMyLogs(limit?: number, offset?: number): Promise<LogsResponse>;
158
+ /**
159
+ * Get logs within a date range
160
+ */
161
+ getLogsByDateRange(startDate: string, endDate: string, limit?: number, offset?: number): Promise<LogsResponse>;
162
+ /**
163
+ * Get logging statistics
164
+ */
165
+ getLogStats(): Promise<LogStats>;
166
+ /**
167
+ * Create a manual log entry (app logs)
168
+ */
169
+ createLog(logData: CreateLogDto): Promise<Log>;
170
+ /**
171
+ * Convenience methods for different log levels
172
+ */
173
+ logInfo(message: string, context?: string, action?: string, data?: any): Promise<Log>;
174
+ logError(message: string, context?: string, action?: string, data?: any): Promise<Log>;
175
+ logWarn(message: string, context?: string, action?: string, data?: any): Promise<Log>;
176
+ logDebug(message: string, context?: string, action?: string, data?: any): Promise<Log>;
142
177
  }
@@ -73,7 +73,6 @@ export class ApiSDK {
73
73
  // If no token is available, try to get it
74
74
  yield this.getToken();
75
75
  }
76
- console.log(this.accessToken);
77
76
  if (this.accessToken) {
78
77
  defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
79
78
  }
@@ -485,7 +484,6 @@ export class ApiSDK {
485
484
  }
486
485
  addUserToOrganization(organizationId, userId) {
487
486
  return __awaiter(this, void 0, void 0, function* () {
488
- console.log('Adding user to organization:', organizationId, userId);
489
487
  yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
490
488
  });
491
489
  }
@@ -966,4 +964,146 @@ export class ApiSDK {
966
964
  yield this.request(`${urls.workflows}/${id}`, 'DELETE');
967
965
  });
968
966
  }
967
+ // ===== LOGS METHODS =====
968
+ /**
969
+ * Get logs with advanced filtering options
970
+ */
971
+ getLogs(filters) {
972
+ return __awaiter(this, void 0, void 0, function* () {
973
+ const params = new URLSearchParams();
974
+ if (filters) {
975
+ Object.entries(filters).forEach(([key, value]) => {
976
+ if (value !== undefined && value !== null) {
977
+ params.append(key, value.toString());
978
+ }
979
+ });
980
+ }
981
+ const queryString = params.toString();
982
+ const url = queryString ? `${urls.logs}?${queryString}` : urls.logs;
983
+ return this.request(url, 'GET');
984
+ });
985
+ }
986
+ /**
987
+ * Get logs for a specific user
988
+ */
989
+ getLogsByUser(userId, limit, offset) {
990
+ return __awaiter(this, void 0, void 0, function* () {
991
+ const params = new URLSearchParams();
992
+ if (limit !== undefined)
993
+ params.append('limit', limit.toString());
994
+ if (offset !== undefined)
995
+ params.append('offset', offset.toString());
996
+ const queryString = params.toString();
997
+ const url = queryString ? `${urls.logs}/user/${userId}?${queryString}` : `${urls.logs}/user/${userId}`;
998
+ return this.request(url, 'GET');
999
+ });
1000
+ }
1001
+ /**
1002
+ * Get logs for a specific controller
1003
+ */
1004
+ getLogsByController(controller, limit, offset) {
1005
+ return __awaiter(this, void 0, void 0, function* () {
1006
+ const params = new URLSearchParams();
1007
+ if (limit !== undefined)
1008
+ params.append('limit', limit.toString());
1009
+ if (offset !== undefined)
1010
+ params.append('offset', offset.toString());
1011
+ const queryString = params.toString();
1012
+ const url = queryString ? `${urls.logs}/controller/${controller}?${queryString}` : `${urls.logs}/controller/${controller}`;
1013
+ return this.request(url, 'GET');
1014
+ });
1015
+ }
1016
+ /**
1017
+ * Get logs for the current authenticated user
1018
+ */
1019
+ getMyLogs(limit, offset) {
1020
+ return __awaiter(this, void 0, void 0, function* () {
1021
+ const params = new URLSearchParams();
1022
+ if (limit !== undefined)
1023
+ params.append('limit', limit.toString());
1024
+ if (offset !== undefined)
1025
+ params.append('offset', offset.toString());
1026
+ const queryString = params.toString();
1027
+ const url = queryString ? `${urls.logs}/my-logs?${queryString}` : `${urls.logs}/my-logs`;
1028
+ return this.request(url, 'GET');
1029
+ });
1030
+ }
1031
+ /**
1032
+ * Get logs within a date range
1033
+ */
1034
+ getLogsByDateRange(startDate, endDate, limit, offset) {
1035
+ return __awaiter(this, void 0, void 0, function* () {
1036
+ const params = new URLSearchParams();
1037
+ params.append('startDate', startDate);
1038
+ params.append('endDate', endDate);
1039
+ if (limit !== undefined)
1040
+ params.append('limit', limit.toString());
1041
+ if (offset !== undefined)
1042
+ params.append('offset', offset.toString());
1043
+ return this.request(`${urls.logs}/date-range?${params.toString()}`, 'GET');
1044
+ });
1045
+ }
1046
+ /**
1047
+ * Get logging statistics
1048
+ */
1049
+ getLogStats() {
1050
+ return __awaiter(this, void 0, void 0, function* () {
1051
+ return this.request(`${urls.logs}/stats`, 'GET');
1052
+ });
1053
+ }
1054
+ /**
1055
+ * Create a manual log entry (app logs)
1056
+ */
1057
+ createLog(logData) {
1058
+ return __awaiter(this, void 0, void 0, function* () {
1059
+ return this.request(urls.logs, 'POST', logData);
1060
+ });
1061
+ }
1062
+ /**
1063
+ * Convenience methods for different log levels
1064
+ */
1065
+ logInfo(message, context, action, data) {
1066
+ return __awaiter(this, void 0, void 0, function* () {
1067
+ return this.createLog({
1068
+ level: 'info',
1069
+ message,
1070
+ context,
1071
+ action,
1072
+ data,
1073
+ });
1074
+ });
1075
+ }
1076
+ logError(message, context, action, data) {
1077
+ return __awaiter(this, void 0, void 0, function* () {
1078
+ return this.createLog({
1079
+ level: 'error',
1080
+ message,
1081
+ context,
1082
+ action,
1083
+ data,
1084
+ });
1085
+ });
1086
+ }
1087
+ logWarn(message, context, action, data) {
1088
+ return __awaiter(this, void 0, void 0, function* () {
1089
+ return this.createLog({
1090
+ level: 'warn',
1091
+ message,
1092
+ context,
1093
+ action,
1094
+ data,
1095
+ });
1096
+ });
1097
+ }
1098
+ logDebug(message, context, action, data) {
1099
+ return __awaiter(this, void 0, void 0, function* () {
1100
+ return this.createLog({
1101
+ level: 'debug',
1102
+ message,
1103
+ context,
1104
+ action,
1105
+ data,
1106
+ });
1107
+ });
1108
+ }
969
1109
  }
@@ -451,3 +451,42 @@ export interface UpdateBase64AudioFileDto {
451
451
  export interface AddBase64ChunkResponse {
452
452
  count: number;
453
453
  }
454
+ export interface Log {
455
+ id: number;
456
+ level: string;
457
+ message: string;
458
+ meta: any;
459
+ timestamp: string;
460
+ }
461
+ export interface LogsResponse {
462
+ logs: Log[];
463
+ total: number;
464
+ limit: number;
465
+ offset: number;
466
+ hasMore: boolean;
467
+ }
468
+ export interface LogStats {
469
+ totalLogs: number;
470
+ errorLogs: number;
471
+ warnLogs: number;
472
+ infoLogs: number;
473
+ recentLogs: number;
474
+ }
475
+ export interface FilterLogsDto {
476
+ controller?: string;
477
+ userId?: string;
478
+ organizationId?: string;
479
+ level?: 'error' | 'warn' | 'info' | 'debug' | 'verbose';
480
+ startDate?: string;
481
+ endDate?: string;
482
+ limit?: number;
483
+ offset?: number;
484
+ }
485
+ export interface CreateLogDto {
486
+ level: 'error' | 'warn' | 'info' | 'debug' | 'verbose';
487
+ message: string;
488
+ context?: string;
489
+ action?: string;
490
+ data?: any;
491
+ additionalMeta?: Record<string, any>;
492
+ }
@@ -29,5 +29,6 @@ declare const urls: {
29
29
  agentSettings: string;
30
30
  audioFiles: string;
31
31
  workflows: string;
32
+ logs: string;
32
33
  };
33
34
  export default urls;
@@ -41,5 +41,7 @@ const urls = {
41
41
  audioFiles: '/audio-files',
42
42
  // Workflows
43
43
  workflows: '/workflows',
44
+ // Logs
45
+ logs: '/logs',
44
46
  };
45
47
  export default urls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.187-bet-staging",
3
+ "version": "1.0.188-bet-staging",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/src/sdk/sdk.ts CHANGED
@@ -55,6 +55,11 @@ import {
55
55
  CreateBase64AudioFileDto,
56
56
  UpdateBase64AudioFileDto,
57
57
  AddBase64ChunkResponse,
58
+ Log,
59
+ LogsResponse,
60
+ LogStats,
61
+ FilterLogsDto,
62
+ CreateLogDto,
58
63
  } from './types';
59
64
  import urls from './urls';
60
65
  import { jwtDecode } from 'jwt-decode';
@@ -128,7 +133,6 @@ export class ApiSDK {
128
133
  await this.getToken();
129
134
  }
130
135
 
131
- console.log(this.accessToken);
132
136
 
133
137
  if (this.accessToken) {
134
138
  defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
@@ -595,7 +599,6 @@ export class ApiSDK {
595
599
  }
596
600
 
597
601
  public async addUserToOrganization(organizationId: string, userId: string): Promise<void> {
598
- console.log('Adding user to organization:', organizationId, userId);
599
602
  await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
600
603
  }
601
604
 
@@ -1026,4 +1029,143 @@ export class ApiSDK {
1026
1029
  await this.request(`${urls.workflows}/${id}`, 'DELETE');
1027
1030
  }
1028
1031
 
1032
+ // ===== LOGS METHODS =====
1033
+
1034
+ /**
1035
+ * Get logs with advanced filtering options
1036
+ */
1037
+ public async getLogs(filters?: FilterLogsDto): Promise<LogsResponse> {
1038
+ const params = new URLSearchParams();
1039
+
1040
+ if (filters) {
1041
+ Object.entries(filters).forEach(([key, value]) => {
1042
+ if (value !== undefined && value !== null) {
1043
+ params.append(key, value.toString());
1044
+ }
1045
+ });
1046
+ }
1047
+
1048
+ const queryString = params.toString();
1049
+ const url = queryString ? `${urls.logs}?${queryString}` : urls.logs;
1050
+
1051
+ return this.request<LogsResponse>(url, 'GET');
1052
+ }
1053
+
1054
+ /**
1055
+ * Get logs for a specific user
1056
+ */
1057
+ public async getLogsByUser(userId: string, limit?: number, offset?: number): Promise<LogsResponse> {
1058
+ const params = new URLSearchParams();
1059
+ if (limit !== undefined) params.append('limit', limit.toString());
1060
+ if (offset !== undefined) params.append('offset', offset.toString());
1061
+
1062
+ const queryString = params.toString();
1063
+ const url = queryString ? `${urls.logs}/user/${userId}?${queryString}` : `${urls.logs}/user/${userId}`;
1064
+
1065
+ return this.request<LogsResponse>(url, 'GET');
1066
+ }
1067
+
1068
+ /**
1069
+ * Get logs for a specific controller
1070
+ */
1071
+ public async getLogsByController(controller: string, limit?: number, offset?: number): Promise<LogsResponse> {
1072
+ const params = new URLSearchParams();
1073
+ if (limit !== undefined) params.append('limit', limit.toString());
1074
+ if (offset !== undefined) params.append('offset', offset.toString());
1075
+
1076
+ const queryString = params.toString();
1077
+ const url = queryString ? `${urls.logs}/controller/${controller}?${queryString}` : `${urls.logs}/controller/${controller}`;
1078
+
1079
+ return this.request<LogsResponse>(url, 'GET');
1080
+ }
1081
+
1082
+ /**
1083
+ * Get logs for the current authenticated user
1084
+ */
1085
+ public async getMyLogs(limit?: number, offset?: number): Promise<LogsResponse> {
1086
+ const params = new URLSearchParams();
1087
+ if (limit !== undefined) params.append('limit', limit.toString());
1088
+ if (offset !== undefined) params.append('offset', offset.toString());
1089
+
1090
+ const queryString = params.toString();
1091
+ const url = queryString ? `${urls.logs}/my-logs?${queryString}` : `${urls.logs}/my-logs`;
1092
+
1093
+ return this.request<LogsResponse>(url, 'GET');
1094
+ }
1095
+
1096
+ /**
1097
+ * Get logs within a date range
1098
+ */
1099
+ public async getLogsByDateRange(
1100
+ startDate: string,
1101
+ endDate: string,
1102
+ limit?: number,
1103
+ offset?: number
1104
+ ): Promise<LogsResponse> {
1105
+ const params = new URLSearchParams();
1106
+ params.append('startDate', startDate);
1107
+ params.append('endDate', endDate);
1108
+ if (limit !== undefined) params.append('limit', limit.toString());
1109
+ if (offset !== undefined) params.append('offset', offset.toString());
1110
+
1111
+ return this.request<LogsResponse>(`${urls.logs}/date-range?${params.toString()}`, 'GET');
1112
+ }
1113
+
1114
+ /**
1115
+ * Get logging statistics
1116
+ */
1117
+ public async getLogStats(): Promise<LogStats> {
1118
+ return this.request<LogStats>(`${urls.logs}/stats`, 'GET');
1119
+ }
1120
+
1121
+ /**
1122
+ * Create a manual log entry (app logs)
1123
+ */
1124
+ public async createLog(logData: CreateLogDto): Promise<Log> {
1125
+ return this.request<Log>(urls.logs, 'POST', logData);
1126
+ }
1127
+
1128
+ /**
1129
+ * Convenience methods for different log levels
1130
+ */
1131
+ public async logInfo(message: string, context?: string, action?: string, data?: any): Promise<Log> {
1132
+ return this.createLog({
1133
+ level: 'info',
1134
+ message,
1135
+ context,
1136
+ action,
1137
+ data,
1138
+ });
1139
+ }
1140
+
1141
+ public async logError(message: string, context?: string, action?: string, data?: any): Promise<Log> {
1142
+ return this.createLog({
1143
+ level: 'error',
1144
+ message,
1145
+ context,
1146
+ action,
1147
+ data,
1148
+ });
1149
+ }
1150
+
1151
+ public async logWarn(message: string, context?: string, action?: string, data?: any): Promise<Log> {
1152
+ return this.createLog({
1153
+ level: 'warn',
1154
+ message,
1155
+ context,
1156
+ action,
1157
+ data,
1158
+ });
1159
+ }
1160
+
1161
+ public async logDebug(message: string, context?: string, action?: string, data?: any): Promise<Log> {
1162
+ return this.createLog({
1163
+ level: 'debug',
1164
+ message,
1165
+ context,
1166
+ action,
1167
+ data,
1168
+ });
1169
+ }
1170
+
1029
1171
  }
package/src/sdk/types.ts CHANGED
@@ -575,3 +575,48 @@ export interface UpdateBase64AudioFileDto {
575
575
  export interface AddBase64ChunkResponse {
576
576
  count: number;
577
577
  }
578
+
579
+ // Log types
580
+ export interface Log {
581
+ id: number;
582
+ level: string;
583
+ message: string;
584
+ meta: any;
585
+ timestamp: string;
586
+ }
587
+
588
+ export interface LogsResponse {
589
+ logs: Log[];
590
+ total: number;
591
+ limit: number;
592
+ offset: number;
593
+ hasMore: boolean;
594
+ }
595
+
596
+ export interface LogStats {
597
+ totalLogs: number;
598
+ errorLogs: number;
599
+ warnLogs: number;
600
+ infoLogs: number;
601
+ recentLogs: number;
602
+ }
603
+
604
+ export interface FilterLogsDto {
605
+ controller?: string;
606
+ userId?: string;
607
+ organizationId?: string;
608
+ level?: 'error' | 'warn' | 'info' | 'debug' | 'verbose';
609
+ startDate?: string;
610
+ endDate?: string;
611
+ limit?: number;
612
+ offset?: number;
613
+ }
614
+
615
+ export interface CreateLogDto {
616
+ level: 'error' | 'warn' | 'info' | 'debug' | 'verbose';
617
+ message: string;
618
+ context?: string;
619
+ action?: string;
620
+ data?: any;
621
+ additionalMeta?: Record<string, any>;
622
+ }
package/src/sdk/urls.ts CHANGED
@@ -52,6 +52,9 @@ const urls = {
52
52
 
53
53
  // Workflows
54
54
  workflows: '/workflows',
55
+
56
+ // Logs
57
+ logs: '/logs',
55
58
  }
56
59
 
57
60
  export default urls;