@chirpier/chirpier-js 0.2.1 → 0.3.0
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.
- package/README.md +37 -10
- package/dist/__tests__/chirpier.test.js +106 -6
- package/dist/index.d.ts +67 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -4
- package/package.json +1 -1
- package/src/__tests__/chirpier.test.ts +67 -5
- package/src/index.ts +119 -5
package/README.md
CHANGED
|
@@ -124,6 +124,7 @@ Client methods:
|
|
|
124
124
|
- `client.close()`: Alias of `client.shutdown()`.
|
|
125
125
|
- `client.listEvents()`: List event definitions using the servicer API.
|
|
126
126
|
- `client.getEvent(eventID)`: Read one event definition.
|
|
127
|
+
- `client.getEventAnalytics(eventID, query)`: Read analytics window comparisons.
|
|
127
128
|
- `client.updateEvent(eventID, payload)`: Update event definition metadata.
|
|
128
129
|
- `client.listPolicies()`: List monitors/policies.
|
|
129
130
|
- `client.createPolicy(payload)`: Create a monitor/policy.
|
|
@@ -132,7 +133,7 @@ Client methods:
|
|
|
132
133
|
- `client.acknowledgeAlert(alertID)`: Acknowledge an alert.
|
|
133
134
|
- `client.resolveAlert(alertID)`: Resolve an alert.
|
|
134
135
|
- `client.archiveAlert(alertID)`: Archive an alert.
|
|
135
|
-
- `client.
|
|
136
|
+
- `client.testDestination(destinationID)`: Send a destination test and return the synthetic test `alert_id`.
|
|
136
137
|
- `client.getEventLogs(eventID, { period, limit, offset })`: Read minute/hour/day event rollups.
|
|
137
138
|
<!-- docs:end common-tasks -->
|
|
138
139
|
|
|
@@ -155,10 +156,20 @@ await client.log({
|
|
|
155
156
|
meta: { task_name: "daily_digest" },
|
|
156
157
|
});
|
|
157
158
|
|
|
159
|
+
await client.flush();
|
|
160
|
+
|
|
158
161
|
const events = await client.listEvents();
|
|
159
|
-
const toolErrors = events.find(
|
|
162
|
+
const toolErrors = events.find(
|
|
163
|
+
(eventDef) => eventDef.agent === "openclaw.main" && eventDef.event === "tool.errors.count"
|
|
164
|
+
);
|
|
160
165
|
|
|
161
166
|
if (toolErrors) {
|
|
167
|
+
const analytics = await client.getEventAnalytics(toolErrors.event_id, {
|
|
168
|
+
view: "window",
|
|
169
|
+
period: "1h",
|
|
170
|
+
previous: "previous_window",
|
|
171
|
+
});
|
|
172
|
+
|
|
162
173
|
await client.createPolicy({
|
|
163
174
|
event_id: toolErrors.event_id,
|
|
164
175
|
title: "OpenClaw tool errors spike",
|
|
@@ -172,6 +183,17 @@ if (toolErrors) {
|
|
|
172
183
|
});
|
|
173
184
|
|
|
174
185
|
await client.getEventLogs(toolErrors.event_id, { period: "hour", limit: 24 });
|
|
186
|
+
|
|
187
|
+
const destination = await client.createDestination({
|
|
188
|
+
channel: "slack",
|
|
189
|
+
url: "https://hooks.slack.com/services/T000/B000/secret",
|
|
190
|
+
scope: "all",
|
|
191
|
+
policy_ids: [],
|
|
192
|
+
enabled: true,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const test = await client.testDestination(destination.destination_id);
|
|
196
|
+
await client.getAlertDeliveries(test.alert_id, { kind: "test" });
|
|
175
197
|
}
|
|
176
198
|
|
|
177
199
|
await client.shutdown();
|
|
@@ -187,16 +209,18 @@ Flushes pending logs and stops the SDK singleton.
|
|
|
187
209
|
npm test
|
|
188
210
|
```
|
|
189
211
|
|
|
190
|
-
##
|
|
212
|
+
## Destination Setup Examples
|
|
191
213
|
|
|
192
|
-
Create a Slack
|
|
214
|
+
Create a Slack destination for OpenClaw alerts:
|
|
193
215
|
|
|
194
216
|
```ts
|
|
195
217
|
await axios.post(
|
|
196
|
-
"https://api.chirpier.co/v1.0/
|
|
218
|
+
"https://api.chirpier.co/v1.0/destinations",
|
|
197
219
|
{
|
|
198
220
|
url: "https://hooks.slack.com/services/T000/B000/secret",
|
|
199
|
-
|
|
221
|
+
channel: "slack",
|
|
222
|
+
scope: "all",
|
|
223
|
+
policy_ids: [],
|
|
200
224
|
enabled: true,
|
|
201
225
|
},
|
|
202
226
|
{
|
|
@@ -205,14 +229,16 @@ await axios.post(
|
|
|
205
229
|
);
|
|
206
230
|
```
|
|
207
231
|
|
|
208
|
-
Create a Telegram
|
|
232
|
+
Create a Telegram destination for OpenClaw alerts:
|
|
209
233
|
|
|
210
234
|
```ts
|
|
211
235
|
await axios.post(
|
|
212
|
-
"https://api.chirpier.co/v1.0/
|
|
236
|
+
"https://api.chirpier.co/v1.0/destinations",
|
|
213
237
|
{
|
|
214
|
-
|
|
238
|
+
channel: "telegram",
|
|
215
239
|
enabled: true,
|
|
240
|
+
scope: "all",
|
|
241
|
+
policy_ids: [],
|
|
216
242
|
credentials: {
|
|
217
243
|
bot_token: "123456:telegram-bot-token",
|
|
218
244
|
chat_id: "987654321",
|
|
@@ -227,5 +253,6 @@ await axios.post(
|
|
|
227
253
|
Send a test notification:
|
|
228
254
|
|
|
229
255
|
```ts
|
|
230
|
-
await client.
|
|
256
|
+
const result = await client.testDestination("whk_123");
|
|
257
|
+
await client.getAlertDeliveries(result.alert_id, { kind: "test" });
|
|
231
258
|
```
|
|
@@ -474,6 +474,66 @@ describe("Chirpier SDK", function () {
|
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
476
|
}); });
|
|
477
|
+
test("event, policy, alert, and destination helpers use servicer endpoints", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
478
|
+
var mock, client, createdEvent, policy, alert_1, destination, updatedDestination;
|
|
479
|
+
return __generator(this, function (_a) {
|
|
480
|
+
switch (_a.label) {
|
|
481
|
+
case 0:
|
|
482
|
+
mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
483
|
+
mock.onPost("https://api.chirpier.co/v1.0/events").reply(200, { event_id: "evt_123", event: "tool.errors.count", public: false, timezone: "UTC" });
|
|
484
|
+
mock.onGet("https://api.chirpier.co/v1.0/events/evt_123").reply(200, { event_id: "evt_123", event: "tool.errors.count", public: false, timezone: "UTC" });
|
|
485
|
+
mock.onGet("https://api.chirpier.co/v1.0/policies/pol_123").reply(200, { policy_id: "pol_123", event_id: "evt_123", title: "Policy", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 1, severity: "warning", enabled: true });
|
|
486
|
+
mock.onPut("https://api.chirpier.co/v1.0/policies/pol_123").reply(200, { policy_id: "pol_123", event_id: "evt_123", title: "Updated", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 1, severity: "warning", enabled: true });
|
|
487
|
+
mock.onGet("https://api.chirpier.co/v1.0/alerts/alrt_123").reply(200, { alert_id: "alrt_123", policy_id: "pol_123", event_id: "evt_123", event: "tool.errors.count", title: "Alert", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 1, severity: "warning", status: "triggered", value: 2, count: 2, min: 1, max: 1 });
|
|
488
|
+
mock.onGet("https://api.chirpier.co/v1.0/destinations").reply(200, []);
|
|
489
|
+
mock.onPost("https://api.chirpier.co/v1.0/destinations").reply(200, { destination_id: "dst_123", channel: "slack", scope: "all", enabled: true });
|
|
490
|
+
mock.onGet("https://api.chirpier.co/v1.0/destinations/dst_123").reply(200, { destination_id: "dst_123", channel: "slack", scope: "all", enabled: true });
|
|
491
|
+
mock.onPut("https://api.chirpier.co/v1.0/destinations/dst_123").reply(200, { destination_id: "dst_123", channel: "slack", scope: "all", enabled: false });
|
|
492
|
+
client = (0, index_1.createClient)({ key: "chp_client_route_key" });
|
|
493
|
+
_a.label = 1;
|
|
494
|
+
case 1:
|
|
495
|
+
_a.trys.push([1, , 11, 13]);
|
|
496
|
+
return [4 /*yield*/, client.createEvent({ event: "tool.errors.count" })];
|
|
497
|
+
case 2:
|
|
498
|
+
createdEvent = _a.sent();
|
|
499
|
+
expect(createdEvent.event_id).toBe("evt_123");
|
|
500
|
+
return [4 /*yield*/, client.getEvent("evt_123")];
|
|
501
|
+
case 3:
|
|
502
|
+
_a.sent();
|
|
503
|
+
return [4 /*yield*/, client.getPolicy("pol_123")];
|
|
504
|
+
case 4:
|
|
505
|
+
policy = _a.sent();
|
|
506
|
+
expect(policy.policy_id).toBe("pol_123");
|
|
507
|
+
return [4 /*yield*/, client.updatePolicy("pol_123", { title: "Updated" })];
|
|
508
|
+
case 5:
|
|
509
|
+
_a.sent();
|
|
510
|
+
return [4 /*yield*/, client.getAlert("alrt_123")];
|
|
511
|
+
case 6:
|
|
512
|
+
alert_1 = _a.sent();
|
|
513
|
+
expect(alert_1.alert_id).toBe("alrt_123");
|
|
514
|
+
return [4 /*yield*/, client.listDestinations()];
|
|
515
|
+
case 7:
|
|
516
|
+
_a.sent();
|
|
517
|
+
return [4 /*yield*/, client.createDestination({ channel: "slack", scope: "all", enabled: true })];
|
|
518
|
+
case 8:
|
|
519
|
+
destination = _a.sent();
|
|
520
|
+
expect(destination.destination_id).toBe("dst_123");
|
|
521
|
+
return [4 /*yield*/, client.getDestination("dst_123")];
|
|
522
|
+
case 9:
|
|
523
|
+
_a.sent();
|
|
524
|
+
return [4 /*yield*/, client.updateDestination("dst_123", { enabled: false })];
|
|
525
|
+
case 10:
|
|
526
|
+
updatedDestination = _a.sent();
|
|
527
|
+
expect(updatedDestination.enabled).toBe(false);
|
|
528
|
+
return [3 /*break*/, 13];
|
|
529
|
+
case 11: return [4 /*yield*/, client.shutdown()];
|
|
530
|
+
case 12:
|
|
531
|
+
_a.sent();
|
|
532
|
+
return [7 /*endfinally*/];
|
|
533
|
+
case 13: return [2 /*return*/];
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}); });
|
|
477
537
|
test("getAlertDeliveries uses pagination params", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
478
538
|
var mock, client;
|
|
479
539
|
return __generator(this, function (_a) {
|
|
@@ -522,21 +582,61 @@ describe("Chirpier SDK", function () {
|
|
|
522
582
|
}
|
|
523
583
|
});
|
|
524
584
|
}); });
|
|
525
|
-
test("
|
|
526
|
-
var mock, client;
|
|
585
|
+
test("testDestination posts to servicer endpoint", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
586
|
+
var mock, client, result;
|
|
527
587
|
return __generator(this, function (_a) {
|
|
528
588
|
switch (_a.label) {
|
|
529
589
|
case 0:
|
|
530
590
|
mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
531
|
-
mock.onPost("https://api.chirpier.co/v1.0/
|
|
532
|
-
|
|
591
|
+
mock.onPost("https://api.chirpier.co/v1.0/destinations/whk_123/test").reply(200, {
|
|
592
|
+
alert_id: "alrt_123",
|
|
593
|
+
destination_id: "whk_123",
|
|
594
|
+
status: "sent",
|
|
595
|
+
});
|
|
596
|
+
client = (0, index_1.createClient)({ key: "chp_client_destination_key" });
|
|
533
597
|
_a.label = 1;
|
|
534
598
|
case 1:
|
|
535
599
|
_a.trys.push([1, , 3, 5]);
|
|
536
|
-
return [4 /*yield*/, client.
|
|
600
|
+
return [4 /*yield*/, client.testDestination("whk_123")];
|
|
537
601
|
case 2:
|
|
602
|
+
result = _a.sent();
|
|
603
|
+
expect(result.alert_id).toBe("alrt_123");
|
|
604
|
+
expect(mock.history.post[0].url).toBe("https://api.chirpier.co/v1.0/destinations/whk_123/test");
|
|
605
|
+
return [3 /*break*/, 5];
|
|
606
|
+
case 3: return [4 /*yield*/, client.shutdown()];
|
|
607
|
+
case 4:
|
|
538
608
|
_a.sent();
|
|
539
|
-
|
|
609
|
+
return [7 /*endfinally*/];
|
|
610
|
+
case 5: return [2 /*return*/];
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}); });
|
|
614
|
+
test("getEventAnalytics uses analytics endpoint", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
615
|
+
var mock, client, analytics;
|
|
616
|
+
return __generator(this, function (_a) {
|
|
617
|
+
switch (_a.label) {
|
|
618
|
+
case 0:
|
|
619
|
+
mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
620
|
+
mock.onGet("https://api.chirpier.co/v1.0/events/evt_123/analytics?view=window&period=1h&previous=previous_window").reply(200, {
|
|
621
|
+
event_id: "evt_123",
|
|
622
|
+
view: "window",
|
|
623
|
+
period: "1h",
|
|
624
|
+
previous: "previous_window",
|
|
625
|
+
data: null,
|
|
626
|
+
});
|
|
627
|
+
client = (0, index_1.createClient)({ key: "chp_client_analytics_key" });
|
|
628
|
+
_a.label = 1;
|
|
629
|
+
case 1:
|
|
630
|
+
_a.trys.push([1, , 3, 5]);
|
|
631
|
+
return [4 /*yield*/, client.getEventAnalytics("evt_123", {
|
|
632
|
+
view: "window",
|
|
633
|
+
period: "1h",
|
|
634
|
+
previous: "previous_window",
|
|
635
|
+
})];
|
|
636
|
+
case 2:
|
|
637
|
+
analytics = _a.sent();
|
|
638
|
+
expect(analytics.event_id).toBe("evt_123");
|
|
639
|
+
expect(mock.history.get[0].url).toBe("https://api.chirpier.co/v1.0/events/evt_123/analytics?view=window&period=1h&previous=previous_window");
|
|
540
640
|
return [3 /*break*/, 5];
|
|
541
641
|
case 3: return [4 /*yield*/, client.shutdown()];
|
|
542
642
|
case 4:
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export interface Config {
|
|
|
13
13
|
timeout?: number;
|
|
14
14
|
batchSize?: number;
|
|
15
15
|
flushDelay?: number;
|
|
16
|
-
/** @deprecated Queues are unbounded in memory. */
|
|
17
16
|
maxQueueSize?: number;
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
@@ -39,6 +38,15 @@ export interface Event {
|
|
|
39
38
|
readonly timezone: string;
|
|
40
39
|
readonly created_at?: string;
|
|
41
40
|
}
|
|
41
|
+
export interface CreateEventPayload {
|
|
42
|
+
agent?: string;
|
|
43
|
+
event: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
public?: boolean;
|
|
46
|
+
description?: string;
|
|
47
|
+
unit?: string;
|
|
48
|
+
timezone?: string;
|
|
49
|
+
}
|
|
42
50
|
export interface Policy {
|
|
43
51
|
readonly policy_id: string;
|
|
44
52
|
readonly event_id: string;
|
|
@@ -52,6 +60,8 @@ export interface Policy {
|
|
|
52
60
|
readonly severity: string;
|
|
53
61
|
readonly enabled: boolean;
|
|
54
62
|
}
|
|
63
|
+
export type CreatePolicyPayload = Omit<Policy, "policy_id">;
|
|
64
|
+
export type UpdatePolicyPayload = Partial<Omit<Policy, "policy_id">>;
|
|
55
65
|
export interface Alert {
|
|
56
66
|
readonly alert_id: string;
|
|
57
67
|
readonly policy_id: string;
|
|
@@ -76,7 +86,7 @@ export interface Alert {
|
|
|
76
86
|
export interface AlertDelivery {
|
|
77
87
|
readonly attempt_id: string;
|
|
78
88
|
readonly alert_id: string;
|
|
79
|
-
readonly
|
|
89
|
+
readonly destination_id?: string;
|
|
80
90
|
readonly channel: string;
|
|
81
91
|
readonly target: string;
|
|
82
92
|
readonly status: string;
|
|
@@ -84,6 +94,17 @@ export interface AlertDelivery {
|
|
|
84
94
|
readonly error_message?: string;
|
|
85
95
|
readonly created_at: string;
|
|
86
96
|
}
|
|
97
|
+
export interface Destination {
|
|
98
|
+
readonly destination_id: string;
|
|
99
|
+
readonly channel: string;
|
|
100
|
+
readonly url?: string;
|
|
101
|
+
readonly credentials?: Record<string, unknown>;
|
|
102
|
+
readonly scope: string;
|
|
103
|
+
readonly policy_ids?: string[];
|
|
104
|
+
readonly enabled: boolean;
|
|
105
|
+
}
|
|
106
|
+
export type CreateDestinationPayload = Omit<Destination, "destination_id">;
|
|
107
|
+
export type UpdateDestinationPayload = Partial<Omit<Destination, "destination_id">>;
|
|
87
108
|
export interface EventLogPoint {
|
|
88
109
|
readonly event_id: string;
|
|
89
110
|
readonly agent?: string;
|
|
@@ -96,6 +117,39 @@ export interface EventLogPoint {
|
|
|
96
117
|
readonly min: number;
|
|
97
118
|
readonly max: number;
|
|
98
119
|
}
|
|
120
|
+
export interface AnalyticsWindowQuery {
|
|
121
|
+
view: "window";
|
|
122
|
+
period: "1h" | "1d" | "7d" | "1m";
|
|
123
|
+
previous: "previous_window" | "previous_1d" | "previous_7d" | "previous_1m";
|
|
124
|
+
}
|
|
125
|
+
export interface AnalyticsWindowData {
|
|
126
|
+
readonly current_value: number;
|
|
127
|
+
readonly current_count: number;
|
|
128
|
+
readonly previous_value: number;
|
|
129
|
+
readonly previous_count: number;
|
|
130
|
+
readonly value_delta: number;
|
|
131
|
+
readonly count_delta: number;
|
|
132
|
+
readonly value_pct_change: number;
|
|
133
|
+
readonly count_pct_change: number;
|
|
134
|
+
readonly current_mean: number;
|
|
135
|
+
readonly previous_mean: number;
|
|
136
|
+
readonly mean_delta: number;
|
|
137
|
+
readonly mean_pct_change: number;
|
|
138
|
+
readonly current_stddev: number;
|
|
139
|
+
readonly previous_stddev: number;
|
|
140
|
+
}
|
|
141
|
+
export interface AnalyticsWindowResponse {
|
|
142
|
+
readonly event_id: string;
|
|
143
|
+
readonly view: "window";
|
|
144
|
+
readonly period: "1h" | "1d" | "7d" | "1m";
|
|
145
|
+
readonly previous: "previous_window" | "previous_1d" | "previous_7d" | "previous_1m";
|
|
146
|
+
readonly data: AnalyticsWindowData | null;
|
|
147
|
+
}
|
|
148
|
+
export interface DestinationTestResult {
|
|
149
|
+
readonly alert_id: string;
|
|
150
|
+
readonly destination_id: string;
|
|
151
|
+
readonly status: string;
|
|
152
|
+
}
|
|
99
153
|
export interface PaginationOptions {
|
|
100
154
|
period?: "minute" | "hour" | "day";
|
|
101
155
|
limit?: number;
|
|
@@ -130,11 +184,15 @@ export declare class Client {
|
|
|
130
184
|
shutdown(): Promise<void>;
|
|
131
185
|
close(): Promise<void>;
|
|
132
186
|
listEvents(): Promise<Event[]>;
|
|
187
|
+
createEvent(payload: CreateEventPayload): Promise<Event>;
|
|
133
188
|
getEvent(eventID: string): Promise<Event>;
|
|
134
189
|
updateEvent(eventID: string, payload: Partial<Omit<Event, "event_id" | "created_at">>): Promise<Event>;
|
|
135
190
|
listPolicies(): Promise<Policy[]>;
|
|
136
|
-
|
|
191
|
+
getPolicy(policyID: string): Promise<Policy>;
|
|
192
|
+
createPolicy(payload: CreatePolicyPayload): Promise<Policy>;
|
|
193
|
+
updatePolicy(policyID: string, payload: UpdatePolicyPayload): Promise<Policy>;
|
|
137
194
|
listAlerts(status?: string): Promise<Alert[]>;
|
|
195
|
+
getAlert(alertID: string): Promise<Alert>;
|
|
138
196
|
getAlertDeliveries(alertID: string, options?: {
|
|
139
197
|
limit?: number;
|
|
140
198
|
offset?: number;
|
|
@@ -142,8 +200,13 @@ export declare class Client {
|
|
|
142
200
|
}): Promise<AlertDelivery[]>;
|
|
143
201
|
acknowledgeAlert(alertID: string): Promise<Alert>;
|
|
144
202
|
archiveAlert(alertID: string): Promise<Alert>;
|
|
145
|
-
|
|
203
|
+
listDestinations(): Promise<Destination[]>;
|
|
204
|
+
createDestination(payload: CreateDestinationPayload): Promise<Destination>;
|
|
205
|
+
getDestination(destinationID: string): Promise<Destination>;
|
|
206
|
+
updateDestination(destinationID: string, payload: UpdateDestinationPayload): Promise<Destination>;
|
|
207
|
+
testDestination(destinationID: string): Promise<DestinationTestResult>;
|
|
146
208
|
getEventLogs(eventID: string, options?: PaginationOptions): Promise<EventLogPoint[]>;
|
|
209
|
+
getEventAnalytics(eventID: string, query: AnalyticsWindowQuery): Promise<AnalyticsWindowResponse>;
|
|
147
210
|
resolveAlert(alertID: string): Promise<Alert>;
|
|
148
211
|
}
|
|
149
212
|
export declare function createClient(config?: Config): Client;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,0BAAkB,QAAQ;IACxB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACn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AAO,CAAC,WAAW,CAAC;IAKjG,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKtE,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAgBxF,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IASjG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;CAK3D;AAID,wBAAgB,YAAY,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAExD;AA4DD,wBAAgB,UAAU,CAAC,OAAO,GAAE,MAAW,GAAG,IAAI,CA+BrD;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAStD;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAO1C;AAED,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAS3C"}
|
package/dist/index.js
CHANGED
|
@@ -403,6 +403,19 @@ var Client = /** @class */ (function () {
|
|
|
403
403
|
});
|
|
404
404
|
});
|
|
405
405
|
};
|
|
406
|
+
Client.prototype.createEvent = function (payload) {
|
|
407
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
+
var response;
|
|
409
|
+
return __generator(this, function (_a) {
|
|
410
|
+
switch (_a.label) {
|
|
411
|
+
case 0: return [4 /*yield*/, this.axiosInstance.post("".concat(this.servicerEndpoint, "/events"), payload)];
|
|
412
|
+
case 1:
|
|
413
|
+
response = _a.sent();
|
|
414
|
+
return [2 /*return*/, response.data];
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
};
|
|
406
419
|
Client.prototype.getEvent = function (eventID) {
|
|
407
420
|
return __awaiter(this, void 0, void 0, function () {
|
|
408
421
|
var response;
|
|
@@ -442,6 +455,19 @@ var Client = /** @class */ (function () {
|
|
|
442
455
|
});
|
|
443
456
|
});
|
|
444
457
|
};
|
|
458
|
+
Client.prototype.getPolicy = function (policyID) {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var response;
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
switch (_a.label) {
|
|
463
|
+
case 0: return [4 /*yield*/, this.axiosInstance.get("".concat(this.servicerEndpoint, "/policies/").concat(policyID))];
|
|
464
|
+
case 1:
|
|
465
|
+
response = _a.sent();
|
|
466
|
+
return [2 /*return*/, response.data];
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
};
|
|
445
471
|
Client.prototype.createPolicy = function (payload) {
|
|
446
472
|
return __awaiter(this, void 0, void 0, function () {
|
|
447
473
|
var response;
|
|
@@ -455,6 +481,19 @@ var Client = /** @class */ (function () {
|
|
|
455
481
|
});
|
|
456
482
|
});
|
|
457
483
|
};
|
|
484
|
+
Client.prototype.updatePolicy = function (policyID, payload) {
|
|
485
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
486
|
+
var response;
|
|
487
|
+
return __generator(this, function (_a) {
|
|
488
|
+
switch (_a.label) {
|
|
489
|
+
case 0: return [4 /*yield*/, this.axiosInstance.put("".concat(this.servicerEndpoint, "/policies/").concat(policyID), payload)];
|
|
490
|
+
case 1:
|
|
491
|
+
response = _a.sent();
|
|
492
|
+
return [2 /*return*/, response.data];
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
};
|
|
458
497
|
Client.prototype.listAlerts = function (status) {
|
|
459
498
|
return __awaiter(this, void 0, void 0, function () {
|
|
460
499
|
var endpoint, response;
|
|
@@ -472,6 +511,19 @@ var Client = /** @class */ (function () {
|
|
|
472
511
|
});
|
|
473
512
|
});
|
|
474
513
|
};
|
|
514
|
+
Client.prototype.getAlert = function (alertID) {
|
|
515
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
516
|
+
var response;
|
|
517
|
+
return __generator(this, function (_a) {
|
|
518
|
+
switch (_a.label) {
|
|
519
|
+
case 0: return [4 /*yield*/, this.axiosInstance.get("".concat(this.servicerEndpoint, "/alerts/").concat(alertID))];
|
|
520
|
+
case 1:
|
|
521
|
+
response = _a.sent();
|
|
522
|
+
return [2 /*return*/, response.data];
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
};
|
|
475
527
|
Client.prototype.getAlertDeliveries = function (alertID_1) {
|
|
476
528
|
return __awaiter(this, arguments, void 0, function (alertID, options) {
|
|
477
529
|
var params, suffix, response;
|
|
@@ -524,14 +576,67 @@ var Client = /** @class */ (function () {
|
|
|
524
576
|
});
|
|
525
577
|
});
|
|
526
578
|
};
|
|
527
|
-
Client.prototype.
|
|
579
|
+
Client.prototype.listDestinations = function () {
|
|
528
580
|
return __awaiter(this, void 0, void 0, function () {
|
|
581
|
+
var response;
|
|
529
582
|
return __generator(this, function (_a) {
|
|
530
583
|
switch (_a.label) {
|
|
531
|
-
case 0: return [4 /*yield*/, this.axiosInstance.
|
|
584
|
+
case 0: return [4 /*yield*/, this.axiosInstance.get("".concat(this.servicerEndpoint, "/destinations"))];
|
|
532
585
|
case 1:
|
|
533
|
-
_a.sent();
|
|
534
|
-
return [2 /*return
|
|
586
|
+
response = _a.sent();
|
|
587
|
+
return [2 /*return*/, response.data];
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
Client.prototype.createDestination = function (payload) {
|
|
593
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
594
|
+
var response;
|
|
595
|
+
return __generator(this, function (_a) {
|
|
596
|
+
switch (_a.label) {
|
|
597
|
+
case 0: return [4 /*yield*/, this.axiosInstance.post("".concat(this.servicerEndpoint, "/destinations"), payload)];
|
|
598
|
+
case 1:
|
|
599
|
+
response = _a.sent();
|
|
600
|
+
return [2 /*return*/, response.data];
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
};
|
|
605
|
+
Client.prototype.getDestination = function (destinationID) {
|
|
606
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
607
|
+
var response;
|
|
608
|
+
return __generator(this, function (_a) {
|
|
609
|
+
switch (_a.label) {
|
|
610
|
+
case 0: return [4 /*yield*/, this.axiosInstance.get("".concat(this.servicerEndpoint, "/destinations/").concat(destinationID))];
|
|
611
|
+
case 1:
|
|
612
|
+
response = _a.sent();
|
|
613
|
+
return [2 /*return*/, response.data];
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
};
|
|
618
|
+
Client.prototype.updateDestination = function (destinationID, payload) {
|
|
619
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
620
|
+
var response;
|
|
621
|
+
return __generator(this, function (_a) {
|
|
622
|
+
switch (_a.label) {
|
|
623
|
+
case 0: return [4 /*yield*/, this.axiosInstance.put("".concat(this.servicerEndpoint, "/destinations/").concat(destinationID), payload)];
|
|
624
|
+
case 1:
|
|
625
|
+
response = _a.sent();
|
|
626
|
+
return [2 /*return*/, response.data];
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
Client.prototype.testDestination = function (destinationID) {
|
|
632
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
633
|
+
var response;
|
|
634
|
+
return __generator(this, function (_a) {
|
|
635
|
+
switch (_a.label) {
|
|
636
|
+
case 0: return [4 /*yield*/, this.axiosInstance.post("".concat(this.servicerEndpoint, "/destinations/").concat(destinationID, "/test"))];
|
|
637
|
+
case 1:
|
|
638
|
+
response = _a.sent();
|
|
639
|
+
return [2 /*return*/, response.data];
|
|
535
640
|
}
|
|
536
641
|
});
|
|
537
642
|
});
|
|
@@ -562,6 +667,24 @@ var Client = /** @class */ (function () {
|
|
|
562
667
|
});
|
|
563
668
|
});
|
|
564
669
|
};
|
|
670
|
+
Client.prototype.getEventAnalytics = function (eventID, query) {
|
|
671
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
672
|
+
var params, response;
|
|
673
|
+
return __generator(this, function (_a) {
|
|
674
|
+
switch (_a.label) {
|
|
675
|
+
case 0:
|
|
676
|
+
params = new URLSearchParams();
|
|
677
|
+
params.set("view", query.view);
|
|
678
|
+
params.set("period", query.period);
|
|
679
|
+
params.set("previous", query.previous);
|
|
680
|
+
return [4 /*yield*/, this.axiosInstance.get("".concat(this.servicerEndpoint, "/events/").concat(eventID, "/analytics?").concat(params.toString()))];
|
|
681
|
+
case 1:
|
|
682
|
+
response = _a.sent();
|
|
683
|
+
return [2 /*return*/, response.data];
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
};
|
|
565
688
|
Client.prototype.resolveAlert = function (alertID) {
|
|
566
689
|
return __awaiter(this, void 0, void 0, function () {
|
|
567
690
|
var response;
|
package/package.json
CHANGED
|
@@ -354,6 +354,39 @@ describe("Chirpier SDK", () => {
|
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
+
test("event, policy, alert, and destination helpers use servicer endpoints", async () => {
|
|
358
|
+
const mock = new MockAdapter(axios);
|
|
359
|
+
mock.onPost("https://api.chirpier.co/v1.0/events").reply(200, { event_id: "evt_123", event: "tool.errors.count", public: false, timezone: "UTC" });
|
|
360
|
+
mock.onGet("https://api.chirpier.co/v1.0/events/evt_123").reply(200, { event_id: "evt_123", event: "tool.errors.count", public: false, timezone: "UTC" });
|
|
361
|
+
mock.onGet("https://api.chirpier.co/v1.0/policies/pol_123").reply(200, { policy_id: "pol_123", event_id: "evt_123", title: "Policy", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 1, severity: "warning", enabled: true });
|
|
362
|
+
mock.onPut("https://api.chirpier.co/v1.0/policies/pol_123").reply(200, { policy_id: "pol_123", event_id: "evt_123", title: "Updated", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 1, severity: "warning", enabled: true });
|
|
363
|
+
mock.onGet("https://api.chirpier.co/v1.0/alerts/alrt_123").reply(200, { alert_id: "alrt_123", policy_id: "pol_123", event_id: "evt_123", event: "tool.errors.count", title: "Alert", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 1, severity: "warning", status: "triggered", value: 2, count: 2, min: 1, max: 1 });
|
|
364
|
+
mock.onGet("https://api.chirpier.co/v1.0/destinations").reply(200, []);
|
|
365
|
+
mock.onPost("https://api.chirpier.co/v1.0/destinations").reply(200, { destination_id: "dst_123", channel: "slack", scope: "all", enabled: true });
|
|
366
|
+
mock.onGet("https://api.chirpier.co/v1.0/destinations/dst_123").reply(200, { destination_id: "dst_123", channel: "slack", scope: "all", enabled: true });
|
|
367
|
+
mock.onPut("https://api.chirpier.co/v1.0/destinations/dst_123").reply(200, { destination_id: "dst_123", channel: "slack", scope: "all", enabled: false });
|
|
368
|
+
|
|
369
|
+
const client: Client = createClient({ key: "chp_client_route_key" });
|
|
370
|
+
try {
|
|
371
|
+
const createdEvent = await client.createEvent({ event: "tool.errors.count" });
|
|
372
|
+
expect(createdEvent.event_id).toBe("evt_123");
|
|
373
|
+
await client.getEvent("evt_123");
|
|
374
|
+
const policy = await client.getPolicy("pol_123");
|
|
375
|
+
expect(policy.policy_id).toBe("pol_123");
|
|
376
|
+
await client.updatePolicy("pol_123", { title: "Updated" });
|
|
377
|
+
const alert = await client.getAlert("alrt_123");
|
|
378
|
+
expect(alert.alert_id).toBe("alrt_123");
|
|
379
|
+
await client.listDestinations();
|
|
380
|
+
const destination = await client.createDestination({ channel: "slack", scope: "all", enabled: true });
|
|
381
|
+
expect(destination.destination_id).toBe("dst_123");
|
|
382
|
+
await client.getDestination("dst_123");
|
|
383
|
+
const updatedDestination = await client.updateDestination("dst_123", { enabled: false });
|
|
384
|
+
expect(updatedDestination.enabled).toBe(false);
|
|
385
|
+
} finally {
|
|
386
|
+
await client.shutdown();
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
357
390
|
test("getAlertDeliveries uses pagination params", async () => {
|
|
358
391
|
const mock = new MockAdapter(axios);
|
|
359
392
|
mock.onGet("https://api.chirpier.co/v1.0/alerts/alrt_123/deliveries?kind=test&limit=20&offset=5").reply(200, []);
|
|
@@ -380,17 +413,46 @@ describe("Chirpier SDK", () => {
|
|
|
380
413
|
}
|
|
381
414
|
});
|
|
382
415
|
|
|
383
|
-
test("
|
|
416
|
+
test("testDestination posts to servicer endpoint", async () => {
|
|
384
417
|
const mock = new MockAdapter(axios);
|
|
385
|
-
|
|
418
|
+
mock.onPost("https://api.chirpier.co/v1.0/destinations/whk_123/test").reply(200, {
|
|
419
|
+
alert_id: "alrt_123",
|
|
420
|
+
destination_id: "whk_123",
|
|
421
|
+
status: "sent",
|
|
422
|
+
});
|
|
386
423
|
|
|
387
|
-
const client: Client = createClient({ key: "
|
|
424
|
+
const client: Client = createClient({ key: "chp_client_destination_key" });
|
|
388
425
|
try {
|
|
389
|
-
|
|
390
|
-
|
|
426
|
+
const result = await client.testDestination("whk_123");
|
|
427
|
+
expect(result.alert_id).toBe("alrt_123");
|
|
428
|
+
expect(mock.history.post[0].url).toBe("https://api.chirpier.co/v1.0/destinations/whk_123/test");
|
|
391
429
|
} finally {
|
|
392
430
|
await client.shutdown();
|
|
393
431
|
}
|
|
394
432
|
});
|
|
433
|
+
|
|
434
|
+
test("getEventAnalytics uses analytics endpoint", async () => {
|
|
435
|
+
const mock = new MockAdapter(axios);
|
|
436
|
+
mock.onGet("https://api.chirpier.co/v1.0/events/evt_123/analytics?view=window&period=1h&previous=previous_window").reply(200, {
|
|
437
|
+
event_id: "evt_123",
|
|
438
|
+
view: "window",
|
|
439
|
+
period: "1h",
|
|
440
|
+
previous: "previous_window",
|
|
441
|
+
data: null,
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const client: Client = createClient({ key: "chp_client_analytics_key" });
|
|
445
|
+
try {
|
|
446
|
+
const analytics = await client.getEventAnalytics("evt_123", {
|
|
447
|
+
view: "window",
|
|
448
|
+
period: "1h",
|
|
449
|
+
previous: "previous_window",
|
|
450
|
+
});
|
|
451
|
+
expect(analytics.event_id).toBe("evt_123");
|
|
452
|
+
expect(mock.history.get[0].url).toBe("https://api.chirpier.co/v1.0/events/evt_123/analytics?view=window&period=1h&previous=previous_window");
|
|
453
|
+
} finally {
|
|
454
|
+
await client.shutdown();
|
|
455
|
+
}
|
|
456
|
+
});
|
|
395
457
|
});
|
|
396
458
|
});
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,6 @@ export interface Config {
|
|
|
29
29
|
timeout?: number;
|
|
30
30
|
batchSize?: number;
|
|
31
31
|
flushDelay?: number;
|
|
32
|
-
/** @deprecated Queues are unbounded in memory. */
|
|
33
32
|
maxQueueSize?: number;
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -59,6 +58,16 @@ export interface Event {
|
|
|
59
58
|
readonly created_at?: string;
|
|
60
59
|
}
|
|
61
60
|
|
|
61
|
+
export interface CreateEventPayload {
|
|
62
|
+
agent?: string;
|
|
63
|
+
event: string;
|
|
64
|
+
title?: string;
|
|
65
|
+
public?: boolean;
|
|
66
|
+
description?: string;
|
|
67
|
+
unit?: string;
|
|
68
|
+
timezone?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
export interface Policy {
|
|
63
72
|
readonly policy_id: string;
|
|
64
73
|
readonly event_id: string;
|
|
@@ -73,6 +82,10 @@ export interface Policy {
|
|
|
73
82
|
readonly enabled: boolean;
|
|
74
83
|
}
|
|
75
84
|
|
|
85
|
+
export type CreatePolicyPayload = Omit<Policy, "policy_id">;
|
|
86
|
+
|
|
87
|
+
export type UpdatePolicyPayload = Partial<Omit<Policy, "policy_id">>;
|
|
88
|
+
|
|
76
89
|
export interface Alert {
|
|
77
90
|
readonly alert_id: string;
|
|
78
91
|
readonly policy_id: string;
|
|
@@ -98,7 +111,7 @@ export interface Alert {
|
|
|
98
111
|
export interface AlertDelivery {
|
|
99
112
|
readonly attempt_id: string;
|
|
100
113
|
readonly alert_id: string;
|
|
101
|
-
readonly
|
|
114
|
+
readonly destination_id?: string;
|
|
102
115
|
readonly channel: string;
|
|
103
116
|
readonly target: string;
|
|
104
117
|
readonly status: string;
|
|
@@ -107,6 +120,20 @@ export interface AlertDelivery {
|
|
|
107
120
|
readonly created_at: string;
|
|
108
121
|
}
|
|
109
122
|
|
|
123
|
+
export interface Destination {
|
|
124
|
+
readonly destination_id: string;
|
|
125
|
+
readonly channel: string;
|
|
126
|
+
readonly url?: string;
|
|
127
|
+
readonly credentials?: Record<string, unknown>;
|
|
128
|
+
readonly scope: string;
|
|
129
|
+
readonly policy_ids?: string[];
|
|
130
|
+
readonly enabled: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type CreateDestinationPayload = Omit<Destination, "destination_id">;
|
|
134
|
+
|
|
135
|
+
export type UpdateDestinationPayload = Partial<Omit<Destination, "destination_id">>;
|
|
136
|
+
|
|
110
137
|
export interface EventLogPoint {
|
|
111
138
|
readonly event_id: string;
|
|
112
139
|
readonly agent?: string;
|
|
@@ -120,6 +147,43 @@ export interface EventLogPoint {
|
|
|
120
147
|
readonly max: number;
|
|
121
148
|
}
|
|
122
149
|
|
|
150
|
+
export interface AnalyticsWindowQuery {
|
|
151
|
+
view: "window";
|
|
152
|
+
period: "1h" | "1d" | "7d" | "1m";
|
|
153
|
+
previous: "previous_window" | "previous_1d" | "previous_7d" | "previous_1m";
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface AnalyticsWindowData {
|
|
157
|
+
readonly current_value: number;
|
|
158
|
+
readonly current_count: number;
|
|
159
|
+
readonly previous_value: number;
|
|
160
|
+
readonly previous_count: number;
|
|
161
|
+
readonly value_delta: number;
|
|
162
|
+
readonly count_delta: number;
|
|
163
|
+
readonly value_pct_change: number;
|
|
164
|
+
readonly count_pct_change: number;
|
|
165
|
+
readonly current_mean: number;
|
|
166
|
+
readonly previous_mean: number;
|
|
167
|
+
readonly mean_delta: number;
|
|
168
|
+
readonly mean_pct_change: number;
|
|
169
|
+
readonly current_stddev: number;
|
|
170
|
+
readonly previous_stddev: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface AnalyticsWindowResponse {
|
|
174
|
+
readonly event_id: string;
|
|
175
|
+
readonly view: "window";
|
|
176
|
+
readonly period: "1h" | "1d" | "7d" | "1m";
|
|
177
|
+
readonly previous: "previous_window" | "previous_1d" | "previous_7d" | "previous_1m";
|
|
178
|
+
readonly data: AnalyticsWindowData | null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface DestinationTestResult {
|
|
182
|
+
readonly alert_id: string;
|
|
183
|
+
readonly destination_id: string;
|
|
184
|
+
readonly status: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
123
187
|
export interface PaginationOptions {
|
|
124
188
|
period?: "minute" | "hour" | "day";
|
|
125
189
|
limit?: number;
|
|
@@ -435,6 +499,11 @@ export class Client {
|
|
|
435
499
|
return response.data;
|
|
436
500
|
}
|
|
437
501
|
|
|
502
|
+
public async createEvent(payload: CreateEventPayload): Promise<Event> {
|
|
503
|
+
const response = await this.axiosInstance.post<Event>(`${this.servicerEndpoint}/events`, payload);
|
|
504
|
+
return response.data;
|
|
505
|
+
}
|
|
506
|
+
|
|
438
507
|
public async getEvent(eventID: string): Promise<Event> {
|
|
439
508
|
const response = await this.axiosInstance.get<Event>(`${this.servicerEndpoint}/events/${eventID}`);
|
|
440
509
|
return response.data;
|
|
@@ -456,11 +525,21 @@ export class Client {
|
|
|
456
525
|
return response.data;
|
|
457
526
|
}
|
|
458
527
|
|
|
459
|
-
public async
|
|
528
|
+
public async getPolicy(policyID: string): Promise<Policy> {
|
|
529
|
+
const response = await this.axiosInstance.get<Policy>(`${this.servicerEndpoint}/policies/${policyID}`);
|
|
530
|
+
return response.data;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
public async createPolicy(payload: CreatePolicyPayload): Promise<Policy> {
|
|
460
534
|
const response = await this.axiosInstance.post<Policy>(`${this.servicerEndpoint}/policies`, payload);
|
|
461
535
|
return response.data;
|
|
462
536
|
}
|
|
463
537
|
|
|
538
|
+
public async updatePolicy(policyID: string, payload: UpdatePolicyPayload): Promise<Policy> {
|
|
539
|
+
const response = await this.axiosInstance.put<Policy>(`${this.servicerEndpoint}/policies/${policyID}`, payload);
|
|
540
|
+
return response.data;
|
|
541
|
+
}
|
|
542
|
+
|
|
464
543
|
public async listAlerts(status?: string): Promise<Alert[]> {
|
|
465
544
|
const endpoint = status
|
|
466
545
|
? `${this.servicerEndpoint}/alerts?status=${encodeURIComponent(status)}`
|
|
@@ -469,6 +548,11 @@ export class Client {
|
|
|
469
548
|
return response.data;
|
|
470
549
|
}
|
|
471
550
|
|
|
551
|
+
public async getAlert(alertID: string): Promise<Alert> {
|
|
552
|
+
const response = await this.axiosInstance.get<Alert>(`${this.servicerEndpoint}/alerts/${alertID}`);
|
|
553
|
+
return response.data;
|
|
554
|
+
}
|
|
555
|
+
|
|
472
556
|
public async getAlertDeliveries(alertID: string, options: { limit?: number; offset?: number; kind?: DeliveryKind } = {}): Promise<AlertDelivery[]> {
|
|
473
557
|
const params = new URLSearchParams();
|
|
474
558
|
if (options.kind) {
|
|
@@ -495,8 +579,29 @@ export class Client {
|
|
|
495
579
|
return response.data;
|
|
496
580
|
}
|
|
497
581
|
|
|
498
|
-
public async
|
|
499
|
-
await this.axiosInstance.
|
|
582
|
+
public async listDestinations(): Promise<Destination[]> {
|
|
583
|
+
const response = await this.axiosInstance.get<Destination[]>(`${this.servicerEndpoint}/destinations`);
|
|
584
|
+
return response.data;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
public async createDestination(payload: CreateDestinationPayload): Promise<Destination> {
|
|
588
|
+
const response = await this.axiosInstance.post<Destination>(`${this.servicerEndpoint}/destinations`, payload);
|
|
589
|
+
return response.data;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
public async getDestination(destinationID: string): Promise<Destination> {
|
|
593
|
+
const response = await this.axiosInstance.get<Destination>(`${this.servicerEndpoint}/destinations/${destinationID}`);
|
|
594
|
+
return response.data;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
public async updateDestination(destinationID: string, payload: UpdateDestinationPayload): Promise<Destination> {
|
|
598
|
+
const response = await this.axiosInstance.put<Destination>(`${this.servicerEndpoint}/destinations/${destinationID}`, payload);
|
|
599
|
+
return response.data;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
public async testDestination(destinationID: string): Promise<DestinationTestResult> {
|
|
603
|
+
const response = await this.axiosInstance.post<DestinationTestResult>(`${this.servicerEndpoint}/destinations/${destinationID}/test`);
|
|
604
|
+
return response.data;
|
|
500
605
|
}
|
|
501
606
|
|
|
502
607
|
public async getEventLogs(eventID: string, options: PaginationOptions = {}): Promise<EventLogPoint[]> {
|
|
@@ -515,6 +620,15 @@ export class Client {
|
|
|
515
620
|
return response.data;
|
|
516
621
|
}
|
|
517
622
|
|
|
623
|
+
public async getEventAnalytics(eventID: string, query: AnalyticsWindowQuery): Promise<AnalyticsWindowResponse> {
|
|
624
|
+
const params = new URLSearchParams();
|
|
625
|
+
params.set("view", query.view);
|
|
626
|
+
params.set("period", query.period);
|
|
627
|
+
params.set("previous", query.previous);
|
|
628
|
+
const response = await this.axiosInstance.get<AnalyticsWindowResponse>(`${this.servicerEndpoint}/events/${eventID}/analytics?${params.toString()}`);
|
|
629
|
+
return response.data;
|
|
630
|
+
}
|
|
631
|
+
|
|
518
632
|
public async resolveAlert(alertID: string): Promise<Alert> {
|
|
519
633
|
const response = await this.axiosInstance.post<Alert>(`${this.servicerEndpoint}/alerts/${alertID}/resolve`);
|
|
520
634
|
return response.data;
|