@rustrak/client 0.16.4 → 0.18.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 +9 -9
- package/dist/index.cjs +507 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +623 -4
- package/dist/index.d.ts +623 -4
- package/dist/index.js +507 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<a href="https://rustrak.
|
|
2
|
+
<a href="https://rustrak.dev">
|
|
3
3
|
<img src="https://raw.githubusercontent.com/rustrak/rustrak/main/apps/docs/public/logo.svg" alt="Rustrak" width="64" height="64" />
|
|
4
4
|
</a>
|
|
5
5
|
<h1>@rustrak/client</h1>
|
|
6
|
-
<p>Official TypeScript client for the <a href="https://rustrak.
|
|
6
|
+
<p>Official TypeScript client for the <a href="https://rustrak.dev">Rustrak</a> self-hosted error tracking API</p>
|
|
7
7
|
|
|
8
8
|
<p>
|
|
9
9
|
<a href="https://www.npmjs.com/package/@rustrak/client">
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
<p>
|
|
27
|
-
<a href="https://rustrak.
|
|
27
|
+
<a href="https://rustrak.dev/sdks/client">Documentation</a>
|
|
28
28
|
·
|
|
29
29
|
<a href="https://github.com/rustrak/rustrak">GitHub</a>
|
|
30
30
|
·
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
`@rustrak/client` is the official TypeScript client for [Rustrak](https://rustrak.
|
|
37
|
+
`@rustrak/client` is the official TypeScript client for [Rustrak](https://rustrak.dev) — an ultra-lightweight, self-hosted error tracking system compatible with any Sentry SDK. This package wraps the Rustrak REST API with full type safety, runtime validation via Zod, built-in retry logic, and structured error handling. Total bundle size: ~28 KB.
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
@@ -78,7 +78,7 @@ const resolved = await client.issues.updateState(1, 'issue-id', {
|
|
|
78
78
|
});
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
**[Full documentation →](https://rustrak.
|
|
81
|
+
**[Full documentation →](https://rustrak.dev/sdks/client)**
|
|
82
82
|
|
|
83
83
|
## Features
|
|
84
84
|
|
|
@@ -319,11 +319,11 @@ import type {
|
|
|
319
319
|
|
|
320
320
|
## What is Rustrak?
|
|
321
321
|
|
|
322
|
-
[Rustrak](https://rustrak.
|
|
322
|
+
[Rustrak](https://rustrak.dev) is a self-hosted error tracking server written in Rust that accepts events from any Sentry SDK: point the SDK's DSN at it and nothing else changes. One container serves the API and the dashboard.
|
|
323
323
|
|
|
324
|
-
- [Getting Started](https://rustrak.
|
|
325
|
-
- [Self-Hosting Guide](https://rustrak.
|
|
326
|
-
- [API Reference](https://rustrak.
|
|
324
|
+
- [Getting Started](https://rustrak.dev/getting-started/overview)
|
|
325
|
+
- [Self-Hosting Guide](https://rustrak.dev/configuration/production)
|
|
326
|
+
- [API Reference](https://rustrak.dev/api-reference)
|
|
327
327
|
- [GitHub](https://github.com/rustrak/rustrak)
|
|
328
328
|
|
|
329
329
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -134,13 +134,24 @@ var alertRuleChannelInputSchema = zod.z.object({
|
|
|
134
134
|
integration_id: zod.z.number().int(),
|
|
135
135
|
routing_override: zod.z.record(zod.z.string(), zod.z.unknown()).default({})
|
|
136
136
|
});
|
|
137
|
+
var alertRuleConditionsSchema = zod.z.object({
|
|
138
|
+
/** The quietest level that still fires. The server takes `null` as absent. */
|
|
139
|
+
min_level: zod.z.enum(["debug", "info", "warning", "error", "fatal"]).nullish(),
|
|
140
|
+
/** When non-empty, the only environments that fire. */
|
|
141
|
+
environments: zod.z.array(zod.z.string()).optional(),
|
|
142
|
+
/** A new issue fires when it reaches this many events, not on its first. */
|
|
143
|
+
min_events: zod.z.number().int().min(1).nullish()
|
|
144
|
+
});
|
|
137
145
|
var alertRuleSchema = zod.z.object({
|
|
138
146
|
id: zod.z.number().int(),
|
|
139
147
|
project_id: zod.z.number().int(),
|
|
140
148
|
name: zod.z.string(),
|
|
141
149
|
alert_type: alertTypeSchema,
|
|
142
150
|
is_enabled: zod.z.boolean(),
|
|
143
|
-
|
|
151
|
+
// A rule stored before the filters existed may hold any object. The server
|
|
152
|
+
// evaluates one it cannot read as no filters; one bad row must not fail the
|
|
153
|
+
// whole list either.
|
|
154
|
+
conditions: alertRuleConditionsSchema.catch({}),
|
|
144
155
|
cooldown_minutes: zod.z.number().int(),
|
|
145
156
|
last_triggered_at: dateTimeSchema.nullable(),
|
|
146
157
|
created_at: dateTimeSchema,
|
|
@@ -153,13 +164,13 @@ var createAlertRuleSchema = zod.z.object({
|
|
|
153
164
|
alert_type: alertTypeSchema,
|
|
154
165
|
channels: zod.z.array(alertRuleChannelInputSchema).default([]),
|
|
155
166
|
is_enabled: zod.z.boolean().optional(),
|
|
156
|
-
conditions:
|
|
167
|
+
conditions: alertRuleConditionsSchema.optional(),
|
|
157
168
|
cooldown_minutes: zod.z.number().int().min(0).optional()
|
|
158
169
|
});
|
|
159
170
|
var updateAlertRuleSchema = zod.z.object({
|
|
160
171
|
name: zod.z.string().min(1).optional(),
|
|
161
172
|
is_enabled: zod.z.boolean().optional(),
|
|
162
|
-
conditions:
|
|
173
|
+
conditions: alertRuleConditionsSchema.optional(),
|
|
163
174
|
cooldown_minutes: zod.z.number().int().min(0).optional(),
|
|
164
175
|
channels: zod.z.array(alertRuleChannelInputSchema).optional()
|
|
165
176
|
});
|
|
@@ -231,6 +242,89 @@ var eventDetailSchema = zod.z.object({
|
|
|
231
242
|
data: zod.z.record(zod.z.string(), zod.z.any())
|
|
232
243
|
// Full Sentry event JSON
|
|
233
244
|
});
|
|
245
|
+
var gitHubAppSchema = zod.z.object({
|
|
246
|
+
app_id: zod.z.number().int(),
|
|
247
|
+
slug: zod.z.string(),
|
|
248
|
+
html_url: zod.z.string(),
|
|
249
|
+
owner_login: zod.z.string(),
|
|
250
|
+
install_url: zod.z.string(),
|
|
251
|
+
last_webhook_at: dateTimeSchema.nullable(),
|
|
252
|
+
created_at: dateTimeSchema
|
|
253
|
+
});
|
|
254
|
+
var gitHubInstallationSchema = zod.z.object({
|
|
255
|
+
id: zod.z.number().int(),
|
|
256
|
+
account_login: zod.z.string(),
|
|
257
|
+
account_type: zod.z.string(),
|
|
258
|
+
suspended: zod.z.boolean(),
|
|
259
|
+
created_at: dateTimeSchema
|
|
260
|
+
});
|
|
261
|
+
var gitHubStatusSchema = zod.z.object({
|
|
262
|
+
app: gitHubAppSchema.nullable(),
|
|
263
|
+
installations: zod.z.array(gitHubInstallationSchema),
|
|
264
|
+
webhook_url: zod.z.string()
|
|
265
|
+
});
|
|
266
|
+
var gitHubManifestSchema = zod.z.object({
|
|
267
|
+
action_url: zod.z.string(),
|
|
268
|
+
manifest: zod.z.string()
|
|
269
|
+
});
|
|
270
|
+
var gitHubRepositorySchema = zod.z.object({
|
|
271
|
+
installation_id: zod.z.number().int(),
|
|
272
|
+
full_name: zod.z.string(),
|
|
273
|
+
default_branch: zod.z.string(),
|
|
274
|
+
private: zod.z.boolean(),
|
|
275
|
+
html_url: zod.z.string()
|
|
276
|
+
});
|
|
277
|
+
var codeMappingSchema = zod.z.object({
|
|
278
|
+
stack_root: zod.z.string(),
|
|
279
|
+
source_root: zod.z.string()
|
|
280
|
+
});
|
|
281
|
+
var projectRepositorySchema = zod.z.object({
|
|
282
|
+
project_id: zod.z.number().int(),
|
|
283
|
+
installation_id: zod.z.number().int(),
|
|
284
|
+
repo_full_name: zod.z.string(),
|
|
285
|
+
default_branch: zod.z.string(),
|
|
286
|
+
html_url: zod.z.string(),
|
|
287
|
+
code_mappings: zod.z.array(codeMappingSchema),
|
|
288
|
+
/** Open a GitHub issue for new issues that pass `auto_create_conditions`. */
|
|
289
|
+
auto_create_issues: zod.z.boolean(),
|
|
290
|
+
auto_create_conditions: alertRuleConditionsSchema,
|
|
291
|
+
codeowners_rules: zod.z.number().int().nullable(),
|
|
292
|
+
codeowners_synced_at: dateTimeSchema.nullable()
|
|
293
|
+
});
|
|
294
|
+
var updateProjectRepositorySchema = zod.z.object({
|
|
295
|
+
installation_id: zod.z.number().int(),
|
|
296
|
+
repo_full_name: zod.z.string().min(1),
|
|
297
|
+
code_mappings: zod.z.array(codeMappingSchema).optional(),
|
|
298
|
+
auto_create_issues: zod.z.boolean().optional(),
|
|
299
|
+
auto_create_conditions: alertRuleConditionsSchema.optional()
|
|
300
|
+
});
|
|
301
|
+
var issueLinkSchema = zod.z.object({
|
|
302
|
+
id: zod.z.number().int(),
|
|
303
|
+
issue_id: zod.z.string(),
|
|
304
|
+
repo_full_name: zod.z.string(),
|
|
305
|
+
number: zod.z.number().int(),
|
|
306
|
+
title: zod.z.string(),
|
|
307
|
+
url: zod.z.string(),
|
|
308
|
+
state: zod.z.string(),
|
|
309
|
+
created_at: dateTimeSchema
|
|
310
|
+
});
|
|
311
|
+
var repoCommitSchema = zod.z.object({
|
|
312
|
+
repo_full_name: zod.z.string(),
|
|
313
|
+
sha: zod.z.string(),
|
|
314
|
+
message: zod.z.string(),
|
|
315
|
+
author_name: zod.z.string(),
|
|
316
|
+
author_login: zod.z.string().nullable(),
|
|
317
|
+
url: zod.z.string(),
|
|
318
|
+
committed_at: dateTimeSchema
|
|
319
|
+
});
|
|
320
|
+
var issueGitHubSchema = zod.z.object({
|
|
321
|
+
links: zod.z.array(issueLinkSchema),
|
|
322
|
+
suspect_commits: zod.z.array(repoCommitSchema),
|
|
323
|
+
owners: zod.z.array(zod.z.string())
|
|
324
|
+
});
|
|
325
|
+
var gitHubLoginSchema = zod.z.object({
|
|
326
|
+
login: zod.z.string().nullable()
|
|
327
|
+
});
|
|
234
328
|
var globalRoleSchema = zod.z.enum(["admin", "member"]);
|
|
235
329
|
var teamMemberSchema = zod.z.object({
|
|
236
330
|
id: zod.z.number().int(),
|
|
@@ -414,6 +508,96 @@ var upsertProjectMemberSchema = zod.z.object({
|
|
|
414
508
|
user_id: zod.z.number().int(),
|
|
415
509
|
role: projectRoleSchema
|
|
416
510
|
});
|
|
511
|
+
var intervalUnitSchema = zod.z.enum([
|
|
512
|
+
"minute",
|
|
513
|
+
"hour",
|
|
514
|
+
"day",
|
|
515
|
+
"week",
|
|
516
|
+
"month",
|
|
517
|
+
"year"
|
|
518
|
+
]);
|
|
519
|
+
var scheduleSchema = zod.z.discriminatedUnion("type", [
|
|
520
|
+
zod.z.object({ type: zod.z.literal("crontab"), value: zod.z.string() }),
|
|
521
|
+
zod.z.object({
|
|
522
|
+
type: zod.z.literal("interval"),
|
|
523
|
+
value: zod.z.number().int().min(1),
|
|
524
|
+
unit: intervalUnitSchema
|
|
525
|
+
})
|
|
526
|
+
]);
|
|
527
|
+
var previewScheduleSchema = zod.z.object({
|
|
528
|
+
schedule: scheduleSchema,
|
|
529
|
+
/** IANA zone the schedule is read in. Defaults to UTC. */
|
|
530
|
+
timezone: zod.z.string().optional()
|
|
531
|
+
});
|
|
532
|
+
var schedulePreviewSchema = zod.z.object({
|
|
533
|
+
next_runs: zod.z.array(dateTimeSchema)
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// src/schemas/monitor.ts
|
|
537
|
+
var monitorConfigSchema = zod.z.object({
|
|
538
|
+
schedule: scheduleSchema,
|
|
539
|
+
checkin_margin: zod.z.number().int(),
|
|
540
|
+
max_runtime: zod.z.number().int(),
|
|
541
|
+
timezone: zod.z.string(),
|
|
542
|
+
failure_issue_threshold: zod.z.number().int(),
|
|
543
|
+
recovery_threshold: zod.z.number().int()
|
|
544
|
+
});
|
|
545
|
+
var monitorConfigInputSchema = zod.z.object({
|
|
546
|
+
schedule: scheduleSchema.optional(),
|
|
547
|
+
checkin_margin: zod.z.number().int().min(1).optional(),
|
|
548
|
+
max_runtime: zod.z.number().int().min(1).optional(),
|
|
549
|
+
timezone: zod.z.string().optional(),
|
|
550
|
+
failure_issue_threshold: zod.z.number().int().min(1).max(720).optional(),
|
|
551
|
+
recovery_threshold: zod.z.number().int().min(1).max(720).optional()
|
|
552
|
+
});
|
|
553
|
+
var checkInStatusSchema = zod.z.enum([
|
|
554
|
+
"ok",
|
|
555
|
+
"error",
|
|
556
|
+
"in_progress",
|
|
557
|
+
"missed",
|
|
558
|
+
"timeout",
|
|
559
|
+
"unknown"
|
|
560
|
+
]);
|
|
561
|
+
var monitorEnvironmentStatusSchema = zod.z.enum(["active", "ok", "error"]);
|
|
562
|
+
var checkInSchema = zod.z.object({
|
|
563
|
+
id: uuidSchema,
|
|
564
|
+
environment: zod.z.string(),
|
|
565
|
+
status: checkInStatusSchema,
|
|
566
|
+
duration_ms: zod.z.number().int().nullable(),
|
|
567
|
+
date_added: dateTimeSchema,
|
|
568
|
+
date_updated: dateTimeSchema,
|
|
569
|
+
expected_time: dateTimeSchema.nullable()
|
|
570
|
+
});
|
|
571
|
+
var monitorEnvironmentSchema = zod.z.object({
|
|
572
|
+
id: uuidSchema,
|
|
573
|
+
environment: zod.z.string(),
|
|
574
|
+
status: monitorEnvironmentStatusSchema,
|
|
575
|
+
next_checkin: dateTimeSchema.nullable(),
|
|
576
|
+
next_checkin_latest: dateTimeSchema.nullable(),
|
|
577
|
+
last_checkin: dateTimeSchema.nullable(),
|
|
578
|
+
/** Newest first. */
|
|
579
|
+
recent_checkins: zod.z.array(checkInSchema)
|
|
580
|
+
});
|
|
581
|
+
var monitorSchema = zod.z.object({
|
|
582
|
+
id: uuidSchema,
|
|
583
|
+
slug: zod.z.string(),
|
|
584
|
+
name: zod.z.string(),
|
|
585
|
+
config: monitorConfigSchema,
|
|
586
|
+
is_muted: zod.z.boolean(),
|
|
587
|
+
created_at: dateTimeSchema,
|
|
588
|
+
environments: zod.z.array(monitorEnvironmentSchema)
|
|
589
|
+
});
|
|
590
|
+
var createMonitorSchema = zod.z.object({
|
|
591
|
+
name: zod.z.string().trim().min(1).max(128),
|
|
592
|
+
/** Derived from `name` when left out. */
|
|
593
|
+
slug: zod.z.string().min(1).max(50).optional(),
|
|
594
|
+
config: monitorConfigInputSchema
|
|
595
|
+
});
|
|
596
|
+
var updateMonitorSchema = zod.z.object({
|
|
597
|
+
name: zod.z.string().trim().min(1).max(128).optional(),
|
|
598
|
+
config: monitorConfigInputSchema.optional(),
|
|
599
|
+
is_muted: zod.z.boolean().optional()
|
|
600
|
+
});
|
|
417
601
|
var metricDeltaSchema = zod.z.object({
|
|
418
602
|
current: zod.z.number().int(),
|
|
419
603
|
/**
|
|
@@ -586,14 +770,21 @@ var projectStorageSchema = zod.z.object({
|
|
|
586
770
|
spans_count: zod.z.number(),
|
|
587
771
|
logs_count: zod.z.number(),
|
|
588
772
|
source_maps_count: zod.z.number(),
|
|
589
|
-
|
|
773
|
+
/** `events_bytes + transactions_bytes + logs_bytes`. */
|
|
774
|
+
estimated_bytes: zod.z.number(),
|
|
775
|
+
events_bytes: zod.z.number(),
|
|
776
|
+
/** Transactions with their spans. */
|
|
777
|
+
transactions_bytes: zod.z.number(),
|
|
778
|
+
logs_bytes: zod.z.number()
|
|
590
779
|
});
|
|
591
780
|
var cleanupCountsSchema = zod.z.object({
|
|
592
781
|
events: zod.z.number(),
|
|
593
782
|
transactions: zod.z.number(),
|
|
594
783
|
spans: zod.z.number(),
|
|
595
784
|
logs: zod.z.number(),
|
|
596
|
-
issues_removed: zod.z.number()
|
|
785
|
+
issues_removed: zod.z.number(),
|
|
786
|
+
/** Unused source maps deleted; only a retention cleanup removes them. */
|
|
787
|
+
source_maps: zod.z.number().default(0)
|
|
597
788
|
});
|
|
598
789
|
var cleanupStatusSchema = zod.z.object({
|
|
599
790
|
state: zod.z.enum(["idle", "running", "completed", "failed"]),
|
|
@@ -606,6 +797,53 @@ var sourceMapGcResultSchema = zod.z.object({
|
|
|
606
797
|
files_removed: zod.z.number(),
|
|
607
798
|
bytes_freed: zod.z.number()
|
|
608
799
|
});
|
|
800
|
+
var kindAgeSchema = zod.z.object({
|
|
801
|
+
counts: zod.z.array(zod.z.number()),
|
|
802
|
+
oldest: dateTimeSchema.nullable()
|
|
803
|
+
});
|
|
804
|
+
var storageAgeSchema = zod.z.object({
|
|
805
|
+
bucket_days: zod.z.array(zod.z.number()),
|
|
806
|
+
projects: zod.z.array(
|
|
807
|
+
zod.z.object({
|
|
808
|
+
project_id: zod.z.number(),
|
|
809
|
+
events: kindAgeSchema,
|
|
810
|
+
transactions: kindAgeSchema,
|
|
811
|
+
logs: kindAgeSchema
|
|
812
|
+
})
|
|
813
|
+
)
|
|
814
|
+
});
|
|
815
|
+
var retentionDaysSchema = zod.z.number().int().min(1).max(36500).nullable();
|
|
816
|
+
var retentionWindowsSchema = zod.z.object({
|
|
817
|
+
events_days: retentionDaysSchema,
|
|
818
|
+
/** Transactions with their spans. */
|
|
819
|
+
transactions_days: retentionDaysSchema,
|
|
820
|
+
logs_days: retentionDaysSchema
|
|
821
|
+
});
|
|
822
|
+
var projectRetentionSchema = retentionWindowsSchema.extend({
|
|
823
|
+
project_id: zod.z.number().int()
|
|
824
|
+
});
|
|
825
|
+
var retentionSettingsSchema = zod.z.object({
|
|
826
|
+
defaults: retentionWindowsSchema,
|
|
827
|
+
overrides: zod.z.array(projectRetentionSchema),
|
|
828
|
+
frequency: zod.z.enum(["daily", "weekly"]),
|
|
829
|
+
/** Hour of the day, UTC. */
|
|
830
|
+
hour: zod.z.number().int().min(0).max(23),
|
|
831
|
+
/** Day of a weekly cleanup, 0 = Sunday. */
|
|
832
|
+
weekday: zod.z.number().int().min(0).max(6)
|
|
833
|
+
});
|
|
834
|
+
var retentionRunSchema = zod.z.object({
|
|
835
|
+
started_at: dateTimeSchema,
|
|
836
|
+
finished_at: dateTimeSchema.nullable(),
|
|
837
|
+
status: zod.z.enum(["running", "ok", "error"]),
|
|
838
|
+
removed: cleanupCountsSchema.nullable(),
|
|
839
|
+
error: zod.z.string().nullable()
|
|
840
|
+
});
|
|
841
|
+
var retentionSchema = zod.z.object({
|
|
842
|
+
settings: retentionSettingsSchema,
|
|
843
|
+
/** Null while everything is kept forever, and for up to a minute after the settings change. */
|
|
844
|
+
next_run_at: dateTimeSchema.nullable(),
|
|
845
|
+
last_run: retentionRunSchema.nullable()
|
|
846
|
+
});
|
|
609
847
|
var cleanupOptionsSchema = zod.z.object({
|
|
610
848
|
older_than_days: zod.z.number().int().min(1),
|
|
611
849
|
project_id: zod.z.number().int().optional(),
|
|
@@ -1663,6 +1901,109 @@ var EventsResource = class extends BaseResource {
|
|
|
1663
1901
|
);
|
|
1664
1902
|
}
|
|
1665
1903
|
};
|
|
1904
|
+
|
|
1905
|
+
// src/resources/github.ts
|
|
1906
|
+
var GitHubResource = class extends BaseResource {
|
|
1907
|
+
/** The app, its installations and the webhook address (admin only). */
|
|
1908
|
+
async status() {
|
|
1909
|
+
return this.request(() => this.http.get("api/github"), gitHubStatusSchema);
|
|
1910
|
+
}
|
|
1911
|
+
/** The form to post to GitHub to create the app, under an org if given. */
|
|
1912
|
+
async manifest(organization) {
|
|
1913
|
+
return this.request(
|
|
1914
|
+
() => this.http.post("api/github/manifest", { json: { organization } }),
|
|
1915
|
+
gitHubManifestSchema
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
async disconnect() {
|
|
1919
|
+
return this.requestVoid(() => this.http.delete("api/github"));
|
|
1920
|
+
}
|
|
1921
|
+
/** Repositories the installations reach, for a project's settings. */
|
|
1922
|
+
async repositories(projectId) {
|
|
1923
|
+
return this.request(
|
|
1924
|
+
() => this.http.get("api/github/repositories", {
|
|
1925
|
+
searchParams: { project_id: projectId }
|
|
1926
|
+
}),
|
|
1927
|
+
gitHubRepositorySchema.array()
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1930
|
+
async projectRepository(projectId) {
|
|
1931
|
+
return this.request(
|
|
1932
|
+
() => this.http.get(`api/projects/${projectId}/github`),
|
|
1933
|
+
projectRepositorySchema.nullable()
|
|
1934
|
+
);
|
|
1935
|
+
}
|
|
1936
|
+
async setProjectRepository(projectId, input) {
|
|
1937
|
+
const validated = this.validateInput(input, updateProjectRepositorySchema);
|
|
1938
|
+
if (!validated.success) {
|
|
1939
|
+
return validated;
|
|
1940
|
+
}
|
|
1941
|
+
return this.request(
|
|
1942
|
+
() => this.http.put(`api/projects/${projectId}/github`, {
|
|
1943
|
+
json: validated.data
|
|
1944
|
+
}),
|
|
1945
|
+
projectRepositorySchema
|
|
1946
|
+
);
|
|
1947
|
+
}
|
|
1948
|
+
async removeProjectRepository(projectId) {
|
|
1949
|
+
return this.requestVoid(
|
|
1950
|
+
() => this.http.delete(`api/projects/${projectId}/github`)
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
/** Copies the repository's CODEOWNERS into Rustrak. */
|
|
1954
|
+
async syncCodeowners(projectId) {
|
|
1955
|
+
return this.request(
|
|
1956
|
+
() => this.http.post(`api/projects/${projectId}/github/codeowners`),
|
|
1957
|
+
projectRepositorySchema
|
|
1958
|
+
);
|
|
1959
|
+
}
|
|
1960
|
+
/** Links, suspect commits and owners for one issue. */
|
|
1961
|
+
async issue(projectId, issueId) {
|
|
1962
|
+
return this.request(
|
|
1963
|
+
() => this.http.get(`api/projects/${projectId}/issues/${issueId}/github`),
|
|
1964
|
+
issueGitHubSchema
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
async createIssue(projectId, issueId, input = {}) {
|
|
1968
|
+
return this.request(
|
|
1969
|
+
() => this.http.post(
|
|
1970
|
+
`api/projects/${projectId}/issues/${issueId}/github/issues`,
|
|
1971
|
+
{ json: input }
|
|
1972
|
+
),
|
|
1973
|
+
issueLinkSchema
|
|
1974
|
+
);
|
|
1975
|
+
}
|
|
1976
|
+
/** `reference` is a GitHub URL, `owner/repo#12` or `#12`. */
|
|
1977
|
+
async linkIssue(projectId, issueId, reference) {
|
|
1978
|
+
return this.request(
|
|
1979
|
+
() => this.http.post(
|
|
1980
|
+
`api/projects/${projectId}/issues/${issueId}/github/links`,
|
|
1981
|
+
{ json: { reference } }
|
|
1982
|
+
),
|
|
1983
|
+
issueLinkSchema
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
async unlinkIssue(projectId, issueId, linkId) {
|
|
1987
|
+
return this.requestVoid(
|
|
1988
|
+
() => this.http.delete(
|
|
1989
|
+
`api/projects/${projectId}/issues/${issueId}/github/links/${linkId}`
|
|
1990
|
+
)
|
|
1991
|
+
);
|
|
1992
|
+
}
|
|
1993
|
+
/** The signed-in person's GitHub username, used to sync assignees. */
|
|
1994
|
+
async myLogin() {
|
|
1995
|
+
return this.request(
|
|
1996
|
+
() => this.http.get("api/github/me"),
|
|
1997
|
+
gitHubLoginSchema
|
|
1998
|
+
);
|
|
1999
|
+
}
|
|
2000
|
+
async setMyLogin(login) {
|
|
2001
|
+
return this.request(
|
|
2002
|
+
() => this.http.put("api/github/me", { json: { login } }),
|
|
2003
|
+
gitHubLoginSchema
|
|
2004
|
+
);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
1666
2007
|
var serverVersionSchema = zod.z.object({
|
|
1667
2008
|
version: zod.z.string()
|
|
1668
2009
|
});
|
|
@@ -2009,6 +2350,77 @@ var MembersResource = class extends BaseResource {
|
|
|
2009
2350
|
);
|
|
2010
2351
|
}
|
|
2011
2352
|
};
|
|
2353
|
+
var MonitorsResource = class extends BaseResource {
|
|
2354
|
+
/** Every monitor of a project, with its environments and recent check-ins. */
|
|
2355
|
+
async list(projectId) {
|
|
2356
|
+
return this.request(
|
|
2357
|
+
() => this.http.get(`api/projects/${projectId}/monitors`),
|
|
2358
|
+
zod.z.array(monitorSchema)
|
|
2359
|
+
);
|
|
2360
|
+
}
|
|
2361
|
+
async get(projectId, slug) {
|
|
2362
|
+
return this.request(
|
|
2363
|
+
() => this.http.get(
|
|
2364
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
|
|
2365
|
+
),
|
|
2366
|
+
monitorSchema
|
|
2367
|
+
);
|
|
2368
|
+
}
|
|
2369
|
+
async create(projectId, input) {
|
|
2370
|
+
const validated = this.validateInput(input, createMonitorSchema);
|
|
2371
|
+
if (!validated.success) {
|
|
2372
|
+
return validated;
|
|
2373
|
+
}
|
|
2374
|
+
return this.request(
|
|
2375
|
+
() => this.http.post(`api/projects/${projectId}/monitors`, {
|
|
2376
|
+
json: validated.data
|
|
2377
|
+
}),
|
|
2378
|
+
monitorSchema
|
|
2379
|
+
);
|
|
2380
|
+
}
|
|
2381
|
+
/** Fields left out keep their value, including each field of `config`. */
|
|
2382
|
+
async update(projectId, slug, input) {
|
|
2383
|
+
const validated = this.validateInput(input, updateMonitorSchema);
|
|
2384
|
+
if (!validated.success) {
|
|
2385
|
+
return validated;
|
|
2386
|
+
}
|
|
2387
|
+
return this.request(
|
|
2388
|
+
() => this.http.put(
|
|
2389
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`,
|
|
2390
|
+
{ json: validated.data }
|
|
2391
|
+
),
|
|
2392
|
+
monitorSchema
|
|
2393
|
+
);
|
|
2394
|
+
}
|
|
2395
|
+
/** Deletes the monitor and its check-ins. Its issues stay. */
|
|
2396
|
+
async delete(projectId, slug) {
|
|
2397
|
+
return this.requestVoid(
|
|
2398
|
+
() => this.http.delete(
|
|
2399
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
|
|
2400
|
+
)
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
/** Check-ins of one monitor, newest first. */
|
|
2404
|
+
async listCheckIns(projectId, slug, options) {
|
|
2405
|
+
const searchParams = {};
|
|
2406
|
+
if (options?.page) {
|
|
2407
|
+
searchParams.page = String(options.page);
|
|
2408
|
+
}
|
|
2409
|
+
if (options?.per_page) {
|
|
2410
|
+
searchParams.per_page = String(options.per_page);
|
|
2411
|
+
}
|
|
2412
|
+
if (options?.environment) {
|
|
2413
|
+
searchParams.environment = options.environment;
|
|
2414
|
+
}
|
|
2415
|
+
return this.request(
|
|
2416
|
+
() => this.http.get(
|
|
2417
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}/checkins`,
|
|
2418
|
+
{ searchParams }
|
|
2419
|
+
),
|
|
2420
|
+
offsetPaginatedResponseSchema(checkInSchema)
|
|
2421
|
+
);
|
|
2422
|
+
}
|
|
2423
|
+
};
|
|
2012
2424
|
|
|
2013
2425
|
// src/resources/projects.ts
|
|
2014
2426
|
var ProjectsResource = class extends BaseResource {
|
|
@@ -2110,6 +2522,21 @@ var ReleasesResource = class extends BaseResource {
|
|
|
2110
2522
|
}
|
|
2111
2523
|
};
|
|
2112
2524
|
|
|
2525
|
+
// src/resources/schedules.ts
|
|
2526
|
+
var SchedulesResource = class extends BaseResource {
|
|
2527
|
+
/** Validates a schedule and lists its next five runs. */
|
|
2528
|
+
async preview(input) {
|
|
2529
|
+
const validated = this.validateInput(input, previewScheduleSchema);
|
|
2530
|
+
if (!validated.success) {
|
|
2531
|
+
return validated;
|
|
2532
|
+
}
|
|
2533
|
+
return this.request(
|
|
2534
|
+
() => this.http.post("api/schedules/preview", { json: validated.data }),
|
|
2535
|
+
schedulePreviewSchema
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2113
2540
|
// src/resources/sessions.ts
|
|
2114
2541
|
var SessionsResource = class extends BaseResource {
|
|
2115
2542
|
/**
|
|
@@ -2442,6 +2869,66 @@ var StorageResource = class extends BaseResource {
|
|
|
2442
2869
|
sourceMapGcResultSchema
|
|
2443
2870
|
);
|
|
2444
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Retention: how long each kind of data is kept, by default and per
|
|
2874
|
+
* project, when its cleanup runs next and how the last one went.
|
|
2875
|
+
*/
|
|
2876
|
+
async getRetention() {
|
|
2877
|
+
return this.request(
|
|
2878
|
+
() => this.http.get("api/storage/retention"),
|
|
2879
|
+
retentionSchema
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2882
|
+
/** Replaces the retention settings. A new schedule applies within a minute. */
|
|
2883
|
+
async updateRetention(settings) {
|
|
2884
|
+
const validated = this.validateInput(settings, retentionSettingsSchema);
|
|
2885
|
+
if (!validated.success) {
|
|
2886
|
+
return validated;
|
|
2887
|
+
}
|
|
2888
|
+
return this.request(
|
|
2889
|
+
() => this.http.put("api/storage/retention", { json: validated.data }),
|
|
2890
|
+
retentionSchema
|
|
2891
|
+
);
|
|
2892
|
+
}
|
|
2893
|
+
/**
|
|
2894
|
+
* Enforces the saved retention now, without waiting for the schedule, and
|
|
2895
|
+
* deletes unused source maps. Returns the started job; follow it with
|
|
2896
|
+
* {@link getCleanupStatus}. A `validation` error while everything is kept
|
|
2897
|
+
* forever, `conflict` while a cleanup runs.
|
|
2898
|
+
*/
|
|
2899
|
+
async runRetention() {
|
|
2900
|
+
return this.request(
|
|
2901
|
+
() => this.http.post("api/storage/retention/run", {
|
|
2902
|
+
// No retry, as for `executeCleanup`: a lost response after the
|
|
2903
|
+
// cleanup started would be retried into a refused second run.
|
|
2904
|
+
retry: 0
|
|
2905
|
+
}),
|
|
2906
|
+
cleanupStatusSchema
|
|
2907
|
+
);
|
|
2908
|
+
}
|
|
2909
|
+
/** How long ago each project's data arrived, per kind, in age buckets. */
|
|
2910
|
+
async getAge() {
|
|
2911
|
+
return this.request(
|
|
2912
|
+
() => this.http.get("api/storage/age"),
|
|
2913
|
+
storageAgeSchema
|
|
2914
|
+
);
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* Dry-run: what enforcing these retention settings now would delete, each
|
|
2918
|
+
* project against its own windows. Saves and deletes nothing.
|
|
2919
|
+
*/
|
|
2920
|
+
async previewRetention(settings) {
|
|
2921
|
+
const validated = this.validateInput(settings, retentionSettingsSchema);
|
|
2922
|
+
if (!validated.success) {
|
|
2923
|
+
return validated;
|
|
2924
|
+
}
|
|
2925
|
+
return this.request(
|
|
2926
|
+
() => this.http.post("api/storage/retention/preview", {
|
|
2927
|
+
json: validated.data
|
|
2928
|
+
}),
|
|
2929
|
+
cleanupCountsSchema
|
|
2930
|
+
);
|
|
2931
|
+
}
|
|
2445
2932
|
};
|
|
2446
2933
|
|
|
2447
2934
|
// src/resources/team.ts
|
|
@@ -2681,6 +3168,14 @@ var RustrakClient = class {
|
|
|
2681
3168
|
* Logs API resource (standalone logs)
|
|
2682
3169
|
*/
|
|
2683
3170
|
logs;
|
|
3171
|
+
/**
|
|
3172
|
+
* Cron monitors API resource (Sentry Crons)
|
|
3173
|
+
*/
|
|
3174
|
+
monitors;
|
|
3175
|
+
/**
|
|
3176
|
+
* Schedules API resource (previews for crontab/interval schedules)
|
|
3177
|
+
*/
|
|
3178
|
+
schedules;
|
|
2684
3179
|
/**
|
|
2685
3180
|
* Spans API resource (standalone + transaction-embedded spans, shared table)
|
|
2686
3181
|
*/
|
|
@@ -2701,6 +3196,10 @@ var RustrakClient = class {
|
|
|
2701
3196
|
* Health API resource (version info)
|
|
2702
3197
|
*/
|
|
2703
3198
|
health;
|
|
3199
|
+
/**
|
|
3200
|
+
* GitHub integration resource
|
|
3201
|
+
*/
|
|
3202
|
+
github;
|
|
2704
3203
|
/**
|
|
2705
3204
|
* Create a new Rustrak API client
|
|
2706
3205
|
*
|
|
@@ -2713,6 +3212,7 @@ var RustrakClient = class {
|
|
|
2713
3212
|
this.issues = new IssuesResource(this.http);
|
|
2714
3213
|
this.events = new EventsResource(this.http);
|
|
2715
3214
|
this.tokens = new TokensResource(this.http);
|
|
3215
|
+
this.github = new GitHubResource(this.http);
|
|
2716
3216
|
this.alertIntegrations = new AlertIntegrationsResource(this.http);
|
|
2717
3217
|
this.alertRules = new AlertRulesResource(this.http);
|
|
2718
3218
|
this.sourceMaps = new SourceMapsResource(this.http);
|
|
@@ -2723,6 +3223,8 @@ var RustrakClient = class {
|
|
|
2723
3223
|
this.releases = new ReleasesResource(this.http);
|
|
2724
3224
|
this.transactions = new TransactionsResource(this.http);
|
|
2725
3225
|
this.logs = new LogsResource(this.http);
|
|
3226
|
+
this.monitors = new MonitorsResource(this.http);
|
|
3227
|
+
this.schedules = new SchedulesResource(this.http);
|
|
2726
3228
|
this.spans = new SpansResource(this.http);
|
|
2727
3229
|
this.agents = new AgentsResource(this.http);
|
|
2728
3230
|
this.stats = new StatsResource(this.http);
|