@futurewindai/wotchi 0.1.0-beta.2 → 0.1.0-beta.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.
Files changed (103) hide show
  1. package/README.md +178 -47
  2. package/SECURITY.md +2 -2
  3. package/dist/cjs/core/admission.js +22 -0
  4. package/dist/cjs/core/client.js +416 -21
  5. package/dist/cjs/core/config.js +193 -18
  6. package/dist/cjs/core/diagnostics.js +16 -1
  7. package/dist/cjs/core/group-store.js +22 -9
  8. package/dist/cjs/core/incident-builder.js +18 -0
  9. package/dist/cjs/core/incident-policy.js +2 -7
  10. package/dist/cjs/core/limits.js +17 -0
  11. package/dist/cjs/core/normalize.js +16 -6
  12. package/dist/cjs/core/notification-queue.js +92 -6
  13. package/dist/cjs/core/prometheus.js +129 -0
  14. package/dist/cjs/core/redact.js +57 -8
  15. package/dist/cjs/core/runtime-monitor.js +109 -0
  16. package/dist/cjs/index.js +8 -1
  17. package/dist/cjs/integrations/express/error-handler.js +21 -4
  18. package/dist/cjs/integrations/express/index.js +2 -1
  19. package/dist/cjs/integrations/express/status-observer.js +6 -0
  20. package/dist/cjs/integrations/nest/capture.js +21 -0
  21. package/dist/cjs/integrations/nest/exception-filter.js +64 -8
  22. package/dist/cjs/integrations/nest/filter-wrapper.js +17 -0
  23. package/dist/cjs/integrations/nest/index.js +7 -1
  24. package/dist/cjs/integrations/nest/module.js +44 -0
  25. package/dist/cjs/integrations/nest/register.js +15 -1
  26. package/dist/cjs/integrations/request-context.js +83 -1
  27. package/dist/cjs/notifiers/alert-payload.js +20 -0
  28. package/dist/cjs/notifiers/console.js +85 -15
  29. package/dist/cjs/notifiers/telegram-format.js +75 -5
  30. package/dist/cjs/notifiers/webhook-http.js +394 -0
  31. package/dist/cjs/notifiers/webhook.js +28 -0
  32. package/dist/esm/core/admission.js +19 -0
  33. package/dist/esm/core/client.js +416 -21
  34. package/dist/esm/core/config.js +193 -18
  35. package/dist/esm/core/diagnostics.js +16 -1
  36. package/dist/esm/core/group-store.js +22 -9
  37. package/dist/esm/core/incident-builder.js +18 -0
  38. package/dist/esm/core/incident-policy.js +2 -7
  39. package/dist/esm/core/limits.js +14 -0
  40. package/dist/esm/core/normalize.js +16 -6
  41. package/dist/esm/core/notification-queue.js +92 -6
  42. package/dist/esm/core/prometheus.js +125 -0
  43. package/dist/esm/core/redact.js +57 -8
  44. package/dist/esm/core/runtime-monitor.js +106 -0
  45. package/dist/esm/index.js +4 -1
  46. package/dist/esm/integrations/express/error-handler.js +21 -4
  47. package/dist/esm/integrations/express/index.js +1 -1
  48. package/dist/esm/integrations/express/status-observer.js +6 -0
  49. package/dist/esm/integrations/nest/capture.js +17 -0
  50. package/dist/esm/integrations/nest/exception-filter.js +65 -9
  51. package/dist/esm/integrations/nest/filter-wrapper.js +14 -0
  52. package/dist/esm/integrations/nest/index.js +3 -1
  53. package/dist/esm/integrations/nest/module.js +41 -0
  54. package/dist/esm/integrations/nest/register.js +15 -1
  55. package/dist/esm/integrations/request-context.js +83 -1
  56. package/dist/esm/notifiers/alert-payload.js +16 -0
  57. package/dist/esm/notifiers/console.js +85 -15
  58. package/dist/esm/notifiers/telegram-format.js +75 -5
  59. package/dist/esm/notifiers/webhook-http.js +387 -0
  60. package/dist/esm/notifiers/webhook.js +24 -0
  61. package/dist/types/core/admission.d.ts +10 -0
  62. package/dist/types/core/config.d.ts +17 -1
  63. package/dist/types/core/diagnostics.d.ts +7 -1
  64. package/dist/types/core/incident-policy.d.ts +1 -1
  65. package/dist/types/core/limits.d.ts +14 -0
  66. package/dist/types/core/notification-queue.d.ts +14 -1
  67. package/dist/types/core/prometheus.d.ts +7 -0
  68. package/dist/types/core/runtime-monitor.d.ts +15 -0
  69. package/dist/types/core/types.d.ts +111 -2
  70. package/dist/types/index.d.ts +8 -2
  71. package/dist/types/integrations/express/index.d.ts +2 -2
  72. package/dist/types/integrations/nest/capture.d.ts +4 -0
  73. package/dist/types/integrations/nest/exception-filter.d.ts +6 -2
  74. package/dist/types/integrations/nest/filter-wrapper.d.ts +7 -0
  75. package/dist/types/integrations/nest/index.d.ts +6 -2
  76. package/dist/types/integrations/nest/module.d.ts +9 -0
  77. package/dist/types/integrations/nest/register.d.ts +3 -0
  78. package/dist/types/integrations/request-context.d.ts +3 -0
  79. package/dist/types/notifiers/alert-payload.d.ts +5 -0
  80. package/dist/types/notifiers/webhook-http.d.ts +37 -0
  81. package/dist/types/notifiers/webhook.d.ts +4 -0
  82. package/dist/types-cjs/core/admission.d.cts +10 -0
  83. package/dist/types-cjs/core/config.d.cts +17 -1
  84. package/dist/types-cjs/core/diagnostics.d.cts +7 -1
  85. package/dist/types-cjs/core/incident-policy.d.cts +1 -1
  86. package/dist/types-cjs/core/limits.d.cts +14 -0
  87. package/dist/types-cjs/core/notification-queue.d.cts +14 -1
  88. package/dist/types-cjs/core/prometheus.d.cts +7 -0
  89. package/dist/types-cjs/core/runtime-monitor.d.cts +15 -0
  90. package/dist/types-cjs/core/types.d.cts +111 -2
  91. package/dist/types-cjs/index.d.cts +8 -2
  92. package/dist/types-cjs/integrations/express/index.d.cts +2 -2
  93. package/dist/types-cjs/integrations/nest/capture.d.cts +4 -0
  94. package/dist/types-cjs/integrations/nest/exception-filter.d.cts +6 -2
  95. package/dist/types-cjs/integrations/nest/filter-wrapper.d.cts +7 -0
  96. package/dist/types-cjs/integrations/nest/index.d.cts +6 -2
  97. package/dist/types-cjs/integrations/nest/module.d.cts +9 -0
  98. package/dist/types-cjs/integrations/nest/register.d.cts +3 -0
  99. package/dist/types-cjs/integrations/request-context.d.cts +3 -0
  100. package/dist/types-cjs/notifiers/alert-payload.d.cts +5 -0
  101. package/dist/types-cjs/notifiers/webhook-http.d.cts +37 -0
  102. package/dist/types-cjs/notifiers/webhook.d.cts +4 -0
  103. package/package.json +17 -4
@@ -1,10 +1,40 @@
1
1
  export type IncidentSeverity = "low" | "medium" | "high" | "critical";
2
- export type WotchiEventKind = "error" | "manual" | "process-monitor";
2
+ export type WotchiEventKind = "error" | "manual" | "process-monitor" | "runtime-monitor";
3
+ export interface WotchiTraceContext {
4
+ traceId?: string;
5
+ spanId?: string;
6
+ }
3
7
  export interface WotchiRequestContext extends Record<string, unknown> {
4
8
  method?: string;
5
9
  route?: string;
6
10
  statusCode?: number;
7
11
  requestId?: string;
12
+ correlationId?: string;
13
+ trace?: WotchiTraceContext;
14
+ }
15
+ export type WotchiTags = Readonly<Record<string, string>>;
16
+ export interface WotchiLinkTemplates {
17
+ log?: string;
18
+ trace?: string;
19
+ }
20
+ export interface WotchiLinks {
21
+ log?: string;
22
+ trace?: string;
23
+ }
24
+ export type WotchiFingerprintCallback = (event: Readonly<SafeErrorEvent>) => string | undefined;
25
+ export type WotchiFingerprintOverride = string | WotchiFingerprintCallback;
26
+ export type WotchiEventFilter = (event: Readonly<SafeErrorEvent>) => boolean;
27
+ export type WotchiBeforeSend = (alert: Readonly<IncidentAlert>) => IncidentAlert | null | undefined;
28
+ export interface WotchiCaptureOptions {
29
+ fingerprint?: WotchiFingerprintOverride;
30
+ severity?: IncidentSeverity;
31
+ alertThreshold?: number;
32
+ request?: WotchiRequestContext;
33
+ trace?: WotchiTraceContext;
34
+ correlationId?: string;
35
+ operation?: string;
36
+ job?: string;
37
+ tags?: Record<string, unknown>;
8
38
  }
9
39
  export interface WotchiEventInput {
10
40
  level: "error";
@@ -12,16 +42,28 @@ export interface WotchiEventInput {
12
42
  message: string;
13
43
  error?: unknown;
14
44
  alertThreshold?: number;
45
+ severity?: IncidentSeverity;
46
+ fingerprint?: WotchiFingerprintOverride;
15
47
  metadata?: Record<string, unknown>;
16
48
  context?: Record<string, unknown>;
17
49
  request?: WotchiRequestContext;
50
+ trace?: WotchiTraceContext;
51
+ correlationId?: string;
52
+ operation?: string;
53
+ job?: string;
54
+ tags?: Record<string, unknown>;
18
55
  }
19
56
  export interface SafeErrorEvent {
20
57
  id: string;
21
58
  timestamp: string;
22
59
  service: string;
23
60
  environment: string;
61
+ instance?: string;
24
62
  release?: string;
63
+ correlationId?: string;
64
+ operation?: string;
65
+ job?: string;
66
+ tags?: WotchiTags;
25
67
  error: {
26
68
  name: string;
27
69
  message: string;
@@ -29,6 +71,7 @@ export interface SafeErrorEvent {
29
71
  code?: string;
30
72
  };
31
73
  request?: WotchiRequestContext;
74
+ trace?: WotchiTraceContext;
32
75
  context?: Record<string, unknown>;
33
76
  }
34
77
  export interface IncidentGroup {
@@ -53,6 +96,19 @@ export interface IncidentAlert {
53
96
  occurrences: number;
54
97
  service: string;
55
98
  environment: string;
99
+ instance?: string;
100
+ release?: string;
101
+ correlationId?: string;
102
+ operation?: string;
103
+ job?: string;
104
+ tags?: WotchiTags;
105
+ error?: SafeErrorEvent["error"] & {
106
+ applicationFrame?: string;
107
+ };
108
+ request?: WotchiRequestContext;
109
+ trace?: WotchiTraceContext;
110
+ context?: Record<string, unknown>;
111
+ links?: WotchiLinks;
56
112
  }
57
113
  export interface WotchiNotifier {
58
114
  readonly name: string;
@@ -67,11 +123,33 @@ export interface TelegramNotifierOptions {
67
123
  chatId: string;
68
124
  timeoutMs?: number;
69
125
  }
126
+ export interface WebhookNotifierOptions {
127
+ url: string;
128
+ headers?: Record<string, string>;
129
+ timeoutMs?: number;
130
+ maxRetries?: number;
131
+ allowHttpLoopback?: boolean;
132
+ allowPrivateDestinations?: boolean;
133
+ payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
134
+ }
135
+ export interface WotchiIncidentRule {
136
+ environment?: string;
137
+ route?: string;
138
+ ignore?: boolean;
139
+ alertThreshold?: number;
140
+ severity?: IncidentSeverity;
141
+ }
70
142
  export interface WotchiConfig {
71
143
  service: string;
72
144
  environment: string;
145
+ instance?: string;
73
146
  release?: string;
74
147
  enabled?: boolean;
148
+ filter?: WotchiEventFilter;
149
+ fingerprint?: WotchiFingerprintCallback;
150
+ beforeSend?: WotchiBeforeSend;
151
+ links?: WotchiLinkTemplates;
152
+ rules?: readonly WotchiIncidentRule[];
75
153
  grouping?: {
76
154
  windowMs?: number;
77
155
  alertThreshold?: number;
@@ -82,6 +160,16 @@ export interface WotchiConfig {
82
160
  queue?: {
83
161
  maxPendingAlerts?: number;
84
162
  concurrency?: 1;
163
+ notifierTimeoutMs?: number;
164
+ notifierCircuitBreaker?: {
165
+ failureThreshold?: number;
166
+ cooldownMs?: number;
167
+ };
168
+ };
169
+ overload?: {
170
+ maxEventsPerSecond?: number;
171
+ burst?: number;
172
+ alertCooldownMs?: number;
85
173
  };
86
174
  privacy?: {
87
175
  redactKeys?: string[];
@@ -100,12 +188,33 @@ export interface WotchiDiagnostics {
100
188
  alertsDropped: number;
101
189
  alertsSent: number;
102
190
  notifierFailures: number;
191
+ fingerprintCallbackFailures: number;
192
+ filterFailures: number;
193
+ beforeSendFailures: number;
194
+ eventsSuppressed: number;
195
+ eventsDroppedOverload: number;
196
+ capturesAfterShutdown: number;
103
197
  activeGroups: number;
104
198
  pendingAlerts: number;
199
+ notifierTimeouts: number;
200
+ notifierCircuitOpenSkips: number;
201
+ }
202
+ export type WotchiTestAlertStatus = "sent" | "queue-full" | "timeout" | "notifier-failed";
203
+ export interface WotchiTestAlertResult {
204
+ status: WotchiTestAlertStatus;
205
+ configurationAccepted: true;
206
+ queued: boolean;
207
+ flushed: boolean;
208
+ delivered: boolean;
209
+ notifierFailures: number;
210
+ diagnostics: Readonly<WotchiDiagnostics>;
211
+ error?: string;
105
212
  }
106
213
  export interface WotchiClient {
107
- captureException(error: unknown, context?: Record<string, unknown>): void;
214
+ captureException(error: unknown, context?: Record<string, unknown>, options?: WotchiCaptureOptions): void;
108
215
  captureEvent(event: WotchiEventInput): void;
216
+ testAlert(): Promise<WotchiTestAlertResult>;
109
217
  flush(timeoutMs?: number): Promise<void>;
218
+ shutdown(timeoutMs?: number): Promise<void>;
110
219
  getDiagnostics(): Readonly<WotchiDiagnostics>;
111
220
  }
@@ -1,9 +1,15 @@
1
1
  import { createWotchi } from "./core/client.js";
2
2
  import { registerWotchiProcessMonitor } from "./core/process-monitor.js";
3
+ import { createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE } from "./core/prometheus.js";
4
+ import { registerWotchiRuntimeWatcher } from "./core/runtime-monitor.js";
3
5
  import { consoleNotifier } from "./notifiers/console.js";
4
6
  import { telegramNotifier } from "./notifiers/telegram.js";
7
+ import { webhookNotifier } from "./notifiers/webhook.js";
5
8
  export { WotchiConfigurationError } from "./core/errors.js";
6
9
  export type { ProcessMonitorHandle } from "./core/process-monitor.js";
7
10
  export type { NormalizedWotchiConfig } from "./core/config.js";
8
- export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiEventKind, WotchiNotifier, WotchiRequestContext, } from "./core/types.js";
9
- export { consoleNotifier, createWotchi, registerWotchiProcessMonitor, telegramNotifier };
11
+ export type { WotchiPrometheusExporter } from "./core/prometheus.js";
12
+ export type { WotchiRuntimeWatcherHandle, WotchiRuntimeWatcherOptions, } from "./core/runtime-monitor.js";
13
+ export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiEventKind, WotchiFingerprintOverride, WotchiFingerprintCallback, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "./core/types.js";
14
+ export type { WebhookRequestFunction, WebhookRequestOptions, WebhookResponse, } from "./notifiers/webhook-http.js";
15
+ export { consoleNotifier, createWotchi, createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE, registerWotchiProcessMonitor, registerWotchiRuntimeWatcher, telegramNotifier, webhookNotifier, };
@@ -1,8 +1,8 @@
1
1
  import type { WotchiClient } from "../../core/types.js";
2
2
  import { createExpressErrorHandler } from "./error-handler.js";
3
3
  import type { ExpressWotchiOptions } from "./request-context.js";
4
- export { consoleNotifier, createWotchi, telegramNotifier } from "../../index.js";
5
- export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiNotifier, WotchiRequestContext, } from "../../index.js";
4
+ export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.js";
5
+ export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiFingerprintCallback, WotchiFingerprintOverride, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "../../index.js";
6
6
  export type { ExpressWotchiOptions } from "./request-context.js";
7
7
  export type { WotchiStatusClass, WotchiStatusObserverOptions } from "./status-observer.js";
8
8
  export { wotchiStatusObserver } from "./status-observer.js";
@@ -0,0 +1,4 @@
1
+ import type { ArgumentsHost } from "@nestjs/common";
2
+ import type { WotchiClient } from "../../core/types.js";
3
+ import { type NestWotchiOptions } from "./request-context.js";
4
+ export declare const captureWotchiNestException: (client: WotchiClient, exception: unknown, host: ArgumentsHost, options?: NestWotchiOptions) => void;
@@ -1,10 +1,14 @@
1
1
  import { type ArgumentsHost, type HttpServer } from "@nestjs/common";
2
2
  import { BaseExceptionFilter } from "@nestjs/core";
3
3
  import type { WotchiClient } from "../../core/types.js";
4
- import { type NestWotchiOptions } from "./request-context.js";
4
+ import type { NestExceptionFilterLike } from "./filter-wrapper.js";
5
+ import type { NestWotchiOptions } from "./request-context.js";
5
6
  export declare class WotchiNestExceptionFilter extends BaseExceptionFilter<unknown> {
6
7
  private readonly client;
7
8
  private readonly options?;
8
- constructor(client: WotchiClient, applicationRef: HttpServer, options?: NestWotchiOptions | undefined);
9
+ private readonly previousGlobalFilters;
10
+ constructor(client: WotchiClient, applicationRef?: HttpServer, options?: NestWotchiOptions | undefined, previousGlobalFilters?: readonly NestExceptionFilterLike[]);
9
11
  catch(exception: unknown, host: ArgumentsHost): void;
12
+ private respondWithoutLoggingRawUnknownException;
13
+ private respondThroughExpressAdapter;
10
14
  }
@@ -0,0 +1,7 @@
1
+ import type { ArgumentsHost } from "@nestjs/common";
2
+ import type { WotchiClient } from "../../core/types.js";
3
+ import type { NestWotchiOptions } from "./request-context.js";
4
+ export interface NestExceptionFilterLike {
5
+ catch(exception: unknown, host: ArgumentsHost): void;
6
+ }
7
+ export declare function withWotchiNestFilter<TFilter extends NestExceptionFilterLike>(client: WotchiClient, filter: TFilter, options?: NestWotchiOptions): TFilter;
@@ -1,5 +1,9 @@
1
- export { consoleNotifier, createWotchi, telegramNotifier } from "../../index.js";
1
+ export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.js";
2
+ export { withWotchiNestFilter } from "./filter-wrapper.js";
3
+ export { WotchiModule, WOTCHI_CLIENT } from "./module.js";
2
4
  export { registerWotchiNest, registerWotchiNestStatusObserver } from "./register.js";
3
- export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiNotifier, WotchiRequestContext, } from "../../index.js";
5
+ export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiFingerprintCallback, WotchiFingerprintOverride, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "../../index.js";
4
6
  export type { NestWotchiApplication, NestWotchiOptions } from "./register.js";
7
+ export type { NestExceptionFilterLike } from "./filter-wrapper.js";
8
+ export type { WotchiNestModuleOptions } from "./module.js";
5
9
  export type { WotchiStatusClass, WotchiStatusObserverOptions } from "../express/status-observer.js";
@@ -0,0 +1,9 @@
1
+ import { type DynamicModule } from "@nestjs/common";
2
+ import type { WotchiConfig } from "../../core/types.js";
3
+ export declare const WOTCHI_CLIENT: unique symbol;
4
+ export interface WotchiNestModuleOptions {
5
+ registerGlobalFilter?: boolean;
6
+ }
7
+ export declare class WotchiModule {
8
+ static forRoot(config: WotchiConfig, options?: WotchiNestModuleOptions): DynamicModule;
9
+ }
@@ -8,6 +8,9 @@ export interface NestWotchiApplication {
8
8
  getHttpAdapter?: () => unknown;
9
9
  use?: (...middleware: unknown[]) => unknown;
10
10
  useGlobalFilters(...filters: unknown[]): unknown;
11
+ config?: {
12
+ getGlobalFilters?: () => unknown[];
13
+ };
11
14
  }
12
15
  export declare function registerWotchiNest(app: unknown, client: WotchiClient, options?: NestWotchiOptions): void;
13
16
  export declare function registerWotchiNestStatusObserver(app: unknown, client: WotchiClient, options?: WotchiStatusObserverOptions): void;
@@ -1,6 +1,8 @@
1
1
  import type { WotchiRequestContext } from "../core/types.js";
2
2
  export interface RequestContextOptions {
3
3
  requestIdProperty?: string;
4
+ correlationIdProperty?: string;
5
+ traceContextProperty?: string;
4
6
  }
5
7
  export declare function normalizeRoutePath(value: unknown): string | undefined;
6
8
  export interface RequestContextInput {
@@ -8,6 +10,7 @@ export interface RequestContextInput {
8
10
  method?: unknown;
9
11
  route?: unknown;
10
12
  statusCode?: unknown;
13
+ trace?: unknown;
11
14
  options?: RequestContextOptions;
12
15
  }
13
16
  export declare function buildRequestContext(input: RequestContextInput): WotchiRequestContext | undefined;
@@ -0,0 +1,5 @@
1
+ import type { SafeNormalizedValue } from "../core/normalize.js";
2
+ import type { IncidentAlert } from "../core/types.js";
3
+ export type BoundedAlertPayload = Record<string, SafeNormalizedValue>;
4
+ export declare function toBoundedPayload(value: unknown): BoundedAlertPayload;
5
+ export declare function toBoundedAlertPayload(alert: IncidentAlert): BoundedAlertPayload;
@@ -0,0 +1,37 @@
1
+ import type { IncidentAlert, WebhookNotifierOptions } from "../core/types.js";
2
+ export interface WebhookRequestOptions {
3
+ protocol: "http:" | "https:";
4
+ hostname: string;
5
+ port?: string;
6
+ method: "POST";
7
+ path: string;
8
+ headers: Record<string, string | number>;
9
+ allowPrivateDestinations?: boolean;
10
+ signal?: AbortSignal;
11
+ }
12
+ export interface WebhookResponse {
13
+ statusCode: number;
14
+ headers: Record<string, string | string[] | undefined>;
15
+ body: string;
16
+ }
17
+ export type WebhookRequestFunction = (options: WebhookRequestOptions, body: string, timeoutMs: number) => Promise<WebhookResponse>;
18
+ export interface WebhookSendOptions {
19
+ url: string;
20
+ alert: IncidentAlert;
21
+ headers?: Record<string, string>;
22
+ timeoutMs?: number;
23
+ maxRetries?: number;
24
+ allowHttpLoopback?: boolean;
25
+ allowPrivateDestinations?: boolean;
26
+ payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
27
+ }
28
+ export declare function normalizeWebhookOptions(options: WebhookNotifierOptions): {
29
+ url: URL;
30
+ headers?: Record<string, string>;
31
+ timeoutMs: number;
32
+ maxRetries: number;
33
+ allowHttpLoopback: boolean;
34
+ allowPrivateDestinations: boolean;
35
+ payloadBuilder?: WebhookNotifierOptions["payloadBuilder"];
36
+ };
37
+ export declare function sendWebhookAlert(options: WebhookSendOptions, request?: WebhookRequestFunction): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { WebhookNotifierOptions, WotchiNotifier } from "../core/types.js";
2
+ import { type WebhookRequestFunction } from "./webhook-http.js";
3
+ export declare function createWebhookNotifier(options: WebhookNotifierOptions, request?: WebhookRequestFunction): WotchiNotifier;
4
+ export declare function webhookNotifier(options: WebhookNotifierOptions): WotchiNotifier;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@futurewindai/wotchi",
3
- "version": "0.1.0-beta.2",
4
- "description": "Bounded incident alerts for Node.js, Express, and NestJS applications",
3
+ "version": "0.1.0-beta.6",
4
+ "description": "Low-noise error alerts for Node.js, Express, and NestJS applications",
5
5
  "keywords": [
6
6
  "nodejs",
7
7
  "typescript",
@@ -11,7 +11,8 @@
11
11
  "incident-management",
12
12
  "alerting",
13
13
  "observability",
14
- "telegram"
14
+ "telegram",
15
+ "webhook"
15
16
  ],
16
17
  "license": "Apache-2.0",
17
18
  "type": "module",
@@ -32,6 +33,16 @@
32
33
  "main": "./dist/cjs/index.js",
33
34
  "module": "./dist/esm/index.js",
34
35
  "types": "./dist/types/index.d.ts",
36
+ "typesVersions": {
37
+ "*": {
38
+ "express": [
39
+ "dist/types/integrations/express/index.d.ts"
40
+ ],
41
+ "nest": [
42
+ "dist/types/integrations/nest/index.d.ts"
43
+ ]
44
+ }
45
+ },
35
46
  "exports": {
36
47
  ".": {
37
48
  "types": {
@@ -62,7 +73,7 @@
62
73
  "type": "git",
63
74
  "url": "git+ssh://git@github.com/FutureWindAI/Wotchi.git"
64
75
  },
65
- "homepage": "https://www.npmjs.com/package/@futurewindai/wotchi",
76
+ "homepage": "https://github.com/FutureWindAI/Wotchi",
66
77
  "bugs": {
67
78
  "url": "https://github.com/FutureWindAI/Wotchi/issues"
68
79
  },
@@ -73,6 +84,7 @@
73
84
  "build:types": "tsc -p tsconfig.types.json",
74
85
  "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && node scripts/prepare-package.mjs",
75
86
  "stand": "node scripts/start-test-stand.mjs",
87
+ "stand:production": "node scripts/start-nest-production-stand.mjs",
76
88
  "typecheck": "tsc -p tsconfig.base.json --noEmit",
77
89
  "lint": "eslint .",
78
90
  "format": "prettier --write .",
@@ -81,6 +93,7 @@
81
93
  "test": "npm run test:compile && node --test .test-dist/test/unit/*.test.js .test-dist/test/integration/express/*.test.js .test-dist/test/integration/nest/*.test.js .test-dist/test/security/*.test.js",
82
94
  "pack:dry-run": "npm run build && npm pack --dry-run --json",
83
95
  "verify:package": "npm run build && node scripts/verify-package.mjs",
96
+ "verify:published-metadata": "node scripts/verify-published-metadata.mjs",
84
97
  "test:compat": "npm run build && node test/compatibility/package-exports.smoke.cjs && node test/compatibility/framework-isolation.cjs",
85
98
  "test:compat:matrix": "npm run build && node scripts/run-compatibility-matrix.mjs",
86
99
  "benchmark": "npm run build && node --expose-gc scripts/run-benchmarks.mjs",