@utilia-os/sdk-js 1.1.0 → 1.4.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 CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  SDK JavaScript/TypeScript para integrar aplicaciones externas con UTILIA OS.
4
4
 
5
- ## Instalacion
5
+ ## Instalación
6
6
 
7
7
  ```bash
8
8
  npm install @utilia-os/sdk-js
9
9
  ```
10
10
 
11
- ## Configuracion
11
+ ## Configuración
12
12
 
13
13
  ```typescript
14
14
  import { UtiliaSDK } from '@utilia-os/sdk-js';
@@ -29,7 +29,7 @@ Antes de crear tickets, identifica al usuario en tu sistema:
29
29
 
30
30
  ```typescript
31
31
  const user = await sdk.users.identify({
32
- externalId: 'user-123', // ID unico en tu sistema (requerido)
32
+ externalId: 'user-123', // ID único en tu sistema (requerido)
33
33
  email: 'user@example.com', // opcional
34
34
  name: 'Juan Perez', // opcional
35
35
  avatarUrl: 'https://...', // opcional
@@ -49,10 +49,10 @@ const ticket = await sdk.tickets.create({
49
49
  email: 'user@example.com',
50
50
  name: 'Juan Perez',
51
51
  },
52
- title: 'Problema con la facturacion',
52
+ title: 'Problema con la facturación',
53
53
  description: 'No puedo ver mis facturas del mes pasado...',
54
54
  category: 'PROBLEMA', // CONSULTA | PROBLEMA | SUGERENCIA | OTRO
55
- priority: 'MEDIA', // BAJA | MEDIA | ALTA | CRITICA
55
+ priority: 'MEDIA', // BAJA | MEDIA | ALTA | CRÍTICA
56
56
  context: { // opcional
57
57
  url: window.location.href,
58
58
  appVersion: '1.2.3',
@@ -104,7 +104,7 @@ await sdk.tickets.close('ticket-uuid', 'user-123');
104
104
  await sdk.tickets.reopen('ticket-uuid', 'user-123');
105
105
  ```
106
106
 
107
- ### Obtener Mensajes No Leidos
107
+ ### Obtener Mensajes No Leídos
108
108
 
109
109
  ```typescript
110
110
  const { count } = await sdk.tickets.getUnreadCount('user-123');
@@ -113,6 +113,50 @@ if (count > 0) {
113
113
  }
114
114
  ```
115
115
 
116
+ ### Reportar Error
117
+
118
+ ```typescript
119
+ const result = await sdk.errors.report({
120
+ message: 'Error al procesar pago',
121
+ module: 'payment-processor',
122
+ severity: 'critical',
123
+ stack: error.stack,
124
+ endpoint: '/api/payments',
125
+ method: 'POST',
126
+ context: {
127
+ gatewayId: 'stripe',
128
+ orderId: 'order-456',
129
+ },
130
+ });
131
+
132
+ console.log(result.hash); // Hash único del error
133
+ console.log(result.deduplicated); // true si el error ya existía
134
+ ```
135
+
136
+ ### Listar Errores
137
+
138
+ ```typescript
139
+ const result = await sdk.errors.list({
140
+ severity: ['critical', 'high'],
141
+ resolved: false,
142
+ limit: 20,
143
+ });
144
+
145
+ console.log(result.errors);
146
+ console.log(result.pagination.total);
147
+ ```
148
+
149
+ ### Estadísticas de Errores
150
+
151
+ ```typescript
152
+ const stats = await sdk.errors.stats();
153
+
154
+ console.log(stats.total); // Total de errores
155
+ console.log(stats.unresolved); // Errores sin resolver
156
+ console.log(stats.bySeverity); // { critical: 5, high: 10, ... }
157
+ console.log(stats.byModule); // { auth: 3, payments: 7, ... }
158
+ ```
159
+
116
160
  ## Manejo de Errores
117
161
 
118
162
  ```typescript
@@ -124,13 +168,13 @@ try {
124
168
  if (error instanceof UtiliaSDKError) {
125
169
  switch (error.code) {
126
170
  case ErrorCode.UNAUTHORIZED:
127
- console.error('API Key invalida');
171
+ console.error('API Key inválida');
128
172
  break;
129
173
  case ErrorCode.RATE_LIMITED:
130
174
  console.error('Demasiadas peticiones, espera antes de reintentar');
131
175
  break;
132
176
  case ErrorCode.VALIDATION_ERROR:
133
- console.error('Datos invalidos:', error.message);
177
+ console.error('Datos inválidos:', error.message);
134
178
  break;
135
179
  case ErrorCode.NOT_FOUND:
136
180
  console.error('Recurso no encontrado');
@@ -141,7 +185,7 @@ try {
141
185
 
142
186
  // Verificar si se puede reintentar
143
187
  if (error.isRetryable()) {
144
- // Implementar logica de reintento
188
+ // Implementar lógica de reintento
145
189
  }
146
190
  }
147
191
  }
@@ -153,7 +197,7 @@ El SDK exporta todos los tipos TypeScript necesarios:
153
197
 
154
198
  ```typescript
155
199
  import type {
156
- // Configuracion
200
+ // Configuración
157
201
  UtiliaSDKConfig,
158
202
 
159
203
  // Tickets
@@ -169,6 +213,13 @@ import type {
169
213
  IdentifyUserInput,
170
214
  ExternalUser,
171
215
 
216
+ // Errores del sistema
217
+ ReportErrorInput,
218
+ ReportedError,
219
+ SystemError,
220
+ ErrorFilters,
221
+ ErrorStats,
222
+
172
223
  // Comunes
173
224
  TicketStatus,
174
225
  TicketCategory,