@laburen/delta-sdk 1.3.0 → 1.5.0-canary.10
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/CHANGELOG.md +24 -0
- package/README.md +3 -0
- package/dist/core/config.d.ts +12 -12
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +88 -88
- package/dist/core/config.js.map +1 -1
- package/dist/core/{constantes.d.ts → constants.d.ts} +3 -3
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/{constantes.js → constants.js} +3 -3
- package/dist/core/constants.js.map +1 -0
- package/dist/core/{contadores.d.ts → counters.d.ts} +12 -11
- package/dist/core/counters.d.ts.map +1 -0
- package/dist/core/counters.js +53 -0
- package/dist/core/counters.js.map +1 -0
- package/dist/core/{sobre.d.ts → envelope.d.ts} +17 -17
- package/dist/core/envelope.d.ts.map +1 -0
- package/dist/core/envelope.js +198 -0
- package/dist/core/envelope.js.map +1 -0
- package/dist/core/scrubbing.d.ts +4 -4
- package/dist/core/scrubbing.d.ts.map +1 -1
- package/dist/core/scrubbing.js +38 -38
- package/dist/core/scrubbing.js.map +1 -1
- package/dist/core/{sesion.d.ts → session.d.ts} +2 -2
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/{sesion.js → session.js} +2 -2
- package/dist/core/session.js.map +1 -0
- package/dist/core/{transporte.d.ts → transport.d.ts} +9 -9
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/{transporte.js → transport.js} +15 -15
- package/dist/core/transport.js.map +1 -0
- package/dist/core/{tipos.d.ts → types.d.ts} +4 -4
- package/dist/core/{tipos.d.ts.map → types.d.ts.map} +1 -1
- package/dist/core/{tipos.js → types.js} +1 -1
- package/dist/core/{tipos.js.map → types.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/platform/client.d.ts +8 -0
- package/dist/platform/client.d.ts.map +1 -0
- package/dist/platform/client.js +30 -0
- package/dist/platform/client.js.map +1 -0
- package/dist/platform/core/errors.d.ts +150 -0
- package/dist/platform/core/errors.d.ts.map +1 -0
- package/dist/platform/core/errors.js +265 -0
- package/dist/platform/core/errors.js.map +1 -0
- package/dist/platform/core/oauth.d.ts +37 -0
- package/dist/platform/core/oauth.d.ts.map +1 -0
- package/dist/platform/core/oauth.js +144 -0
- package/dist/platform/core/oauth.js.map +1 -0
- package/dist/platform/core/pagination.d.ts +30 -0
- package/dist/platform/core/pagination.d.ts.map +1 -0
- package/dist/platform/core/pagination.js +44 -0
- package/dist/platform/core/pagination.js.map +1 -0
- package/dist/platform/core/request.d.ts +6 -0
- package/dist/platform/core/request.d.ts.map +1 -0
- package/dist/platform/core/request.js +24 -0
- package/dist/platform/core/request.js.map +1 -0
- package/dist/platform/core/send.d.ts +36 -0
- package/dist/platform/core/send.d.ts.map +1 -0
- package/dist/platform/core/send.js +171 -0
- package/dist/platform/core/send.js.map +1 -0
- package/dist/platform/core/sse.d.ts +8 -0
- package/dist/platform/core/sse.d.ts.map +1 -0
- package/dist/platform/core/sse.js +72 -0
- package/dist/platform/core/sse.js.map +1 -0
- package/dist/platform/core/stream.d.ts +21 -0
- package/dist/platform/core/stream.d.ts.map +1 -0
- package/dist/platform/core/stream.js +268 -0
- package/dist/platform/core/stream.js.map +1 -0
- package/dist/platform/generated/resources.d.ts +120 -0
- package/dist/platform/generated/resources.d.ts.map +1 -0
- package/dist/platform/generated/resources.js +65 -0
- package/dist/platform/generated/resources.js.map +1 -0
- package/dist/platform/generated/schemas.d.ts +78 -0
- package/dist/platform/generated/schemas.d.ts.map +1 -0
- package/dist/platform/generated/schemas.js +2 -0
- package/dist/platform/generated/schemas.js.map +1 -0
- package/dist/platform/generated/types.d.ts +5167 -0
- package/dist/platform/generated/types.d.ts.map +1 -0
- package/dist/platform/generated/types.js +6 -0
- package/dist/platform/generated/types.js.map +1 -0
- package/dist/platform/index.d.ts +9 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +7 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/telemetry/{captura.d.ts → capture.d.ts} +3 -3
- package/dist/telemetry/capture.d.ts.map +1 -0
- package/dist/telemetry/{captura.js → capture.js} +54 -54
- package/dist/telemetry/capture.js.map +1 -0
- package/dist/telemetry/index.d.ts +2 -2
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/{tipos.d.ts → types.d.ts} +2 -2
- package/dist/telemetry/types.d.ts.map +1 -0
- package/dist/telemetry/types.js +2 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/telemetry/with-telemetry.d.ts +9 -9
- package/dist/telemetry/with-telemetry.d.ts.map +1 -1
- package/dist/telemetry/with-telemetry.js +31 -31
- package/dist/telemetry/with-telemetry.js.map +1 -1
- package/dist/telemetry/with-tool.d.ts +2 -2
- package/dist/telemetry/with-tool.d.ts.map +1 -1
- package/dist/telemetry/with-tool.js +3 -3
- package/dist/telemetry/with-tool.js.map +1 -1
- package/docs/platform/guide.md +554 -0
- package/docs/telemetry/que-se-manda.md +2 -2
- package/docs/telemetry/troubleshooting.md +1 -1
- package/package.json +15 -5
- package/src/core/config.ts +81 -83
- package/src/core/{constantes.ts → constants.ts} +2 -2
- package/src/core/counters.ts +72 -0
- package/src/core/envelope.ts +234 -0
- package/src/core/scrubbing.ts +41 -41
- package/src/core/{sesion.ts → session.ts} +1 -1
- package/src/core/{transporte.ts → transport.ts} +20 -20
- package/src/core/{tipos.ts → types.ts} +3 -3
- package/src/index.ts +1 -1
- package/src/platform/client.ts +32 -0
- package/src/platform/core/errors.ts +348 -0
- package/src/platform/core/oauth.ts +201 -0
- package/src/platform/core/pagination.ts +67 -0
- package/src/platform/core/request.ts +27 -0
- package/src/platform/core/send.ts +212 -0
- package/src/platform/core/sse.ts +68 -0
- package/src/platform/core/stream.ts +314 -0
- package/src/platform/generated/resources.ts +192 -0
- package/src/platform/generated/schemas.ts +79 -0
- package/src/platform/generated/types.ts +5167 -0
- package/src/platform/index.ts +45 -0
- package/src/telemetry/{captura.ts → capture.ts} +57 -57
- package/src/telemetry/index.ts +2 -2
- package/src/telemetry/{tipos.ts → types.ts} +1 -1
- package/src/telemetry/with-telemetry.ts +51 -54
- package/src/telemetry/with-tool.ts +5 -5
- package/dist/core/constantes.d.ts.map +0 -1
- package/dist/core/constantes.js.map +0 -1
- package/dist/core/contadores.d.ts.map +0 -1
- package/dist/core/contadores.js +0 -53
- package/dist/core/contadores.js.map +0 -1
- package/dist/core/sesion.d.ts.map +0 -1
- package/dist/core/sesion.js.map +0 -1
- package/dist/core/sobre.d.ts.map +0 -1
- package/dist/core/sobre.js +0 -200
- package/dist/core/sobre.js.map +0 -1
- package/dist/core/transporte.d.ts.map +0 -1
- package/dist/core/transporte.js.map +0 -1
- package/dist/telemetry/captura.d.ts.map +0 -1
- package/dist/telemetry/captura.js.map +0 -1
- package/dist/telemetry/tipos.d.ts.map +0 -1
- package/dist/telemetry/tipos.js +0 -2
- package/dist/telemetry/tipos.js.map +0 -1
- package/src/core/contadores.ts +0 -71
- package/src/core/sobre.ts +0 -236
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ Formato: [Keep a Changelog](https://keepachangelog.com/es-ES/1.1.0/).
|
|
|
4
4
|
El paquete es **additive-only**: se agregan funciones y campos opcionales, nunca se renombra ni se
|
|
5
5
|
saca nada. Un worker que se queda en una versión vieja sigue funcionando.
|
|
6
6
|
|
|
7
|
+
## [1.5.0] — 2026-11-05
|
|
8
|
+
|
|
9
|
+
La puerta `/platform` suma `agents.generate` y `agents.stream`: correr un turno de un agente. `generate` devuelve el JSON final; `stream` devuelve `{ chunks, result }` (`chunks` es un `AsyncIterable` de pedazos y `result` se resuelve con el `finish` y el texto completo). Tipos nuevos: `AgentStream`, `AgentRunChunk` y `AgentRunMetadata`. El timeout de estas dos rutas viene del contrato (630 s por intento). Ver `docs/platform/guide.md`, sección 8.
|
|
10
|
+
|
|
11
|
+
La puerta `/platform` suma las rutas de la etapa agregar: `models.list`, `me.get`, `knowledge.projects.list`, `mcp.connections.tools.list` y `meta.schemas.agentConfig`. Códigos de error nuevos: `base_version_mismatch` y `mcp_connection_name_taken`. En `config.knowledge`, `datastore_ids` se reemplazó por `project_ids`: el campo viejo se quitó del contrato, no solo se sumó el nuevo.
|
|
12
|
+
|
|
13
|
+
Cada item de `models.list` suma `capabilities.image_handling` (`native` o `described_as_text`) y `capabilities.pdf_handling` (`native`, `text_and_image_per_page` o `transcribed_to_text`): cómo le llega cada adjunto al modelo. `pricing.cache_write` se quitó del contrato.
|
|
14
|
+
|
|
15
|
+
La vista de versión del agente puede traer `warnings` (`mcp_tools_unverified`, con `connection_id`) y un filtro `tools` de una asignación MCP con un nombre desconocido devuelve 400 `invalid_request`.
|
|
16
|
+
|
|
17
|
+
El config del agente acepta `$schema` (string opcional); la API lo ignora y no lo guarda.
|
|
18
|
+
|
|
19
|
+
El contrato suma las reglas de tools y effort: `reasoning_effort` debe ser un nivel del modelo, las variantes de tool únicas (todas menos `http`) se marcan con `x-single: true`, y la tool `thinking` no va con un modelo que razona salvo con effort `off`.
|
|
20
|
+
|
|
21
|
+
## [1.4.0] — 2026-11-02
|
|
22
|
+
|
|
23
|
+
Nueva puerta `/platform`. No hay que hacer nada si no la usás.
|
|
24
|
+
|
|
25
|
+
`waitForDeviceToken` ya no corta ante un error de red o un timeout: espera 5 segundos más y vuelve a consultar hasta el vencimiento. La puerta exporta `DEFAULT_BASE_URL`.
|
|
26
|
+
|
|
27
|
+
## [1.3.1] — 2026-11-02
|
|
28
|
+
|
|
29
|
+
Cambio interno: nombres de código en inglés. No hay que hacer nada.
|
|
30
|
+
|
|
7
31
|
## [1.3.0] — 2026-08-05
|
|
8
32
|
|
|
9
33
|
Solo documentación. **El código no cambió**: si ya estás en `1.2.0`, actualizar es opcional. Es una
|
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ conviviendo en el mismo paquete.
|
|
|
12
12
|
|---|---|
|
|
13
13
|
| `@laburen/delta-sdk` | la raíz: solo los tipos compartidos entre puertas (`Envelope`, `Notify`, `Severity`, `Surface`, `TelemetryEvent`) — sin runtime |
|
|
14
14
|
| [`@laburen/delta-sdk/telemetry`](#telemetry) | le manda los errores y eventos de tu worker a la ingesta de telemetría (`telemetry.laburen.com`), que los guarda en D1 y avisa por Slack al canal del cliente |
|
|
15
|
+
| [`@laburen/delta-sdk/platform`](docs/platform/guide.md) | cliente tipado de la API de plataforma (`dashboard.laburen.com/api/platform/v1`): agentes, skills, conexiones MCP, tokens, modelos, `me` y proyectos de conocimiento, más el login por device code |
|
|
15
16
|
|
|
16
17
|
Instalar el paquete, la API key y el `ctx` son iguales para cualquier puerta: ver
|
|
17
18
|
[docs/empezar.md](docs/empezar.md).
|
|
@@ -139,6 +140,8 @@ un grupo nuevo y el dedup de la ingesta no sirve.
|
|
|
139
140
|
| [docs/telemetry/que-se-manda.md](docs/telemetry/que-se-manda.md) | el contrato de `/telemetry` en prosa, con un payload de ejemplo |
|
|
140
141
|
| [docs/telemetry/troubleshooting.md](docs/telemetry/troubleshooting.md) | síntomas propios de `/telemetry`: 413, los límites del scrubbing |
|
|
141
142
|
|
|
143
|
+
Para usar la API de plataforma desde la terminal, hay una CLI: `@laburen/delta-cli` (comando `laburen`).
|
|
144
|
+
|
|
142
145
|
El TypeScript real está en `node_modules/@laburen/delta-sdk/src/`: si algo no cierra, se lee.
|
|
143
146
|
|
|
144
147
|
## Versionado
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Notify, type Surface, type TelemetryConfig, type TelemetryEvent } from "./
|
|
2
|
-
export interface
|
|
1
|
+
import { type Notify, type Surface, type TelemetryConfig, type TelemetryEvent } from "./types.js";
|
|
2
|
+
export interface ValidatedConfig {
|
|
3
3
|
service: {
|
|
4
4
|
name: string;
|
|
5
5
|
version?: string;
|
|
@@ -12,16 +12,16 @@ export interface ConfigValidada {
|
|
|
12
12
|
notify: Notify;
|
|
13
13
|
ingestUrl: string;
|
|
14
14
|
scrub: string[];
|
|
15
|
-
beforeSend?: (
|
|
15
|
+
beforeSend?: (event: TelemetryEvent) => TelemetryEvent | null;
|
|
16
16
|
debug: boolean;
|
|
17
17
|
queueMaxRetries?: number;
|
|
18
18
|
}
|
|
19
|
-
export type
|
|
19
|
+
export type ConfigResult = {
|
|
20
20
|
ok: true;
|
|
21
|
-
config:
|
|
21
|
+
config: ValidatedConfig;
|
|
22
22
|
} | {
|
|
23
23
|
ok: false;
|
|
24
|
-
|
|
24
|
+
missing: string[];
|
|
25
25
|
};
|
|
26
26
|
/** El motivo por el que `notify` no es usable, o `null` si lo es. Dos reglas, no una: (a) un canal
|
|
27
27
|
* DECLARADO (`enabled: true`) pero incompleto invalida TODA la config, aunque el otro canal esté
|
|
@@ -31,14 +31,14 @@ export type ResultadoConfig = {
|
|
|
31
31
|
* `notify` armado con un getter o un `Proxy` que lanza al leer sus propiedades cuenta como "no
|
|
32
32
|
* usable", no como una excepción que se escapa de `createTelemetry` — el SDK no lanza nunca, ni
|
|
33
33
|
* con el notify más raro. */
|
|
34
|
-
export declare function
|
|
35
|
-
/** Wrapper booleano de `
|
|
36
|
-
* `notify` sirve (el override por evento de `
|
|
37
|
-
export declare function
|
|
34
|
+
export declare function invalidNotifyReason(notify: unknown): string | null;
|
|
35
|
+
/** Wrapper booleano de `invalidNotifyReason`, para los callers que solo necesitan saber si el
|
|
36
|
+
* `notify` sirve (el override por evento de `capture.ts`) sin mostrar el motivo. */
|
|
37
|
+
export declare function usableNotify(notify: unknown): boolean;
|
|
38
38
|
/** Un `queueMaxRetries` usable es un entero ≥ 0: sale del `max_retries` del `wrangler.jsonc` vía
|
|
39
39
|
* una `var` del env, que siempre es `string` — `"2" + 1` da `"21"`, no `3`. */
|
|
40
|
-
export declare function queueMaxRetriesUsable(
|
|
40
|
+
export declare function queueMaxRetriesUsable(value: unknown): value is number;
|
|
41
41
|
/** Valida en runtime lo que el tipo no puede: un campo que llega vacío desde el env es un string
|
|
42
42
|
* válido para TypeScript, y significa que ese worker nunca va a reportar nada. */
|
|
43
|
-
export declare function
|
|
43
|
+
export declare function validate(input: TelemetryConfig): ConfigResult;
|
|
44
44
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,MAAM,EAEX,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,MAAM,EAEX,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,GAAG,IAAI,CAAC;IAC9D,KAAK,EAAE,OAAO,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAsEpG;;;;;;;8BAO8B;AAC9B,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiBlE;AAED;qFACqF;AACrF,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;gFACgF;AAChF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAErE;AAED;mFACmF;AACnF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAyC7D"}
|
package/dist/core/config.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { INGEST_URL } from "./
|
|
2
|
-
import { SURFACES, } from "./
|
|
1
|
+
import { INGEST_URL } from "./constants.js";
|
|
2
|
+
import { SURFACES, } from "./types.js";
|
|
3
3
|
// Los `?.` no son paranoia: los valores salen del env del worker, y ahí TypeScript no manda.
|
|
4
|
-
function
|
|
5
|
-
return typeof
|
|
4
|
+
function empty(value) {
|
|
5
|
+
return typeof value !== "string" || value.trim() === "";
|
|
6
6
|
}
|
|
7
|
-
// Mismo criterio que `
|
|
7
|
+
// Mismo criterio que `textOf` en envelope.ts: un aviso no puede lanzar por describir el valor que
|
|
8
8
|
// está avisando. `JSON.stringify` no sabe serializar un `BigInt` (un `queueMaxRetries` armado con
|
|
9
9
|
// uno lo hace lanzar), así que cae a `String()` en vez de romper el aviso.
|
|
10
|
-
function
|
|
10
|
+
function describeValue(value) {
|
|
11
11
|
try {
|
|
12
|
-
return JSON.stringify(
|
|
12
|
+
return JSON.stringify(value) ?? String(value);
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
15
|
-
return String(
|
|
15
|
+
return String(value);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
// El mismo regex que aplica la ingesta: el contrato ya está duplicado a propósito, así que
|
|
@@ -20,56 +20,56 @@ function describirValor(valor) {
|
|
|
20
20
|
const SLACK_CHANNEL_ID = /^[CGD][A-Z0-9]{8,}$/;
|
|
21
21
|
// Objetos sueltos porque vienen de un `unknown` en runtime (env, fila de D1): no se puede confiar
|
|
22
22
|
// en que respeten el tipo `Notify` solo porque TypeScript los tipó así en el archivo del cliente.
|
|
23
|
-
// "
|
|
23
|
+
// "undeclared" es un canal AUSENTE (la clave `slack`/`email` no está, o `enabled` es `false`); un
|
|
24
24
|
// canal PRESENTE cuyo `enabled` es truthy pero no un booleano estricto (un `1` de una columna
|
|
25
25
|
// INTEGER de D1 usada como boolean, el mismo patrón que ya cita `emailPlausible` más abajo) es
|
|
26
|
-
// "
|
|
26
|
+
// "incomplete", no "undeclared": la ingesta valida `enabled` con un union discriminado entre los
|
|
27
27
|
// literales `true`/`false`, y cualquier otro valor le rompe el discriminante — `notify` sale crudo
|
|
28
28
|
// al sobre si el OTRO canal es válido, y la ingesta lo rechaza con "Invalid discriminator value"
|
|
29
29
|
// mientras el SDK cree que la config está sana.
|
|
30
|
-
function
|
|
30
|
+
function slackState(slack) {
|
|
31
31
|
if (typeof slack !== "object" || slack === null)
|
|
32
|
-
return "
|
|
33
|
-
const
|
|
34
|
-
if (typeof
|
|
35
|
-
return "
|
|
36
|
-
if (
|
|
37
|
-
return "
|
|
38
|
-
return typeof
|
|
39
|
-
? "
|
|
40
|
-
: "
|
|
32
|
+
return "undeclared";
|
|
33
|
+
const value = slack;
|
|
34
|
+
if (typeof value.enabled !== "boolean")
|
|
35
|
+
return "incomplete";
|
|
36
|
+
if (value.enabled === false)
|
|
37
|
+
return "undeclared";
|
|
38
|
+
return typeof value.channel === "string" && SLACK_CHANNEL_ID.test(value.channel)
|
|
39
|
+
? "complete"
|
|
40
|
+
: "incomplete";
|
|
41
41
|
}
|
|
42
42
|
/** Deliberadamente MÁS PERMISIVO que el `z.email()` de la ingesta (verificado con un fuzz test en
|
|
43
43
|
* `test/config.test.ts` que compara contra el Zod real): atrapa la basura obvia —sin `@`, con
|
|
44
44
|
* espacios o comas, sin un dominio con punto— y nada más. Quedar más estricto que la ingesta es
|
|
45
45
|
* peor que el 400 mudo que este archivo cierra: una dirección real rechazada acá manda TODO el
|
|
46
46
|
* worker a inerte, no solo ese evento. */
|
|
47
|
-
function emailPlausible(
|
|
48
|
-
if (typeof
|
|
47
|
+
function emailPlausible(value) {
|
|
48
|
+
if (typeof value !== "string" || value === "" || value.trim() !== value)
|
|
49
49
|
return false;
|
|
50
|
-
if (/\s/.test(
|
|
50
|
+
if (/\s/.test(value) || value.includes(","))
|
|
51
51
|
return false;
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
52
|
+
const atSign = value.indexOf("@");
|
|
53
|
+
if (atSign <= 0 || atSign !== value.lastIndexOf("@"))
|
|
54
54
|
return false;
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
55
|
+
const domain = value.slice(atSign + 1);
|
|
56
|
+
if (domain === "" || !domain.includes("."))
|
|
57
57
|
return false;
|
|
58
|
-
return !
|
|
58
|
+
return !domain.startsWith(".") && !domain.endsWith(".");
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function emailState(email) {
|
|
61
61
|
if (typeof email !== "object" || email === null)
|
|
62
|
-
return "
|
|
63
|
-
const
|
|
62
|
+
return "undeclared";
|
|
63
|
+
const value = email;
|
|
64
64
|
// Mismo criterio que `estadoSlack`: un `enabled` truthy pero no booleano estricto es
|
|
65
|
-
// "
|
|
66
|
-
if (typeof
|
|
67
|
-
return "
|
|
68
|
-
if (
|
|
69
|
-
return "
|
|
70
|
-
return Array.isArray(
|
|
71
|
-
? "
|
|
72
|
-
: "
|
|
65
|
+
// "incomplete", no "undeclared".
|
|
66
|
+
if (typeof value.enabled !== "boolean")
|
|
67
|
+
return "incomplete";
|
|
68
|
+
if (value.enabled === false)
|
|
69
|
+
return "undeclared";
|
|
70
|
+
return Array.isArray(value.to) && value.to.length > 0 && value.to.every(emailPlausible)
|
|
71
|
+
? "complete"
|
|
72
|
+
: "incomplete";
|
|
73
73
|
}
|
|
74
74
|
/** El motivo por el que `notify` no es usable, o `null` si lo es. Dos reglas, no una: (a) un canal
|
|
75
75
|
* DECLARADO (`enabled: true`) pero incompleto invalida TODA la config, aunque el otro canal esté
|
|
@@ -79,19 +79,19 @@ function estadoEmail(email) {
|
|
|
79
79
|
* `notify` armado con un getter o un `Proxy` que lanza al leer sus propiedades cuenta como "no
|
|
80
80
|
* usable", no como una excepción que se escapa de `createTelemetry` — el SDK no lanza nunca, ni
|
|
81
81
|
* con el notify más raro. */
|
|
82
|
-
export function
|
|
82
|
+
export function invalidNotifyReason(notify) {
|
|
83
83
|
try {
|
|
84
84
|
if (typeof notify !== "object" || notify === null) {
|
|
85
85
|
return "notify (revisá slack.channel / email.to)";
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
const slack =
|
|
89
|
-
const email =
|
|
90
|
-
if (slack === "
|
|
87
|
+
const value = notify;
|
|
88
|
+
const slack = slackState(value.slack);
|
|
89
|
+
const email = emailState(value.email);
|
|
90
|
+
if (slack === "incomplete")
|
|
91
91
|
return "notify: slack.channel declarado pero vacío o mal formado";
|
|
92
|
-
if (email === "
|
|
92
|
+
if (email === "incomplete")
|
|
93
93
|
return "notify: email.to declarado pero vacío o mal formado";
|
|
94
|
-
if (slack !== "
|
|
94
|
+
if (slack !== "complete" && email !== "complete") {
|
|
95
95
|
return "notify (revisá slack.channel / email.to)";
|
|
96
96
|
}
|
|
97
97
|
return null;
|
|
@@ -100,62 +100,62 @@ export function motivoNotifyInvalido(notify) {
|
|
|
100
100
|
return "notify (no se pudo leer: revisá slack.channel / email.to)";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
/** Wrapper booleano de `
|
|
104
|
-
* `notify` sirve (el override por evento de `
|
|
105
|
-
export function
|
|
106
|
-
return
|
|
103
|
+
/** Wrapper booleano de `invalidNotifyReason`, para los callers que solo necesitan saber si el
|
|
104
|
+
* `notify` sirve (el override por evento de `capture.ts`) sin mostrar el motivo. */
|
|
105
|
+
export function usableNotify(notify) {
|
|
106
|
+
return invalidNotifyReason(notify) === null;
|
|
107
107
|
}
|
|
108
108
|
/** Un `queueMaxRetries` usable es un entero ≥ 0: sale del `max_retries` del `wrangler.jsonc` vía
|
|
109
109
|
* una `var` del env, que siempre es `string` — `"2" + 1` da `"21"`, no `3`. */
|
|
110
|
-
export function queueMaxRetriesUsable(
|
|
111
|
-
return typeof
|
|
110
|
+
export function queueMaxRetriesUsable(value) {
|
|
111
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
112
112
|
}
|
|
113
113
|
/** Valida en runtime lo que el tipo no puede: un campo que llega vacío desde el env es un string
|
|
114
114
|
* válido para TypeScript, y significa que ese worker nunca va a reportar nada. */
|
|
115
|
-
export function
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
if (!SURFACES.includes(
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
return { ok: false,
|
|
132
|
-
const service = { name:
|
|
133
|
-
if (
|
|
134
|
-
service.version =
|
|
135
|
-
if (
|
|
136
|
-
service.environment =
|
|
115
|
+
export function validate(input) {
|
|
116
|
+
const missing = [];
|
|
117
|
+
if (empty(input.service?.name))
|
|
118
|
+
missing.push("service.name");
|
|
119
|
+
if (empty(input.organizationId))
|
|
120
|
+
missing.push("organizationId");
|
|
121
|
+
if (empty(input.agentId))
|
|
122
|
+
missing.push("agentId");
|
|
123
|
+
if (empty(input.apiKey))
|
|
124
|
+
missing.push("apiKey");
|
|
125
|
+
if (!SURFACES.includes(input.surface))
|
|
126
|
+
missing.push("surface");
|
|
127
|
+
const notifyReason = invalidNotifyReason(input.notify);
|
|
128
|
+
if (notifyReason !== null)
|
|
129
|
+
missing.push(notifyReason);
|
|
130
|
+
if (missing.length > 0)
|
|
131
|
+
return { ok: false, missing };
|
|
132
|
+
const service = { name: input.service.name.trim() };
|
|
133
|
+
if (input.service.version !== undefined)
|
|
134
|
+
service.version = input.service.version;
|
|
135
|
+
if (input.service.environment !== undefined)
|
|
136
|
+
service.environment = input.service.environment;
|
|
137
137
|
const config = {
|
|
138
138
|
service,
|
|
139
|
-
surface:
|
|
140
|
-
organizationId:
|
|
141
|
-
agentId:
|
|
142
|
-
apiKey:
|
|
143
|
-
notify:
|
|
139
|
+
surface: input.surface,
|
|
140
|
+
organizationId: input.organizationId.trim(),
|
|
141
|
+
agentId: input.agentId.trim(),
|
|
142
|
+
apiKey: input.apiKey.trim(),
|
|
143
|
+
notify: input.notify,
|
|
144
144
|
// La URL es constante del paquete; el override existe solo para desarrollo local.
|
|
145
|
-
ingestUrl:
|
|
146
|
-
scrub:
|
|
147
|
-
debug:
|
|
145
|
+
ingestUrl: input.ingestUrl?.trim() || INGEST_URL,
|
|
146
|
+
scrub: input.scrub ?? [],
|
|
147
|
+
debug: input.debug ?? false,
|
|
148
148
|
};
|
|
149
|
-
if (
|
|
150
|
-
config.beforeSend =
|
|
151
|
-
if (
|
|
152
|
-
if (queueMaxRetriesUsable(
|
|
153
|
-
config.queueMaxRetries =
|
|
149
|
+
if (input.beforeSend !== undefined)
|
|
150
|
+
config.beforeSend = input.beforeSend;
|
|
151
|
+
if (input.queueMaxRetries !== undefined) {
|
|
152
|
+
if (queueMaxRetriesUsable(input.queueMaxRetries)) {
|
|
153
|
+
config.queueMaxRetries = input.queueMaxRetries;
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
156
|
// Se descarta y no se suma a `faltan`: a diferencia de los seis obligatorios, sin este
|
|
157
157
|
// dato el cliente sigue reportando — solo se omite `retry.limit` en surface "queue".
|
|
158
|
-
console.error(`[delta-sdk] queueMaxRetries inválido (se esperaba un entero ≥ 0, llegó ${
|
|
158
|
+
console.error(`[delta-sdk] queueMaxRetries inválido (se esperaba un entero ≥ 0, llegó ${describeValue(input.queueMaxRetries)}): se ignora`);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
return { ok: true, config };
|
package/dist/core/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAEN,QAAQ,GAIR,MAAM,YAAY,CAAC;AAkBpB,6FAA6F;AAC7F,SAAS,KAAK,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACzD,CAAC;AAED,kGAAkG;AAClG,kGAAkG;AAClG,2EAA2E;AAC3E,SAAS,aAAa,CAAC,KAAc;IACpC,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC;AAED,2FAA2F;AAC3F,6BAA6B;AAC7B,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAI/C,kGAAkG;AAClG,kGAAkG;AAClG,kGAAkG;AAClG,8FAA8F;AAC9F,+FAA+F;AAC/F,iGAAiG;AACjG,mGAAmG;AACnG,iGAAiG;AACjG,gDAAgD;AAChD,SAAS,UAAU,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,YAAY,CAAC;IACrE,MAAM,KAAK,GAAG,KAAiD,CAAC;IAChE,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,YAAY,CAAC;IAC5D,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,YAAY,CAAC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C/B,OAAO;QACP,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE;QAC3C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;QAC3B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,kFAAkF;QAClF,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,UAAU;QAChD,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK;KAC3B,CAAC;IACF,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAAE,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACzE,IAAI,KAAK,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,qBAAqB,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;YAClD,MAAM,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAChD,CAAC;aAAM,CAAC;YACP,uFAAuF;YACvF,qFAAqF;YACrF,OAAO,CAAC,KAAK,CACZ,0EAA0E,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,cAAc,CAC5H,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
export declare const INGEST_URL = "https://telemetry.laburen.com/events";
|
|
4
4
|
export declare const SDK_NAME = "@laburen/delta-sdk";
|
|
5
5
|
/** Tiene que coincidir con `version` del package.json; lo verifica `npm run version:check`. */
|
|
6
|
-
export declare const SDK_VERSION = "1.
|
|
6
|
+
export declare const SDK_VERSION = "1.5.0-canary.10";
|
|
7
7
|
/** Los mismos topes que aplica la ingesta. El cliente los aplica para no perder el sobre entero;
|
|
8
8
|
* la ingesta, para no confiar en el cliente. */
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const LIMITS: {
|
|
10
10
|
readonly stacktraceChars: number;
|
|
11
11
|
readonly messageChars: number;
|
|
12
12
|
readonly attributeKeys: 64;
|
|
13
13
|
readonly bodyBytes: number;
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA;8DAC8D;AAC9D,eAAO,MAAM,UAAU,yCAAyC,CAAC;AAEjE,eAAO,MAAM,QAAQ,uBAAuB,CAAC;AAE7C,+FAA+F;AAC/F,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAE7C;iDACiD;AACjD,eAAO,MAAM,MAAM;;;;;CAKT,CAAC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
export const INGEST_URL = "https://telemetry.laburen.com/events";
|
|
4
4
|
export const SDK_NAME = "@laburen/delta-sdk";
|
|
5
5
|
/** Tiene que coincidir con `version` del package.json; lo verifica `npm run version:check`. */
|
|
6
|
-
export const SDK_VERSION = "1.
|
|
6
|
+
export const SDK_VERSION = "1.5.0-canary.10";
|
|
7
7
|
/** Los mismos topes que aplica la ingesta. El cliente los aplica para no perder el sobre entero;
|
|
8
8
|
* la ingesta, para no confiar en el cliente. */
|
|
9
|
-
export const
|
|
9
|
+
export const LIMITS = {
|
|
10
10
|
stacktraceChars: 8 * 1024,
|
|
11
11
|
messageChars: 2 * 1024,
|
|
12
12
|
attributeKeys: 64,
|
|
13
13
|
bodyBytes: 512 * 1024,
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA;8DAC8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AAE7C,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE7C;iDACiD;AACjD,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,eAAe,EAAE,CAAC,GAAG,IAAI;IACzB,YAAY,EAAE,CAAC,GAAG,IAAI;IACtB,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,GAAG,GAAG,IAAI;CACZ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/** Lo que viaja en el campo `drops` del sobre.
|
|
1
|
+
/** Lo que viaja en el campo `drops` del sobre. Estas claves SON el contrato de cable con la ingesta
|
|
2
|
+
* (se serializan tal cual) y quedan en español a propósito. La ingesta lo acepta como
|
|
2
3
|
* `z.record(z.string(), z.number())`, así que las claves son libres; `before_send` conserva la
|
|
3
4
|
* grafía canónica de Sentry para las razones de drop. */
|
|
4
5
|
export interface Drops {
|
|
@@ -9,20 +10,20 @@ export interface Drops {
|
|
|
9
10
|
internos: number;
|
|
10
11
|
}
|
|
11
12
|
/** Veces que el código pidió enviar. */
|
|
12
|
-
export declare function
|
|
13
|
+
export declare function countFired(): void;
|
|
13
14
|
/** Envíos que terminaron, con cualquier status: un 429 y un 503 salieron y los rechazaron. */
|
|
14
|
-
export declare function
|
|
15
|
+
export declare function countCompleted(): void;
|
|
15
16
|
/** Envíos que lanzaron: red, DNS. */
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
/** La quinta forma de perder un evento: algo entre `
|
|
20
|
-
* red del `catch` de `
|
|
17
|
+
export declare function countFailed(): void;
|
|
18
|
+
export declare function countBeforeSend(): void;
|
|
19
|
+
export declare function countTrimmed(): void;
|
|
20
|
+
/** La quinta forma de perder un evento: algo entre `buildEvent` y `serializeCapped` lanzó, y la
|
|
21
|
+
* red del `catch` de `capture` lo atrapó. Sin este contador, ese evento desaparecía sin dejar
|
|
21
22
|
* rastro en ningún `drops` del sobre siguiente. */
|
|
22
|
-
export declare function
|
|
23
|
+
export declare function countInternal(): void;
|
|
23
24
|
/** `incompletos` es la resta, y es el único contador que prueba pérdida por ciclo de vida: sin
|
|
24
25
|
* esta separación, un 429 por rate limit y "se perdió el evento" se ven idénticos. */
|
|
25
26
|
export declare function drops(): Drops;
|
|
26
27
|
/** Solo para los tests. No sale por ninguna puerta del `exports` map. */
|
|
27
|
-
export declare function
|
|
28
|
-
//# sourceMappingURL=
|
|
28
|
+
export declare function resetCounters(): void;
|
|
29
|
+
//# sourceMappingURL=counters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counters.d.ts","sourceRoot":"","sources":["../../src/core/counters.ts"],"names":[],"mappings":"AAAA;;;0DAG0D;AAC1D,MAAM,WAAW,KAAK;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAWD,wCAAwC;AACxC,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,8FAA8F;AAC9F,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,qCAAqC;AACrC,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED;;oDAEoD;AACpD,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED;uFACuF;AACvF,wBAAgB,KAAK,IAAI,KAAK,CAQ7B;AAED,yEAAyE;AACzE,wBAAgB,aAAa,IAAI,IAAI,CAOpC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const stats = {
|
|
2
|
+
fired: 0,
|
|
3
|
+
completed: 0,
|
|
4
|
+
failed: 0,
|
|
5
|
+
before_send: 0,
|
|
6
|
+
trimmed: 0,
|
|
7
|
+
internal: 0,
|
|
8
|
+
};
|
|
9
|
+
/** Veces que el código pidió enviar. */
|
|
10
|
+
export function countFired() {
|
|
11
|
+
stats.fired += 1;
|
|
12
|
+
}
|
|
13
|
+
/** Envíos que terminaron, con cualquier status: un 429 y un 503 salieron y los rechazaron. */
|
|
14
|
+
export function countCompleted() {
|
|
15
|
+
stats.completed += 1;
|
|
16
|
+
}
|
|
17
|
+
/** Envíos que lanzaron: red, DNS. */
|
|
18
|
+
export function countFailed() {
|
|
19
|
+
stats.failed += 1;
|
|
20
|
+
}
|
|
21
|
+
export function countBeforeSend() {
|
|
22
|
+
stats.before_send += 1;
|
|
23
|
+
}
|
|
24
|
+
export function countTrimmed() {
|
|
25
|
+
stats.trimmed += 1;
|
|
26
|
+
}
|
|
27
|
+
/** La quinta forma de perder un evento: algo entre `buildEvent` y `serializeCapped` lanzó, y la
|
|
28
|
+
* red del `catch` de `capture` lo atrapó. Sin este contador, ese evento desaparecía sin dejar
|
|
29
|
+
* rastro en ningún `drops` del sobre siguiente. */
|
|
30
|
+
export function countInternal() {
|
|
31
|
+
stats.internal += 1;
|
|
32
|
+
}
|
|
33
|
+
/** `incompletos` es la resta, y es el único contador que prueba pérdida por ciclo de vida: sin
|
|
34
|
+
* esta separación, un 429 por rate limit y "se perdió el evento" se ven idénticos. */
|
|
35
|
+
export function drops() {
|
|
36
|
+
return {
|
|
37
|
+
incompletos: stats.fired - stats.completed - stats.failed,
|
|
38
|
+
fallados: stats.failed,
|
|
39
|
+
before_send: stats.before_send,
|
|
40
|
+
recortados: stats.trimmed,
|
|
41
|
+
internos: stats.internal,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Solo para los tests. No sale por ninguna puerta del `exports` map. */
|
|
45
|
+
export function resetCounters() {
|
|
46
|
+
stats.fired = 0;
|
|
47
|
+
stats.completed = 0;
|
|
48
|
+
stats.failed = 0;
|
|
49
|
+
stats.before_send = 0;
|
|
50
|
+
stats.trimmed = 0;
|
|
51
|
+
stats.internal = 0;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=counters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counters.js","sourceRoot":"","sources":["../../src/core/counters.ts"],"names":[],"mappings":"AAYA,MAAM,KAAK,GAAG;IACb,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;IACT,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACX,CAAC;AAEF,wCAAwC;AACxC,MAAM,UAAU,UAAU;IACzB,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;AAClB,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,cAAc;IAC7B,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,WAAW;IAC1B,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe;IAC9B,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,YAAY;IAC3B,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AACpB,CAAC;AAED;;oDAEoD;AACpD,MAAM,UAAU,aAAa;IAC5B,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC;AACrB,CAAC;AAED;uFACuF;AACvF,MAAM,UAAU,KAAK;IACpB,OAAO;QACN,WAAW,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM;QACzD,QAAQ,EAAE,KAAK,CAAC,MAAM;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,KAAK,CAAC,OAAO;QACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACxB,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,aAAa;IAC5B,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;IAChB,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IACpB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACjB,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;IAClB,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type { CaptureOptions, Envelope, Notify, RetryInfo, Severity, Surface, TelemetryEvent } from "./
|
|
1
|
+
import type { CaptureOptions, Envelope, Notify, RetryInfo, Severity, Surface, TelemetryEvent } from "./types.js";
|
|
2
2
|
/** El mismo truncado que aplica la ingesta del lado servidor. */
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function truncate(value: string, max: number): string;
|
|
4
4
|
/** Deja las primeras 64 claves. Los valores ya son escalares por tipo, así que no hay nada que
|
|
5
5
|
* serializar del lado del cliente. */
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function capAttributes(attrs: Record<string, string | number | boolean> | undefined): Record<string, string | number | boolean> | undefined;
|
|
7
7
|
/** Semántica de excepciones de OTel: type, message y stacktrace. */
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function extractException(error: unknown): TelemetryEvent["exception"];
|
|
9
9
|
/** Solo devuelve números donde el SDK REALMENTE los sabe. En `alarm` los maneja el repo, en
|
|
10
10
|
* `workflow` viven en el ctx del step y en `queue` en el mensaje: ahí se omite el bloque, porque
|
|
11
11
|
* un valor inventado silencia la alerta terminal. */
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function retryForSurface(surface: Surface): TelemetryEvent["retry"] | undefined;
|
|
13
13
|
/** Mapea los números de camelCase (API pública) a snake_case (contrato). */
|
|
14
|
-
export declare function
|
|
15
|
-
export interface
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
export declare function retryFromOptions(info: RetryInfo): NonNullable<TelemetryEvent["retry"]>;
|
|
15
|
+
export interface EventArgs {
|
|
16
|
+
kind: "error" | "event";
|
|
17
|
+
message: string | undefined;
|
|
18
18
|
exception: TelemetryEvent["exception"] | undefined;
|
|
19
19
|
agentId: string;
|
|
20
20
|
surface: Surface;
|
|
21
21
|
severityDefault: Severity;
|
|
22
|
-
|
|
22
|
+
options: CaptureOptions;
|
|
23
23
|
}
|
|
24
|
-
export declare function
|
|
25
|
-
export interface
|
|
26
|
-
|
|
24
|
+
export declare function buildEvent(args: EventArgs): TelemetryEvent;
|
|
25
|
+
export interface EnvelopeArgs {
|
|
26
|
+
event: TelemetryEvent;
|
|
27
27
|
service: {
|
|
28
28
|
name: string;
|
|
29
29
|
version?: string;
|
|
@@ -35,12 +35,12 @@ export interface ArgsSobre {
|
|
|
35
35
|
}
|
|
36
36
|
/** Un sobre por captura, sin batching: el caso es 1 error por invocación, y batchear exigiría un
|
|
37
37
|
* punto de flush, que es justo donde se pierde data. */
|
|
38
|
-
export declare function
|
|
38
|
+
export declare function buildEnvelope(args: EnvelopeArgs): Envelope;
|
|
39
39
|
/** Recorta el sobre hasta que entre en el tope de bytes. NUNCA descarta el evento: un error con
|
|
40
40
|
* stacktrace enorme sigue siendo un error que hay que reportar. Muta el sobre, que es
|
|
41
41
|
* recién armado y de este módulo. */
|
|
42
|
-
export declare function
|
|
42
|
+
export declare function serializeCapped(envelope: Envelope): {
|
|
43
43
|
body: string;
|
|
44
|
-
|
|
44
|
+
trimmed: boolean;
|
|
45
45
|
};
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/core/envelope.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,cAAc,EACd,QAAQ,EACR,MAA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