denotify-client 1.1.18 → 1.1.19

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.
@@ -26,50 +26,25 @@ export type DiscordWebhook = {
26
26
  embed?: DiscordEmbedOptions;
27
27
  };
28
28
  export type NotifyDiscordWebhookRawId = "notify_discord_webhook";
29
- export type NotifyDiscordWebhookRawResponse = {
30
- id: number;
31
- created_at: string;
32
- url: string;
33
- username: string;
34
- avatar_url: string;
35
- message: string;
36
- embed?: DiscordEmbedOptions;
37
- };
38
29
  export type Email = {
39
- email: string;
40
- subject?: string;
41
- html: string;
42
- };
43
- export type NotifyEmailRawId = "notify_telegram";
44
- export type NotifyEmailRawResponse = {
45
- id: number;
46
- created_at: string;
47
30
  email: string;
48
31
  subject: string | null;
49
32
  html: string;
50
33
  };
34
+ export type NotifyEmailRawId = "notify_email";
51
35
  export type Telegram = {
52
36
  clientId: number;
53
37
  content: string;
54
38
  };
55
39
  export type NotifyTelegramRawId = "notify_telegram";
56
- export type NotifyTelegramRawResponse = {
57
- id: number;
58
- created_at: string;
59
- clientId: number;
60
- content: string;
61
- };
62
40
  export type NotificationTypeId = "Discord" | "Telegram" | "Email";
63
41
  export type NotificationConfig = DiscordWebhook | Telegram | Email;
64
- export type NotifyRawId = NotifyDiscordWebhookRawId | NotifyTelegramRawId | NotifyEmailRawId;
65
- export type NotifyRawResponse = NotifyDiscordWebhookRawResponse | NotifyTelegramRawResponse | NotifyEmailRawResponse;
66
- export type NotificationRawResponse = {
67
- notify_type: NotifyRawId;
68
- notify: NotifyRawResponse;
69
- error: boolean;
70
- error_message: string | null;
71
- error_timestamp: number | null;
42
+ export type Notification = NotificationConfig & {
43
+ error?: boolean;
44
+ error_message?: string | null;
45
+ error_timestamp?: number | null;
72
46
  };
47
+ export type NotifyRawId = NotifyDiscordWebhookRawId | NotifyTelegramRawId | NotifyEmailRawId;
73
48
  export type PollFunctionV1 = {
74
49
  nBlocks: number;
75
50
  address: string;
@@ -93,20 +68,6 @@ export type HandlerFunctionCallRawConfig = {
93
68
  constant?: number;
94
69
  };
95
70
  export type HandlerFunctionCallUpdate = Partial<HandlerFunctionCallRawConfig>;
96
- export type HandlerFunctionCallRawResponse = {
97
- id: number;
98
- created_at: string;
99
- nBlocks: number;
100
- address: string;
101
- fixedArgs: string[];
102
- responseArgIndex: number;
103
- responseArgDecimals: number;
104
- function: string;
105
- condition: Condition;
106
- constant: number;
107
- abi: string[];
108
- version: number;
109
- };
110
71
  export type OnchainEventV1 = {
111
72
  address: string;
112
73
  event: string;
@@ -126,17 +87,6 @@ export type HandlerOnchainEventRawConfig = {
126
87
  constant?: number;
127
88
  };
128
89
  export type HandlerOnchainEventUpdate = Partial<HandlerOnchainEventRawConfig>;
129
- export type HandlerOnchainEventRawResponse = {
130
- id: number;
131
- created_at: string;
132
- address: string;
133
- event: string;
134
- abi: any;
135
- paramsIndex: number;
136
- paramsDecimals: number;
137
- condition: Condition;
138
- constant: number;
139
- };
140
90
  export type FunctionCallerConfig = {
141
91
  address: string;
142
92
  bytecode: string;
@@ -208,49 +158,23 @@ export type PollFunctionV2 = {
208
158
  timePeriod?: string | null;
209
159
  startTime?: number;
210
160
  debounceCount?: number;
211
- functions: FunctionCallerConfig;
212
- triggerOn: "always" | "filter";
213
- latch?: boolean;
214
- filterVersion?: string;
215
- filter?: FilterConfig;
216
- };
217
- export type HandlerFunctionCallV2RawConfig = {
218
- timeBase: TimeBase;
219
- nBlocks?: number;
220
- timePeriod?: string | null;
221
- startTime?: number;
222
- debounceCount?: number;
223
- functions: FunctionCallerConfig;
161
+ functions: FunctionCallerConfig | null;
224
162
  triggerOn: "always" | "filter";
225
163
  latch?: boolean;
226
- filterVersion?: string;
227
- filter?: FilterConfig;
228
- };
229
- export type HandlerFunctionCallV2Update = Partial<HandlerFunctionCallV2RawConfig>;
230
- export type HandlerFunctionCallV2RawResponse = {
231
- id: number;
232
- created_at: string;
233
- nBlocks: number;
234
- address: string;
235
- fixedArgs: string[];
236
- responseArgIndex: number;
237
- responseArgDecimals: number;
238
- function: string;
239
- condition: Condition;
240
- constant: number;
241
- abi: string[];
242
- version: number;
164
+ filterVersion: string | null;
165
+ filter: FilterConfig | null;
243
166
  };
167
+ export type HandlerFunctionCallV2Update = Partial<PollFunctionV2>;
244
168
  export type OnchainEventV2 = {
245
169
  addresses: string[];
246
170
  abiHash: string;
247
171
  event: string;
248
172
  debounceCount?: number;
249
- functions?: FunctionCallerConfig;
173
+ functions: FunctionCallerConfig | null;
250
174
  triggerOn?: "always" | "filter";
251
175
  latch?: boolean;
252
- filterVersion?: string;
253
- filter?: FilterConfig;
176
+ filterVersion: string | null;
177
+ filter: FilterConfig | null;
254
178
  };
255
179
  export type HandlerOnchainEventV2RawConfig = {
256
180
  addresses: string[];
@@ -264,40 +188,16 @@ export type HandlerOnchainEventV2RawConfig = {
264
188
  filter: FilterConfig | null;
265
189
  };
266
190
  export type HandlerOnchainEventV2Update = Partial<HandlerOnchainEventV2RawConfig>;
267
- export type HandlerOnchainEventV2RawResponse = {
268
- id: number;
269
- created_at: string;
270
- nBlocks: number;
271
- address: string;
272
- fixedArgs: string[];
273
- responseArgIndex: number;
274
- responseArgDecimals: number;
275
- function: string;
276
- condition: Condition;
277
- constant: number;
278
- abi: string[];
279
- version: number;
280
- };
281
191
  export type Network = "ethereum" | "avalanche" | "bsc" | "polygon" | "fantom" | "optimism" | "arbitrum" | "canto";
282
192
  export type TriggerConfig = PollFunctionV2 | PollFunctionV1 | OnchainEventV1 | OnchainEventV2;
283
193
  export type TriggerTypeId = "PollFunctionV2" | "OnchainEventV1" | "PollFunctionV1" | "OnchainEventV2";
194
+ export type Trigger = TriggerConfig & {
195
+ error?: boolean;
196
+ error_message?: string | null;
197
+ error_timestamp?: number | null;
198
+ };
284
199
  export type TriggerUpdate = HandlerFunctionCallV2Update | HandlerFunctionCallUpdate | HandlerOnchainEventUpdate | HandlerOnchainEventV2Update;
285
200
  export type TriggerTypeRawId = "handler_function_call" | "handler_onchain_event" | "handler_function_call_v2" | "handler_onchain_event_v2";
286
- export type HandlerRawResponse = HandlerFunctionCallV2RawResponse | HandlerFunctionCallRawResponse | HandlerOnchainEventRawResponse | HandlerOnchainEventV2RawResponse;
287
- export type TriggerRawResponse = {
288
- id: number;
289
- type: TriggerTypeRawId;
290
- triggered: boolean;
291
- lastBlock: number;
292
- alertType: "event" | "latch";
293
- enabled: boolean;
294
- nickname: string;
295
- error: boolean;
296
- error_message: string | null;
297
- error_timestamp: number | null;
298
- network: Network;
299
- handler: HandlerRawResponse;
300
- };
301
201
  export type Condition = ">" | ">=" | "<" | "<=" | "=" | "true";
302
202
  export type DeNotifyOptions = {
303
203
  email?: string;
@@ -307,14 +207,6 @@ export type DeNotifyOptions = {
307
207
  url?: string;
308
208
  anonKey?: string;
309
209
  };
310
- export type AlertConfig = {
311
- name: string;
312
- network: Network;
313
- triggerId: TriggerTypeId;
314
- trigger: TriggerConfig;
315
- notificationId: NotificationTypeId;
316
- notification: NotificationConfig;
317
- };
318
210
  export type Pagination = {
319
211
  page?: number;
320
212
  size?: number;
@@ -332,10 +224,14 @@ export type AlertHistory = {
332
224
  metadata: any;
333
225
  subtype: TriggerTypeRawId | NotifyRawId;
334
226
  };
335
- export type AlertRawResponse = {
336
- alertId: number;
337
- trigger: TriggerRawResponse;
338
- notification: NotificationRawResponse;
227
+ export type Alert = {
228
+ name: string;
229
+ network: Network;
230
+ id?: number;
231
+ triggerId: TriggerTypeId;
232
+ trigger: Trigger;
233
+ notificationId: NotificationTypeId;
234
+ notification: Notification;
339
235
  };
340
236
  export declare class DeNotifyClient {
341
237
  private url;
@@ -346,10 +242,12 @@ export declare class DeNotifyClient {
346
242
  params: HistoryParams;
347
243
  history: AlertHistory[];
348
244
  }>;
349
- getAlert(id: number): Promise<AlertRawResponse>;
350
- getAlerts(): Promise<AlertRawResponse[]>;
351
- createAlert(config: AlertConfig): Promise<any>;
245
+ getAlert(id: number): Promise<Alert>;
246
+ getAlerts(): Promise<Alert[]>;
247
+ createAlert(config: Alert): Promise<any>;
352
248
  deleteAlert(id: number): Promise<any>;
249
+ private decode;
250
+ private encode;
353
251
  private request;
354
252
  getAbi(network: string, address: string): Promise<{
355
253
  abi: unknown[];
@@ -380,9 +278,9 @@ export declare class AlertBuilder {
380
278
  * @param options Desired trigger configuration
381
279
  * @returns self for piping
382
280
  */
383
- withTrigger<TTriggerTypeId extends TriggerTypeId>(id: TTriggerTypeId, options: TTriggerTypeId extends "PollFunctionV2" ? PollFunctionV2 : TTriggerTypeId extends "OnchainEventV2" ? OnchainEventV2 : TTriggerTypeId extends "PollFunctionV1" ? PollFunctionV1 : TTriggerTypeId extends "OnchainEventV1" ? OnchainEventV1 : never): AlertBuilder;
281
+ withTrigger<TTriggerTypeId extends TriggerTypeId>(id: TTriggerTypeId, options: TTriggerTypeId extends "PollFunctionV2" ? Partial<PollFunctionV2> : TTriggerTypeId extends "OnchainEventV2" ? Partial<OnchainEventV2> : TTriggerTypeId extends "PollFunctionV1" ? Partial<PollFunctionV1> : TTriggerTypeId extends "OnchainEventV1" ? OnchainEventV1 : never): AlertBuilder;
384
282
  withNotification<TNotificationTypeId extends NotificationTypeId>(id: TNotificationTypeId, options: TNotificationTypeId extends "Discord" ? DiscordWebhook : TNotificationTypeId extends "Telegram" ? Telegram : TNotificationTypeId extends "Email" ? Email : never): AlertBuilder;
385
- config(): Promise<AlertConfig>;
283
+ config(): Promise<Alert>;
386
284
  }
387
285
 
388
286
  export {};