denotify-client 1.1.11 → 1.1.12

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.
@@ -0,0 +1,355 @@
1
+ // Generated by dts-bundle-generator v7.2.0
2
+
3
+ import * as yup from 'yup';
4
+
5
+ export type DiscordWebhook = {
6
+ url: string;
7
+ username?: string;
8
+ avatar_url?: string;
9
+ message: string;
10
+ };
11
+ export type NotifyDiscordWebhookRawId = "notify_discord_webhook";
12
+ export type NotifyDiscordWebhookRawResponse = {
13
+ id: number;
14
+ created_at: string;
15
+ url: string;
16
+ username: string;
17
+ avatar_url: string;
18
+ message: string;
19
+ };
20
+ export type NotificationTypeId = "Discord";
21
+ export type NotificationConfig = DiscordWebhook;
22
+ export type NotifyRawId = NotifyDiscordWebhookRawId;
23
+ export type NotifyRawResponse = NotifyDiscordWebhookRawResponse;
24
+ export type NotificationRawResponse = {
25
+ notify_type: NotifyRawId;
26
+ notify: NotifyRawResponse;
27
+ error: boolean;
28
+ error_message: string | null;
29
+ error_timestamp: number | null;
30
+ };
31
+ export type PollFunctionV1 = {
32
+ nBlocks: number;
33
+ address: string;
34
+ abi: any;
35
+ fixedArgs?: (string | number)[];
36
+ function: string;
37
+ condition: Condition;
38
+ responseArgIndex?: number;
39
+ responseArgDecimals?: number;
40
+ constant?: number;
41
+ };
42
+ export type HandlerFunctionCallRawConfig = {
43
+ nBlocks: number;
44
+ address: string;
45
+ abi: any;
46
+ fixedArgs?: (string | number)[];
47
+ function: string;
48
+ condition: Condition;
49
+ responseArgIndex?: number;
50
+ responseArgDecimals?: number;
51
+ constant?: number;
52
+ };
53
+ export type HandlerFunctionCallUpdate = Partial<HandlerFunctionCallRawConfig>;
54
+ export type HandlerFunctionCallRawResponse = {
55
+ id: number;
56
+ created_at: string;
57
+ nBlocks: number;
58
+ address: string;
59
+ fixedArgs: string[];
60
+ responseArgIndex: number;
61
+ responseArgDecimals: number;
62
+ function: string;
63
+ condition: Condition;
64
+ constant: number;
65
+ abi: string[];
66
+ version: number;
67
+ };
68
+ export type OnchainEventV1 = {
69
+ address: string;
70
+ event: string;
71
+ abi: any;
72
+ condition: Condition;
73
+ paramsIndex?: number;
74
+ paramsDecimals?: number;
75
+ constant?: number;
76
+ };
77
+ export type HandlerOnchainEventRawConfig = {
78
+ address: string;
79
+ event: string;
80
+ abi: any;
81
+ condition: Condition;
82
+ paramsIndex?: number;
83
+ paramsDecimals?: number;
84
+ constant?: number;
85
+ };
86
+ export type HandlerOnchainEventUpdate = Partial<HandlerOnchainEventRawConfig>;
87
+ export type HandlerOnchainEventRawResponse = {
88
+ id: number;
89
+ created_at: string;
90
+ address: string;
91
+ event: string;
92
+ abi: any;
93
+ paramsIndex: number;
94
+ paramsDecimals: number;
95
+ condition: Condition;
96
+ constant: number;
97
+ };
98
+ export type FunctionCallerConfig = {
99
+ address: string;
100
+ bytecode: string;
101
+ abiHash: string;
102
+ function: string;
103
+ }[];
104
+ export declare class FunctionBuilder {
105
+ private api?;
106
+ private data;
107
+ private constructor();
108
+ static create(api?: DeNotifyClient): FunctionBuilder;
109
+ getAbiHash(abi: any): Promise<string>;
110
+ addFunction<T = any>(address: string, func: string, args: T[], abi: any): Promise<this>;
111
+ get(): FunctionCallerConfig;
112
+ static schema(): yup.ArraySchema<{
113
+ function: string;
114
+ address: string;
115
+ bytecode: string;
116
+ abiHash: string;
117
+ }[] | undefined, yup.AnyObject, "", "">;
118
+ }
119
+ export type Logic = "AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE";
120
+ export type NumericOperation = "eq" | "!eq" | "gt" | "gte" | "lt" | "lte";
121
+ export type StringOperation = "contains" | "!contains" | "is" | "!is" | "isEmpty" | "!isEmpty";
122
+ export type AddressOperation = "is" | "!is" | "isEmpty" | "!isEmpty";
123
+ export type FilterDataTypes = "String" | "Address" | "Number";
124
+ export type FilterOpertationType = NumericOperation | StringOperation | AddressOperation;
125
+ export type FilterCondition = {
126
+ logic?: Logic;
127
+ key: string;
128
+ type: FilterDataTypes;
129
+ operation: FilterOpertationType;
130
+ constant: string | number;
131
+ };
132
+ export type ConditionGroup = {
133
+ logic: Logic;
134
+ conditions: FilterCondition[];
135
+ };
136
+ export type FilterConfig = ConditionGroup[];
137
+ export declare class FilterBuilder {
138
+ private groups;
139
+ constructor();
140
+ static version(): string;
141
+ static new(): FilterBuilder;
142
+ newGroup(logic: Logic): FilterBuilder;
143
+ addCondition(logic: Logic, key: string, type: FilterDataTypes, operation: FilterOpertationType, constant: string | number): FilterBuilder;
144
+ finalise(): ConditionGroup[];
145
+ static schema(): yup.ArraySchema<{
146
+ conditions?: {
147
+ constant?: {} | undefined;
148
+ operation?: string | undefined;
149
+ type: NonNullable<"String" | "Address" | "Number" | undefined>;
150
+ key: string;
151
+ logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
152
+ }[] | undefined;
153
+ logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
154
+ }[] | undefined, yup.AnyObject, "", "">;
155
+ }
156
+ export type TimeBase = "blocks" | "time";
157
+ /**
158
+ * @typedef PollFunction
159
+ * @param {TimeBase} timeBase - Supports two poll period types. 'block' will test the trigger ever nBlocks blocks, 'time' will test the trigger as specified by timePeriod
160
+ * @param {number} nBlocks -
161
+ *
162
+ */
163
+ export type PollFunctionV2 = {
164
+ timeBase: TimeBase;
165
+ nBlocks?: number;
166
+ timePeriod?: string | null;
167
+ startTime?: number;
168
+ debounceCount?: number;
169
+ functions: FunctionCallerConfig;
170
+ triggerOn: "always" | "filter";
171
+ latch?: boolean;
172
+ filterVersion?: string;
173
+ filter?: FilterConfig;
174
+ };
175
+ export type HandlerFunctionCallV2RawConfig = {
176
+ timeBase: TimeBase;
177
+ nBlocks?: number;
178
+ timePeriod?: string | null;
179
+ startTime?: number;
180
+ debounceCount?: number;
181
+ functions: FunctionCallerConfig;
182
+ triggerOn: "always" | "filter";
183
+ latch?: boolean;
184
+ filterVersion?: string;
185
+ filter?: FilterConfig;
186
+ };
187
+ export type HandlerFunctionCallV2Update = Partial<HandlerFunctionCallV2RawConfig>;
188
+ export type HandlerFunctionCallV2RawResponse = {
189
+ id: number;
190
+ created_at: string;
191
+ nBlocks: number;
192
+ address: string;
193
+ fixedArgs: string[];
194
+ responseArgIndex: number;
195
+ responseArgDecimals: number;
196
+ function: string;
197
+ condition: Condition;
198
+ constant: number;
199
+ abi: string[];
200
+ version: number;
201
+ };
202
+ export type Network = "avalanche" | "ethereum";
203
+ export type TriggerConfig = PollFunctionV2 | PollFunctionV1 | OnchainEventV1;
204
+ export type TriggerTypeId = "PollFunctionV2" | "OnchainEventV1" | "PollFunctionV1";
205
+ export type TriggerUpdate = HandlerFunctionCallV2Update | HandlerFunctionCallUpdate | HandlerOnchainEventUpdate;
206
+ export type TriggerTypeRawId = "handler_function_call" | "handler_onchain_event" | "handler_function_call_v2";
207
+ export type HandlerRawResponse = HandlerFunctionCallV2RawResponse | HandlerFunctionCallRawResponse | HandlerOnchainEventRawResponse;
208
+ export type TriggerRawResponse = {
209
+ id: number;
210
+ type: TriggerTypeRawId;
211
+ triggered: boolean;
212
+ lastBlock: number;
213
+ alertType: "event" | "latch";
214
+ enabled: boolean;
215
+ nickname: string;
216
+ error: boolean;
217
+ error_message: string | null;
218
+ error_timestamp: number | null;
219
+ network: Network;
220
+ handler: HandlerRawResponse;
221
+ };
222
+ export type Condition = ">" | ">=" | "<" | "<=" | "=" | "true";
223
+ export type DeNotifyOptions = {
224
+ email?: string;
225
+ password?: string;
226
+ projectId?: string;
227
+ key?: string;
228
+ url?: string;
229
+ anonKey?: string;
230
+ };
231
+ export type AlertConfig = {
232
+ name: string;
233
+ network: Network;
234
+ triggerId: TriggerTypeId;
235
+ trigger: TriggerConfig;
236
+ notificationId: NotificationTypeId;
237
+ notification: NotificationConfig;
238
+ };
239
+ export type Pagination = {
240
+ page?: number;
241
+ size?: number;
242
+ };
243
+ export type HistoryParams = {
244
+ id?: number;
245
+ page?: number;
246
+ size?: number;
247
+ };
248
+ export type AlertHistory = {
249
+ type: "trigger" | "notification";
250
+ set: boolean;
251
+ alert_id: number;
252
+ block: number;
253
+ metadata: any;
254
+ subtype: TriggerTypeRawId | NotifyRawId;
255
+ };
256
+ export type AlertRawResponse = {
257
+ alertId: number;
258
+ trigger: TriggerRawResponse;
259
+ notification: NotificationRawResponse;
260
+ };
261
+ export declare class DeNotifyClient {
262
+ private url;
263
+ private headers;
264
+ private constructor();
265
+ static create(options: DeNotifyOptions): Promise<DeNotifyClient>;
266
+ alertHistory(id?: number | null, pagination?: Pagination): Promise<{
267
+ params: HistoryParams;
268
+ history: AlertHistory[];
269
+ }>;
270
+ getAlert(id: number): Promise<AlertRawResponse>;
271
+ getAlerts(): Promise<AlertRawResponse[]>;
272
+ createAlert(config: AlertConfig): Promise<any>;
273
+ deleteAlert(id: number): Promise<any>;
274
+ private request;
275
+ getAbi(network: string, address: string): Promise<{
276
+ abi: any[];
277
+ proxy?: string;
278
+ }>;
279
+ getAbiHash(abi: any): Promise<any>;
280
+ setAlertName(_triggerId: number, _name: string): Promise<void>;
281
+ enableAlert(_triggerId: number): Promise<void>;
282
+ disableAlert(_triggerId: number): Promise<void>;
283
+ updateNotification(_triggerId: number): Promise<void>;
284
+ updateTrigger(triggerId: number, update: TriggerUpdate): Promise<any>;
285
+ }
286
+ export declare class AlertBuilder {
287
+ private name;
288
+ private network?;
289
+ private triggerId?;
290
+ private trigger?;
291
+ private notificationId?;
292
+ private notification?;
293
+ private constructor();
294
+ static create(name: string): AlertBuilder;
295
+ onNetwork(network: Network): AlertBuilder;
296
+ /**
297
+ * Call withTrigger with one of the TriggerConfig types:
298
+ * PollFunctionV2 | PollFunctionV1 | OnchainEventV1
299
+ * @param id Simple ID
300
+ * @param options Desired trigger configuration
301
+ * @returns self for piping
302
+ */
303
+ withTrigger<T>(id: TriggerTypeId, options: T): AlertBuilder;
304
+ withNotification<T = NotificationConfig>(id: NotificationTypeId, options: T): AlertBuilder;
305
+ validate(): Promise<{
306
+ username?: string | undefined;
307
+ avatar_url?: string | undefined;
308
+ message: string;
309
+ url: string;
310
+ } | {
311
+ condition?: string | undefined;
312
+ nBlocks?: number | undefined;
313
+ constant?: number | undefined;
314
+ responseArgIndex?: number | undefined;
315
+ responseArgDecimals?: number | undefined;
316
+ address: string;
317
+ abi: any[];
318
+ } | {
319
+ condition?: string | undefined;
320
+ constant?: number | undefined;
321
+ paramsIndex?: number | undefined;
322
+ paramsDecimals?: number | undefined;
323
+ address: string;
324
+ event: string;
325
+ abi: any[];
326
+ } | {
327
+ filter?: {
328
+ conditions?: {
329
+ constant?: {} | undefined;
330
+ operation?: string | undefined;
331
+ type: NonNullable<"String" | "Address" | "Number" | undefined>;
332
+ key: string;
333
+ logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
334
+ }[] | undefined;
335
+ logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
336
+ }[] | undefined;
337
+ nBlocks?: number | undefined;
338
+ timePeriod?: string | undefined;
339
+ debounceCount?: number | undefined;
340
+ functions?: {
341
+ function: string;
342
+ address: string;
343
+ bytecode: string;
344
+ abiHash: string;
345
+ }[] | undefined;
346
+ filterVersion?: string | undefined;
347
+ startTime: number;
348
+ latch: boolean;
349
+ timeBase: NonNullable<"time" | "blocks" | undefined>;
350
+ triggerOn: "filter" | "always";
351
+ }>;
352
+ config(): Promise<AlertConfig>;
353
+ }
354
+
355
+ export {};