@angelitosystems/devtools-protocol 0.1.0 → 1.0.2
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 +86 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @angelitosystems/devtools-protocol
|
|
2
|
+
|
|
3
|
+
> Tipos y utilidades compartidas para el protocolo WebSocket de NestJS DevTools.
|
|
4
|
+
|
|
5
|
+
Este paquete define el contrato entre el SDK, el servidor y el dashboard. No tiene dependencias de runtime y puede utilizarse en Node.js, Bun o una aplicacion web.
|
|
6
|
+
|
|
7
|
+
## Instalacion
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @angelitosystems/devtools-protocol
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bun add @angelitosystems/devtools-protocol
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Exportaciones
|
|
18
|
+
|
|
19
|
+
El paquete exporta:
|
|
20
|
+
|
|
21
|
+
- `DevToolsMessage`, `DevToolsEvent`, `DevToolsEventMap` y los payloads tipados.
|
|
22
|
+
- `DevToolsEventName` y `PROTOCOL_VERSION`.
|
|
23
|
+
- `createMessage`, `parseMessage` y `randomId` para construir y validar mensajes.
|
|
24
|
+
- `Redactor`, `redactValue`, `redactText` y `defaultRedactor`.
|
|
25
|
+
- Utilidades para enlaces profundos de VS Code y Cursor.
|
|
26
|
+
|
|
27
|
+
## Crear un mensaje tipado
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import {
|
|
31
|
+
createMessage,
|
|
32
|
+
PROTOCOL_VERSION,
|
|
33
|
+
type DevToolsMessage,
|
|
34
|
+
type LogPayload,
|
|
35
|
+
} from '@angelitosystems/devtools-protocol';
|
|
36
|
+
|
|
37
|
+
const payload: LogPayload = {
|
|
38
|
+
projectId: 'catalog-api',
|
|
39
|
+
level: 'info',
|
|
40
|
+
message: 'Application started',
|
|
41
|
+
processId: process.pid,
|
|
42
|
+
timestamp: Date.now(),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const message: DevToolsMessage<LogPayload> = createMessage(
|
|
46
|
+
'log.created',
|
|
47
|
+
payload,
|
|
48
|
+
{ projectId: 'catalog-api' },
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
console.log(PROTOCOL_VERSION, message.event, message.payload.message);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Los nombres de evento y sus payloads estan relacionados mediante `DevToolsEventMap`; TypeScript detectara un payload incompatible con el evento elegido.
|
|
55
|
+
|
|
56
|
+
## Redaccion de datos
|
|
57
|
+
|
|
58
|
+
Antes de enviar informacion de una aplicacion, puedes eliminar secretos con el redactor incluido:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { Redactor } from '@angelitosystems/devtools-protocol';
|
|
62
|
+
|
|
63
|
+
const redactor = new Redactor({ redact: ['internalId'] });
|
|
64
|
+
|
|
65
|
+
redactor.redact({ password: 'secret', email: 'dev@example.com' });
|
|
66
|
+
// { password: '[REDACTED]', email: 'dev@example.com' }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
La politica predeterminada cubre contrasenas, tokens, cookies, autorizaciones, claves privadas y nombres sensibles similares. Tambien limita la profundidad y el tamano de los valores capturados.
|
|
70
|
+
|
|
71
|
+
## Compatibilidad
|
|
72
|
+
|
|
73
|
+
`PROTOCOL_VERSION` es `1`. Un cambio incompatible en el envelope o en los payloads requiere incrementar esta version.
|
|
74
|
+
|
|
75
|
+
## Desarrollo
|
|
76
|
+
|
|
77
|
+
Desde el monorepo:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
bun run --cwd packages/protocol build
|
|
81
|
+
bun test packages/protocol
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Licencia
|
|
85
|
+
|
|
86
|
+
MIT. Consulta la documentacion general en [`docs/architecture.md`](../../docs/architecture.md).
|