@gnpdev/rpa-tools 1.0.4 → 1.0.6
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 +28 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,8 +21,8 @@ Crea un archivo en tu proyecto (ej. `src/lib/rpa.js`) para inicializar y exporta
|
|
|
21
21
|
|
|
22
22
|
```javascript
|
|
23
23
|
// src/lib/rpa.js
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
import { createRpaTools } from '@strujillodv/rpa-tools';
|
|
25
|
+
import { Pool } from 'pg';
|
|
26
26
|
|
|
27
27
|
// 1. Configura tu pool de base de datos (usualmente ya lo tienes)
|
|
28
28
|
const pool = new Pool({
|
|
@@ -30,27 +30,24 @@ const pool = new Pool({
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
// 2. Inicializa las herramientas
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = initRpa;
|
|
33
|
+
export const rpa = await createRpaTools({
|
|
34
|
+
botId: process.env.RPA_BOT_ID,
|
|
35
|
+
db: pool,
|
|
36
|
+
minio: {
|
|
37
|
+
endPoint: process.env.MINIO_ENDPOINT,
|
|
38
|
+
port: parseInt(process.env.MINIO_PORT || '9000'),
|
|
39
|
+
useSSL: process.env.MINIO_USE_SSL === 'true',
|
|
40
|
+
accessKey: process.env.MINIO_ACCESS_KEY,
|
|
41
|
+
secretKey: process.env.MINIO_SECRET_KEY,
|
|
42
|
+
bucket: 'rpa-screenshots'
|
|
43
|
+
},
|
|
44
|
+
log: {
|
|
45
|
+
level: process.env.NODE_ENV === 'development' ? 'debug' : 'info',
|
|
46
|
+
pretty: process.env.NODE_ENV !== 'production',
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export const logger = rpa.logger;
|
|
54
51
|
```
|
|
55
52
|
|
|
56
53
|
## Uso en la Aplicación
|
|
@@ -59,14 +56,19 @@ module.exports = initRpa;
|
|
|
59
56
|
Usa el logger preconfigurado que ya incluye el `botId` en cada entrada.
|
|
60
57
|
|
|
61
58
|
```javascript
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
import { logger, rpa } from './lib/rpa.js';
|
|
60
|
+
|
|
61
|
+
logger.info('Procesando orden');
|
|
64
62
|
```
|
|
65
63
|
|
|
66
64
|
### 2. Gestión de Credenciales
|
|
67
65
|
Recupera de forma segura el `usuario`, `password` e `idUsuario` de una aplicación específica vinculada al bot.
|
|
68
66
|
|
|
69
67
|
```javascript
|
|
68
|
+
import { logger, rpa } from './lib/rpa.js';
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
logger.info('Optener creddenciales');
|
|
70
72
|
const credentials = await rpa.getCredentials('Portal CRM');
|
|
71
73
|
|
|
72
74
|
if (credentials) {
|
|
@@ -80,7 +82,7 @@ Activa el watcher pasando la instancia de `page`. El bot detectará cambios en l
|
|
|
80
82
|
|
|
81
83
|
```javascript
|
|
82
84
|
const { chromium } = require('playwright');
|
|
83
|
-
|
|
85
|
+
import { rpa } from './lib/rpa.js';
|
|
84
86
|
|
|
85
87
|
const browser = await chromium.launch();
|
|
86
88
|
const page = await browser.newPage();
|