@honeyhive/control-plane-sdk 1.0.0-rc.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.
- package/.github/workflows/publish.yaml +173 -0
- package/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/generated/apiTypes.d.ts +410 -0
- package/dist/generated/apiTypes.d.ts.map +1 -0
- package/dist/generated/apiTypes.js +3 -0
- package/dist/generated/apiTypes.js.map +1 -0
- package/dist/generated/client.d.ts +83 -0
- package/dist/generated/client.d.ts.map +1 -0
- package/dist/generated/client.js +134 -0
- package/dist/generated/client.js.map +1 -0
- package/dist/generated/types.d.ts +672 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +2 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/generated/version.d.ts +2 -0
- package/dist/generated/version.d.ts.map +1 -0
- package/dist/generated/version.js +3 -0
- package/dist/generated/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/util.d.ts +131 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +270 -0
- package/dist/util.js.map +1 -0
- package/package.json +28 -0
- package/src/generated/apiTypes.ts +471 -0
- package/src/generated/client.ts +187 -0
- package/src/generated/types.ts +683 -0
- package/src/generated/version.ts +3 -0
- package/src/index.ts +26 -0
- package/src/util.ts +386 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
// AUTO-GENERATED — do not edit manually. Run `pnpm turbo run generate` to regenerate.
|
|
2
|
+
|
|
3
|
+
// ---- Request types ----
|
|
4
|
+
|
|
5
|
+
export interface ListAlertsRequest {
|
|
6
|
+
/** @description The unique identifier of the project whose alerts are listed */
|
|
7
|
+
project_id: string;
|
|
8
|
+
/** @description 1-indexed page number */
|
|
9
|
+
page?: number;
|
|
10
|
+
/** @description Number of alerts to return per page */
|
|
11
|
+
limit?: number;
|
|
12
|
+
/** @description Only return alerts in this status */
|
|
13
|
+
status?: 'ACTIVE' | 'TRIGGERED' | 'PAUSED' | 'RESOLVED';
|
|
14
|
+
/** @description Field to sort results by */
|
|
15
|
+
sort_by?: 'created_at' | 'updated_at' | 'name' | 'status' | 'frequency' | 'last_triggered';
|
|
16
|
+
/** @description Sort order */
|
|
17
|
+
sort_order?: 'asc' | 'desc';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CreateAlertRequest {
|
|
21
|
+
/** @description The unique identifier of the project the alert is created in */
|
|
22
|
+
project_id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
/** @enum {string} */
|
|
26
|
+
frequency: 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY';
|
|
27
|
+
/** @default 0 */
|
|
28
|
+
minimum_sample_size?: number;
|
|
29
|
+
/**
|
|
30
|
+
* @default AGGREGATE
|
|
31
|
+
* @enum {string}
|
|
32
|
+
*/
|
|
33
|
+
alert_type?: 'DRIFT' | 'AGGREGATE' | 'PER_EVENT';
|
|
34
|
+
/**
|
|
35
|
+
* @default AVERAGE
|
|
36
|
+
* @enum {string}
|
|
37
|
+
*/
|
|
38
|
+
aggregation?: 'AVERAGE' | 'COUNT' | 'SUM' | 'MIN' | 'MAX' | 'P90' | 'P95' | 'P99' | 'MEDIAN';
|
|
39
|
+
thresholds: PostAlertRequestThresholds;
|
|
40
|
+
filters: SingleFilter[];
|
|
41
|
+
projections: string[];
|
|
42
|
+
notification_details: PostAlertRequestNotificationDetails;
|
|
43
|
+
/** @enum {string} */
|
|
44
|
+
status?: 'ACTIVE' | 'TRIGGERED' | 'PAUSED' | 'RESOLVED';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface GetAlertRequest {
|
|
48
|
+
/** @description The unique identifier of the project the alert belongs to */
|
|
49
|
+
project_id: string;
|
|
50
|
+
/** @description The unique identifier of the alert to retrieve */
|
|
51
|
+
alert_id: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CreateProjectRequest {
|
|
55
|
+
/** @description The unique identifier of the workspace the project is created in */
|
|
56
|
+
workspace_id: string;
|
|
57
|
+
/** @description Project display name */
|
|
58
|
+
name: string;
|
|
59
|
+
/** @description Project description */
|
|
60
|
+
description?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Format: email
|
|
63
|
+
* @description Email of the user to grant the project-creator membership to (API key actors only)
|
|
64
|
+
*/
|
|
65
|
+
project_creator?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface GetProjectRequest {
|
|
69
|
+
/** @description The unique identifier of the project to retrieve */
|
|
70
|
+
project_id: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface UpdateProjectRequest {
|
|
74
|
+
/** @description The unique identifier of the project to update */
|
|
75
|
+
project_id: string;
|
|
76
|
+
/** @description Project display name */
|
|
77
|
+
name?: string;
|
|
78
|
+
/** @description Project description */
|
|
79
|
+
description?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DeleteProjectRequest {
|
|
83
|
+
/** @description The unique identifier of the project to delete */
|
|
84
|
+
project_id: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ---- Response types ----
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @description A paginated list of alerts
|
|
91
|
+
*/
|
|
92
|
+
export type ListAlertsResponse = {
|
|
93
|
+
/** @enum {boolean} */
|
|
94
|
+
success: true;
|
|
95
|
+
data: AlertItem[];
|
|
96
|
+
pagination: Pagination;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @description The created alert
|
|
101
|
+
*/
|
|
102
|
+
export type CreateAlertResponse = {
|
|
103
|
+
/** @enum {boolean} */
|
|
104
|
+
success: true;
|
|
105
|
+
data: AlertItem;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @description A single alert
|
|
110
|
+
*/
|
|
111
|
+
export type GetAlertResponse = {
|
|
112
|
+
/** @enum {boolean} */
|
|
113
|
+
success: true;
|
|
114
|
+
data: AlertItem;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @description The created project
|
|
119
|
+
*/
|
|
120
|
+
export type CreateProjectResponse = {
|
|
121
|
+
success: boolean;
|
|
122
|
+
data: ProjectItem;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @description A single project
|
|
127
|
+
*/
|
|
128
|
+
export type GetProjectResponse = {
|
|
129
|
+
success: boolean;
|
|
130
|
+
data: ProjectItem;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @description The updated project
|
|
135
|
+
*/
|
|
136
|
+
export type UpdateProjectResponse = {
|
|
137
|
+
success: boolean;
|
|
138
|
+
data: ProjectItem;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @description The deleted (archived) project
|
|
143
|
+
*/
|
|
144
|
+
export type DeleteProjectResponse = {
|
|
145
|
+
success: boolean;
|
|
146
|
+
data: ProjectItem;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// ---- Internal types ----
|
|
150
|
+
//
|
|
151
|
+
// These types are not part of the public API surface (not re-exported
|
|
152
|
+
// from index.ts) and are tagged @inline so TypeDoc renders their
|
|
153
|
+
// bodies inline at use sites rather than as standalone pages.
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @description Alert object
|
|
157
|
+
* @inline
|
|
158
|
+
*/
|
|
159
|
+
export type AlertItem = {
|
|
160
|
+
id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
description?: string | null;
|
|
163
|
+
/** @enum {string} */
|
|
164
|
+
status: 'ACTIVE' | 'TRIGGERED' | 'PAUSED' | 'RESOLVED';
|
|
165
|
+
/** @enum {string} */
|
|
166
|
+
frequency: 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY';
|
|
167
|
+
minimum_sample_size: number;
|
|
168
|
+
/** @enum {string} */
|
|
169
|
+
alert_type: 'DRIFT' | 'AGGREGATE' | 'PER_EVENT';
|
|
170
|
+
aggregation: string;
|
|
171
|
+
event_filters: AlertEventFilter[];
|
|
172
|
+
event_metrics: AlertEventMetric[];
|
|
173
|
+
thresholds: AlertItemThresholds;
|
|
174
|
+
last_run_at?: string | null;
|
|
175
|
+
last_result?:
|
|
176
|
+
| ({
|
|
177
|
+
current_bucket_score?: number | boolean;
|
|
178
|
+
previous_bucket_score?: number | boolean;
|
|
179
|
+
last_triggered_baseline?: number | boolean;
|
|
180
|
+
drift_percentage?: number;
|
|
181
|
+
thresholds?: AlertItemLastResultThresholds;
|
|
182
|
+
event_filters?: unknown[];
|
|
183
|
+
event_metrics?: unknown[];
|
|
184
|
+
aggregation?: string;
|
|
185
|
+
} & {
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
})
|
|
188
|
+
| null;
|
|
189
|
+
trigger_error?: string | null;
|
|
190
|
+
is_active: boolean;
|
|
191
|
+
is_muted: boolean;
|
|
192
|
+
created_at: string;
|
|
193
|
+
updated_at?: string | null;
|
|
194
|
+
last_trigger_id?: string | null;
|
|
195
|
+
scope_type: string;
|
|
196
|
+
scope_id: string;
|
|
197
|
+
created_by?: string | null;
|
|
198
|
+
last_trigger?: AlertTrigger;
|
|
199
|
+
triggers?: AlertTrigger[];
|
|
200
|
+
notifications?: AlertNotification[];
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @inline
|
|
205
|
+
*/
|
|
206
|
+
export type AlertEventFilter = {
|
|
207
|
+
filter: SingleFilter;
|
|
208
|
+
/** @enum {string} */
|
|
209
|
+
type: 'float' | 'numeric' | 'boolean' | 'string' | 'null';
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @inline
|
|
214
|
+
*/
|
|
215
|
+
export type SingleFilter = {
|
|
216
|
+
field: string;
|
|
217
|
+
/** @enum {string} */
|
|
218
|
+
operator:
|
|
219
|
+
| 'exists'
|
|
220
|
+
| 'not exists'
|
|
221
|
+
| 'is'
|
|
222
|
+
| 'is not'
|
|
223
|
+
| 'contains'
|
|
224
|
+
| 'not contains'
|
|
225
|
+
| 'greater than'
|
|
226
|
+
| 'less than'
|
|
227
|
+
| 'after'
|
|
228
|
+
| 'before';
|
|
229
|
+
value: string | number | boolean | null;
|
|
230
|
+
/** @enum {string} */
|
|
231
|
+
type: 'string' | 'number' | 'boolean' | 'datetime';
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @inline
|
|
236
|
+
*/
|
|
237
|
+
export type AlertEventMetric = {
|
|
238
|
+
/** @description Projected field or metric for this entry */
|
|
239
|
+
projection: string;
|
|
240
|
+
/** @enum {string} */
|
|
241
|
+
type: 'float' | 'numeric' | 'boolean' | 'string' | 'null';
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @inline
|
|
246
|
+
*/
|
|
247
|
+
export type AlertTrigger = {
|
|
248
|
+
id: string;
|
|
249
|
+
alert_id: string;
|
|
250
|
+
result: AlertTriggerResult;
|
|
251
|
+
muted: boolean;
|
|
252
|
+
notification_sent: boolean;
|
|
253
|
+
triggered_time: string;
|
|
254
|
+
resolved_time: string | null;
|
|
255
|
+
resolved_by: string | null;
|
|
256
|
+
created_at: string;
|
|
257
|
+
updated_at: string;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @inline
|
|
262
|
+
*/
|
|
263
|
+
export type AlertNotification = {
|
|
264
|
+
id: string;
|
|
265
|
+
alert_id: string;
|
|
266
|
+
/** @enum {string} */
|
|
267
|
+
stage: 'CRITICAL' | 'RESOLUTION';
|
|
268
|
+
/** @enum {string} */
|
|
269
|
+
channel: 'EMAIL' | 'SLACK' | 'WEBHOOK';
|
|
270
|
+
/** @enum {string} */
|
|
271
|
+
scope: 'ALL_PROJECT_MEMBERS' | 'SPECIFIC_MEMBER';
|
|
272
|
+
membership_id?: string | null;
|
|
273
|
+
metadata?: {
|
|
274
|
+
[key: string]: unknown;
|
|
275
|
+
} | null;
|
|
276
|
+
last_sent_at?: string | null;
|
|
277
|
+
created_at: string;
|
|
278
|
+
membership?: {
|
|
279
|
+
user: AlertNotificationMembershipUser;
|
|
280
|
+
} | null;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @inline
|
|
285
|
+
*/
|
|
286
|
+
export type Pagination = {
|
|
287
|
+
page: number;
|
|
288
|
+
limit: number;
|
|
289
|
+
total: number;
|
|
290
|
+
total_unfiltered: number;
|
|
291
|
+
total_pages: number;
|
|
292
|
+
has_next: boolean;
|
|
293
|
+
has_prev: boolean;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @description Project object
|
|
298
|
+
* @inline
|
|
299
|
+
*/
|
|
300
|
+
export type ProjectItem = {
|
|
301
|
+
id: string;
|
|
302
|
+
/** @description Project display name */
|
|
303
|
+
name: string;
|
|
304
|
+
/** @description Project description */
|
|
305
|
+
description: string;
|
|
306
|
+
created_at: string;
|
|
307
|
+
updated_at?: string | null;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @inline
|
|
312
|
+
*/
|
|
313
|
+
export type AlertItemThresholdsCritical = {
|
|
314
|
+
/** @enum {string} */
|
|
315
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
316
|
+
value: number;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @inline
|
|
321
|
+
*/
|
|
322
|
+
export type AlertItemThresholdsResolved = {
|
|
323
|
+
/** @enum {string} */
|
|
324
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
325
|
+
value: number;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @inline
|
|
330
|
+
*/
|
|
331
|
+
export type AlertItemThresholds = {
|
|
332
|
+
critical: AlertItemThresholdsCritical;
|
|
333
|
+
resolved: AlertItemThresholdsResolved;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @inline
|
|
338
|
+
*/
|
|
339
|
+
export type AlertItemLastResultThresholdsCritical = {
|
|
340
|
+
/** @enum {string} */
|
|
341
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
342
|
+
value: number;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @inline
|
|
347
|
+
*/
|
|
348
|
+
export type AlertItemLastResultThresholdsResolved = {
|
|
349
|
+
/** @enum {string} */
|
|
350
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
351
|
+
value: number;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @inline
|
|
356
|
+
*/
|
|
357
|
+
export type AlertItemLastResultThresholds = {
|
|
358
|
+
critical: AlertItemLastResultThresholdsCritical;
|
|
359
|
+
resolved: AlertItemLastResultThresholdsResolved;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @inline
|
|
364
|
+
*/
|
|
365
|
+
export type AlertTriggerResultThresholdsCritical = {
|
|
366
|
+
/** @enum {string} */
|
|
367
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
368
|
+
value: number;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @inline
|
|
373
|
+
*/
|
|
374
|
+
export type AlertTriggerResultThresholdsResolved = {
|
|
375
|
+
/** @enum {string} */
|
|
376
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
377
|
+
value: number;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @inline
|
|
382
|
+
*/
|
|
383
|
+
export type AlertTriggerResultThresholds = {
|
|
384
|
+
critical: AlertTriggerResultThresholdsCritical;
|
|
385
|
+
resolved: AlertTriggerResultThresholdsResolved;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* @inline
|
|
390
|
+
*/
|
|
391
|
+
export type AlertTriggerResult = {
|
|
392
|
+
current_bucket_score?: number | boolean;
|
|
393
|
+
previous_bucket_score?: number | boolean;
|
|
394
|
+
last_triggered_baseline?: number | boolean;
|
|
395
|
+
drift_percentage?: number;
|
|
396
|
+
thresholds?: AlertTriggerResultThresholds;
|
|
397
|
+
event_filters?: unknown[];
|
|
398
|
+
event_metrics?: unknown[];
|
|
399
|
+
aggregation?: string;
|
|
400
|
+
} & {
|
|
401
|
+
[key: string]: unknown;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @inline
|
|
406
|
+
*/
|
|
407
|
+
export type AlertNotificationMembershipUser = {
|
|
408
|
+
id: string;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @inline
|
|
413
|
+
*/
|
|
414
|
+
export type PostAlertRequestThresholdsCritical = {
|
|
415
|
+
/** @enum {string} */
|
|
416
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
417
|
+
value: number;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @inline
|
|
422
|
+
*/
|
|
423
|
+
export type PostAlertRequestThresholdsResolved = {
|
|
424
|
+
/** @enum {string} */
|
|
425
|
+
operator: 'greater_than' | 'less_than' | 'equal_to';
|
|
426
|
+
value: number;
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @inline
|
|
431
|
+
*/
|
|
432
|
+
export type PostAlertRequestThresholds = {
|
|
433
|
+
critical: PostAlertRequestThresholdsCritical;
|
|
434
|
+
resolved: PostAlertRequestThresholdsResolved;
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @inline
|
|
439
|
+
*/
|
|
440
|
+
export type PostAlertRequestNotificationDetailsCritical = {
|
|
441
|
+
/** @enum {string} */
|
|
442
|
+
channel: 'EMAIL' | 'SLACK' | 'WEBHOOK';
|
|
443
|
+
/** @enum {string} */
|
|
444
|
+
scope: 'ALL_PROJECT_MEMBERS' | 'SPECIFIC_MEMBER';
|
|
445
|
+
user_ids?: string[];
|
|
446
|
+
metadata: {
|
|
447
|
+
[key: string]: unknown;
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* @inline
|
|
453
|
+
*/
|
|
454
|
+
export type PostAlertRequestNotificationDetailsResolved = {
|
|
455
|
+
/** @enum {string} */
|
|
456
|
+
channel: 'EMAIL' | 'SLACK' | 'WEBHOOK';
|
|
457
|
+
/** @enum {string} */
|
|
458
|
+
scope: 'ALL_PROJECT_MEMBERS' | 'SPECIFIC_MEMBER';
|
|
459
|
+
user_ids?: string[];
|
|
460
|
+
metadata: {
|
|
461
|
+
[key: string]: unknown;
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @inline
|
|
467
|
+
*/
|
|
468
|
+
export type PostAlertRequestNotificationDetails = {
|
|
469
|
+
critical: PostAlertRequestNotificationDetailsCritical;
|
|
470
|
+
resolved: PostAlertRequestNotificationDetailsResolved;
|
|
471
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// AUTO-GENERATED — do not edit manually. Run `pnpm turbo run generate` to regenerate.
|
|
2
|
+
|
|
3
|
+
import { type paths } from './types.js';
|
|
4
|
+
import {
|
|
5
|
+
type ListAlertsRequest,
|
|
6
|
+
type CreateAlertRequest,
|
|
7
|
+
type GetAlertRequest,
|
|
8
|
+
type CreateProjectRequest,
|
|
9
|
+
type GetProjectRequest,
|
|
10
|
+
type UpdateProjectRequest,
|
|
11
|
+
type DeleteProjectRequest,
|
|
12
|
+
type ListAlertsResponse,
|
|
13
|
+
type CreateAlertResponse,
|
|
14
|
+
type GetAlertResponse,
|
|
15
|
+
type CreateProjectResponse,
|
|
16
|
+
type GetProjectResponse,
|
|
17
|
+
type UpdateProjectResponse,
|
|
18
|
+
type DeleteProjectResponse,
|
|
19
|
+
} from './apiTypes.js';
|
|
20
|
+
import { type ClientConfig, type FetchOptions, createApiClient, unwrap } from '../util.js';
|
|
21
|
+
|
|
22
|
+
/** @inline */
|
|
23
|
+
class AlertsNamespace {
|
|
24
|
+
#client: ReturnType<typeof createApiClient<paths>>;
|
|
25
|
+
|
|
26
|
+
constructor(client: ReturnType<typeof createApiClient<paths>>) {
|
|
27
|
+
this.#client = client;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* List alerts
|
|
32
|
+
*
|
|
33
|
+
* List the alerts in a project. The project is identified by the `project_id` path parameter
|
|
34
|
+
* alone; the `x-hh-project-id` header does not participate. Supports offset pagination, an
|
|
35
|
+
* optional status filter, and sorting (defaults to most recently created first).
|
|
36
|
+
*/
|
|
37
|
+
public list(request: ListAlertsRequest, options?: FetchOptions): Promise<ListAlertsResponse> {
|
|
38
|
+
const { project_id, page, limit, status, sort_by, sort_order } = request;
|
|
39
|
+
return unwrap(
|
|
40
|
+
this.#client.GET('/v1/projects/{project_id}/alerts', {
|
|
41
|
+
params: { path: { project_id }, query: { page, limit, status, sort_by, sort_order } },
|
|
42
|
+
...options,
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create an alert
|
|
49
|
+
*
|
|
50
|
+
* Create an alert in a project. The project is identified by the `project_id` path parameter
|
|
51
|
+
* alone; the `x-hh-project-id` header does not participate. The alert's `filters` and
|
|
52
|
+
* `projections` (metrics) are mapped against the project's logged-event schema; if no schema
|
|
53
|
+
* data matches them — e.g. no events have been logged to the project yet — the request fails
|
|
54
|
+
* with a 400.
|
|
55
|
+
*/
|
|
56
|
+
public create(request: CreateAlertRequest, options?: FetchOptions): Promise<CreateAlertResponse> {
|
|
57
|
+
const { project_id, ...body } = request;
|
|
58
|
+
return unwrap(
|
|
59
|
+
this.#client.POST('/v1/projects/{project_id}/alerts', {
|
|
60
|
+
params: { path: { project_id } },
|
|
61
|
+
body,
|
|
62
|
+
...options,
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get an alert
|
|
69
|
+
*
|
|
70
|
+
* Retrieve a single alert by id, including its thresholds, triggers, and notification
|
|
71
|
+
* configuration. The alert's project is identified by the `project_id` path parameter alone;
|
|
72
|
+
* the `x-hh-project-id` header does not participate.
|
|
73
|
+
*/
|
|
74
|
+
public get(request: GetAlertRequest, options?: FetchOptions): Promise<GetAlertResponse> {
|
|
75
|
+
const { project_id, alert_id } = request;
|
|
76
|
+
return unwrap(
|
|
77
|
+
this.#client.GET('/v1/projects/{project_id}/alerts/{alert_id}', {
|
|
78
|
+
params: { path: { project_id, alert_id } },
|
|
79
|
+
...options,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @inline */
|
|
86
|
+
class ProjectsNamespace {
|
|
87
|
+
#client: ReturnType<typeof createApiClient<paths>>;
|
|
88
|
+
|
|
89
|
+
constructor(client: ReturnType<typeof createApiClient<paths>>) {
|
|
90
|
+
this.#client = client;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create a project
|
|
95
|
+
*
|
|
96
|
+
* Create a project in a workspace. The parent workspace is identified by the `workspace_id`
|
|
97
|
+
* path parameter alone; the `x-hh-workspace-id` header does not participate.
|
|
98
|
+
*
|
|
99
|
+
* The optional `project_creator` field names the user (by email) who receives the
|
|
100
|
+
* project-creator membership on the new project. The named user must already be a member of
|
|
101
|
+
* the workspace. When omitted, the project is created without any membership. The field is
|
|
102
|
+
* only accepted on API-key-initiated requests — user-initiated creation always makes the
|
|
103
|
+
* calling user the creator and rejects the field with a 400.
|
|
104
|
+
*/
|
|
105
|
+
public create(
|
|
106
|
+
request: CreateProjectRequest,
|
|
107
|
+
options?: FetchOptions,
|
|
108
|
+
): Promise<CreateProjectResponse> {
|
|
109
|
+
const { workspace_id, ...body } = request;
|
|
110
|
+
return unwrap(
|
|
111
|
+
this.#client.POST('/v1/workspaces/{workspace_id}/projects', {
|
|
112
|
+
params: { path: { workspace_id } },
|
|
113
|
+
body,
|
|
114
|
+
...options,
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get a project
|
|
121
|
+
*
|
|
122
|
+
* Retrieve a single project by id. The project is identified by the `project_id` path
|
|
123
|
+
* parameter alone; the `x-hh-project-id` header does not participate.
|
|
124
|
+
*/
|
|
125
|
+
public get(request: GetProjectRequest, options?: FetchOptions): Promise<GetProjectResponse> {
|
|
126
|
+
const { project_id } = request;
|
|
127
|
+
return unwrap(
|
|
128
|
+
this.#client.GET('/v1/projects/{project_id}', {
|
|
129
|
+
params: { path: { project_id } },
|
|
130
|
+
...options,
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Update a project
|
|
137
|
+
*
|
|
138
|
+
* Update a project's display name and/or description. The project is identified by the
|
|
139
|
+
* `project_id` path parameter alone; the `x-hh-project-id` header does not participate.
|
|
140
|
+
* Only fields included in the request body are modified.
|
|
141
|
+
*/
|
|
142
|
+
public update(
|
|
143
|
+
request: UpdateProjectRequest,
|
|
144
|
+
options?: FetchOptions,
|
|
145
|
+
): Promise<UpdateProjectResponse> {
|
|
146
|
+
const { project_id, ...body } = request;
|
|
147
|
+
return unwrap(
|
|
148
|
+
this.#client.PUT('/v1/projects/{project_id}', {
|
|
149
|
+
params: { path: { project_id } },
|
|
150
|
+
body,
|
|
151
|
+
...options,
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Delete a project
|
|
158
|
+
*
|
|
159
|
+
* Delete a project. The project is soft-deleted (archived) and no longer appears in reads;
|
|
160
|
+
* the response returns the archived project. The project is identified by the `project_id`
|
|
161
|
+
* path parameter alone; the `x-hh-project-id` header does not participate.
|
|
162
|
+
*/
|
|
163
|
+
public delete(
|
|
164
|
+
request: DeleteProjectRequest,
|
|
165
|
+
options?: FetchOptions,
|
|
166
|
+
): Promise<DeleteProjectResponse> {
|
|
167
|
+
const { project_id } = request;
|
|
168
|
+
return unwrap(
|
|
169
|
+
this.#client.DELETE('/v1/projects/{project_id}', {
|
|
170
|
+
params: { path: { project_id } },
|
|
171
|
+
...options,
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export class Client {
|
|
178
|
+
#client: ReturnType<typeof createApiClient<paths>>;
|
|
179
|
+
readonly alerts: AlertsNamespace;
|
|
180
|
+
readonly projects: ProjectsNamespace;
|
|
181
|
+
|
|
182
|
+
constructor(options: ClientConfig = {}) {
|
|
183
|
+
this.#client = createApiClient<paths>(options);
|
|
184
|
+
this.alerts = new AlertsNamespace(this.#client);
|
|
185
|
+
this.projects = new ProjectsNamespace(this.#client);
|
|
186
|
+
}
|
|
187
|
+
}
|