@gearbox-protocol/cli-utils 5.68.0 → 5.68.1
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.
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ILogger } from "@gearbox-protocol/sdk";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
teamId: string;
|
|
2
|
+
import type { SignlConfig } from "./schema.js";
|
|
3
|
+
export type SignlServiceOptions = SignlConfig & {
|
|
5
4
|
retryInterval?: number;
|
|
6
5
|
retryCount?: number;
|
|
7
|
-
}
|
|
6
|
+
};
|
|
8
7
|
export default class SignlNotifier {
|
|
9
8
|
#private;
|
|
10
9
|
constructor(opts: SignlServiceOptions, logger?: ILogger);
|
|
@@ -13,6 +13,7 @@ export default class SignlNotifier {
|
|
|
13
13
|
this.#retryInterval = opts.retryInterval ?? DEFAULT_RETRY_INTERVAL;
|
|
14
14
|
this.#retryCount = opts.retryCount ?? DEFAULT_RETRY_COUNT;
|
|
15
15
|
this.#logger = logger;
|
|
16
|
+
this.#logger?.info(opts, "signl notifier configured");
|
|
16
17
|
}
|
|
17
18
|
alert(message) {
|
|
18
19
|
void this.#sendAlert(message).catch(e => this.#logger?.error(e));
|
|
@@ -21,7 +22,7 @@ export default class SignlNotifier {
|
|
|
21
22
|
const text = message.slice(0, 64); // it's to be shown in mobile notifications anyways
|
|
22
23
|
this.#logger?.debug("sending signl alert");
|
|
23
24
|
await withRetry(async () => {
|
|
24
|
-
const resp = await fetch(`https://connect.signl4.com/api/v2/alerts?x-s4-api-key=${this.#apiKey}`, {
|
|
25
|
+
const resp = await fetch(`https://connect.signl4.com/api/v2/alerts?x-s4-api-key=${this.#apiKey.value}`, {
|
|
25
26
|
method: "POST",
|
|
26
27
|
headers: {
|
|
27
28
|
"Content-Type": "application/json",
|
|
@@ -29,7 +30,7 @@ export default class SignlNotifier {
|
|
|
29
30
|
body: JSON.stringify({
|
|
30
31
|
category: "emergency",
|
|
31
32
|
severity: 0,
|
|
32
|
-
teamId: this.#teamId,
|
|
33
|
+
teamId: this.#teamId.value,
|
|
33
34
|
text,
|
|
34
35
|
title: "GEARBOX ALERT",
|
|
35
36
|
}),
|
|
@@ -26,3 +26,8 @@ export declare const NotificationConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
26
26
|
alertsOnly: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<boolean, any>>>;
|
|
27
27
|
}, z.core.$strip>], "type">;
|
|
28
28
|
export type NotificationConfig = z.infer<typeof NotificationConfig>;
|
|
29
|
+
export declare const SignlConfig: z.ZodObject<{
|
|
30
|
+
apiKey: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<CensoredString<string>, CensoredString<string>>]>, z.ZodTransform<CensoredString<string>, string | CensoredString<string>>>;
|
|
31
|
+
teamId: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<CensoredString<string>, CensoredString<string>>]>, z.ZodTransform<CensoredString<string>, string | CensoredString<string>>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type SignlConfig = z.infer<typeof SignlConfig>;
|
|
@@ -36,3 +36,11 @@ export const NotificationConfig = z.discriminatedUnion("type", [
|
|
|
36
36
|
TelegramConfig,
|
|
37
37
|
SlackConfig,
|
|
38
38
|
]);
|
|
39
|
+
export const SignlConfig = z.object({
|
|
40
|
+
apiKey: z
|
|
41
|
+
.union([z.string(), z.instanceof(CensoredString)])
|
|
42
|
+
.transform(CensoredString.transform),
|
|
43
|
+
teamId: z
|
|
44
|
+
.union([z.string(), z.instanceof(CensoredString)])
|
|
45
|
+
.transform(CensoredString.transform),
|
|
46
|
+
});
|