@gearbox-protocol/cli-utils 5.68.0 → 5.68.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.
@@ -42,7 +42,17 @@ export class NotificationsService {
42
42
  const recipient = addr === ADDRESS_0X0 ? undefined : addr;
43
43
  const recipientNotification = message.messageFor(recipient);
44
44
  if (recipientNotification) {
45
- notifier.notify(this.#toDedupableNotification(recipientNotification), severity);
45
+ const notification = this.#toDedupableNotification(recipientNotification);
46
+ notifier.notify(notification, severity);
47
+ // log global notifications
48
+ if (!addr) {
49
+ if (severity === "alert") {
50
+ this.#logger?.warn(notification.plain);
51
+ }
52
+ else {
53
+ this.#logger?.debug(notification.plain);
54
+ }
55
+ }
46
56
  }
47
57
  }
48
58
  }
@@ -1,10 +1,9 @@
1
1
  import type { ILogger } from "@gearbox-protocol/sdk";
2
- export interface SignlServiceOptions {
3
- apiKey: string;
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
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/cli-utils",
3
3
  "description": "Utils for creating cli apps",
4
- "version": "5.68.0",
4
+ "version": "5.68.2",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"