@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/dist/index.js
CHANGED
|
@@ -128,13 +128,24 @@ var alertRuleChannelInputSchema = z.object({
|
|
|
128
128
|
integration_id: z.number().int(),
|
|
129
129
|
routing_override: z.record(z.string(), z.unknown()).default({})
|
|
130
130
|
});
|
|
131
|
+
var alertRuleConditionsSchema = z.object({
|
|
132
|
+
/** The quietest level that still fires. The server takes `null` as absent. */
|
|
133
|
+
min_level: z.enum(["debug", "info", "warning", "error", "fatal"]).nullish(),
|
|
134
|
+
/** When non-empty, the only environments that fire. */
|
|
135
|
+
environments: z.array(z.string()).optional(),
|
|
136
|
+
/** A new issue fires when it reaches this many events, not on its first. */
|
|
137
|
+
min_events: z.number().int().min(1).nullish()
|
|
138
|
+
});
|
|
131
139
|
var alertRuleSchema = z.object({
|
|
132
140
|
id: z.number().int(),
|
|
133
141
|
project_id: z.number().int(),
|
|
134
142
|
name: z.string(),
|
|
135
143
|
alert_type: alertTypeSchema,
|
|
136
144
|
is_enabled: z.boolean(),
|
|
137
|
-
|
|
145
|
+
// A rule stored before the filters existed may hold any object. The server
|
|
146
|
+
// evaluates one it cannot read as no filters; one bad row must not fail the
|
|
147
|
+
// whole list either.
|
|
148
|
+
conditions: alertRuleConditionsSchema.catch({}),
|
|
138
149
|
cooldown_minutes: z.number().int(),
|
|
139
150
|
last_triggered_at: dateTimeSchema.nullable(),
|
|
140
151
|
created_at: dateTimeSchema,
|
|
@@ -147,13 +158,13 @@ var createAlertRuleSchema = z.object({
|
|
|
147
158
|
alert_type: alertTypeSchema,
|
|
148
159
|
channels: z.array(alertRuleChannelInputSchema).default([]),
|
|
149
160
|
is_enabled: z.boolean().optional(),
|
|
150
|
-
conditions:
|
|
161
|
+
conditions: alertRuleConditionsSchema.optional(),
|
|
151
162
|
cooldown_minutes: z.number().int().min(0).optional()
|
|
152
163
|
});
|
|
153
164
|
var updateAlertRuleSchema = z.object({
|
|
154
165
|
name: z.string().min(1).optional(),
|
|
155
166
|
is_enabled: z.boolean().optional(),
|
|
156
|
-
conditions:
|
|
167
|
+
conditions: alertRuleConditionsSchema.optional(),
|
|
157
168
|
cooldown_minutes: z.number().int().min(0).optional(),
|
|
158
169
|
channels: z.array(alertRuleChannelInputSchema).optional()
|
|
159
170
|
});
|
|
@@ -225,6 +236,89 @@ var eventDetailSchema = z.object({
|
|
|
225
236
|
data: z.record(z.string(), z.any())
|
|
226
237
|
// Full Sentry event JSON
|
|
227
238
|
});
|
|
239
|
+
var gitHubAppSchema = z.object({
|
|
240
|
+
app_id: z.number().int(),
|
|
241
|
+
slug: z.string(),
|
|
242
|
+
html_url: z.string(),
|
|
243
|
+
owner_login: z.string(),
|
|
244
|
+
install_url: z.string(),
|
|
245
|
+
last_webhook_at: dateTimeSchema.nullable(),
|
|
246
|
+
created_at: dateTimeSchema
|
|
247
|
+
});
|
|
248
|
+
var gitHubInstallationSchema = z.object({
|
|
249
|
+
id: z.number().int(),
|
|
250
|
+
account_login: z.string(),
|
|
251
|
+
account_type: z.string(),
|
|
252
|
+
suspended: z.boolean(),
|
|
253
|
+
created_at: dateTimeSchema
|
|
254
|
+
});
|
|
255
|
+
var gitHubStatusSchema = z.object({
|
|
256
|
+
app: gitHubAppSchema.nullable(),
|
|
257
|
+
installations: z.array(gitHubInstallationSchema),
|
|
258
|
+
webhook_url: z.string()
|
|
259
|
+
});
|
|
260
|
+
var gitHubManifestSchema = z.object({
|
|
261
|
+
action_url: z.string(),
|
|
262
|
+
manifest: z.string()
|
|
263
|
+
});
|
|
264
|
+
var gitHubRepositorySchema = z.object({
|
|
265
|
+
installation_id: z.number().int(),
|
|
266
|
+
full_name: z.string(),
|
|
267
|
+
default_branch: z.string(),
|
|
268
|
+
private: z.boolean(),
|
|
269
|
+
html_url: z.string()
|
|
270
|
+
});
|
|
271
|
+
var codeMappingSchema = z.object({
|
|
272
|
+
stack_root: z.string(),
|
|
273
|
+
source_root: z.string()
|
|
274
|
+
});
|
|
275
|
+
var projectRepositorySchema = z.object({
|
|
276
|
+
project_id: z.number().int(),
|
|
277
|
+
installation_id: z.number().int(),
|
|
278
|
+
repo_full_name: z.string(),
|
|
279
|
+
default_branch: z.string(),
|
|
280
|
+
html_url: z.string(),
|
|
281
|
+
code_mappings: z.array(codeMappingSchema),
|
|
282
|
+
/** Open a GitHub issue for new issues that pass `auto_create_conditions`. */
|
|
283
|
+
auto_create_issues: z.boolean(),
|
|
284
|
+
auto_create_conditions: alertRuleConditionsSchema,
|
|
285
|
+
codeowners_rules: z.number().int().nullable(),
|
|
286
|
+
codeowners_synced_at: dateTimeSchema.nullable()
|
|
287
|
+
});
|
|
288
|
+
var updateProjectRepositorySchema = z.object({
|
|
289
|
+
installation_id: z.number().int(),
|
|
290
|
+
repo_full_name: z.string().min(1),
|
|
291
|
+
code_mappings: z.array(codeMappingSchema).optional(),
|
|
292
|
+
auto_create_issues: z.boolean().optional(),
|
|
293
|
+
auto_create_conditions: alertRuleConditionsSchema.optional()
|
|
294
|
+
});
|
|
295
|
+
var issueLinkSchema = z.object({
|
|
296
|
+
id: z.number().int(),
|
|
297
|
+
issue_id: z.string(),
|
|
298
|
+
repo_full_name: z.string(),
|
|
299
|
+
number: z.number().int(),
|
|
300
|
+
title: z.string(),
|
|
301
|
+
url: z.string(),
|
|
302
|
+
state: z.string(),
|
|
303
|
+
created_at: dateTimeSchema
|
|
304
|
+
});
|
|
305
|
+
var repoCommitSchema = z.object({
|
|
306
|
+
repo_full_name: z.string(),
|
|
307
|
+
sha: z.string(),
|
|
308
|
+
message: z.string(),
|
|
309
|
+
author_name: z.string(),
|
|
310
|
+
author_login: z.string().nullable(),
|
|
311
|
+
url: z.string(),
|
|
312
|
+
committed_at: dateTimeSchema
|
|
313
|
+
});
|
|
314
|
+
var issueGitHubSchema = z.object({
|
|
315
|
+
links: z.array(issueLinkSchema),
|
|
316
|
+
suspect_commits: z.array(repoCommitSchema),
|
|
317
|
+
owners: z.array(z.string())
|
|
318
|
+
});
|
|
319
|
+
var gitHubLoginSchema = z.object({
|
|
320
|
+
login: z.string().nullable()
|
|
321
|
+
});
|
|
228
322
|
var globalRoleSchema = z.enum(["admin", "member"]);
|
|
229
323
|
var teamMemberSchema = z.object({
|
|
230
324
|
id: z.number().int(),
|
|
@@ -408,6 +502,96 @@ var upsertProjectMemberSchema = z.object({
|
|
|
408
502
|
user_id: z.number().int(),
|
|
409
503
|
role: projectRoleSchema
|
|
410
504
|
});
|
|
505
|
+
var intervalUnitSchema = z.enum([
|
|
506
|
+
"minute",
|
|
507
|
+
"hour",
|
|
508
|
+
"day",
|
|
509
|
+
"week",
|
|
510
|
+
"month",
|
|
511
|
+
"year"
|
|
512
|
+
]);
|
|
513
|
+
var scheduleSchema = z.discriminatedUnion("type", [
|
|
514
|
+
z.object({ type: z.literal("crontab"), value: z.string() }),
|
|
515
|
+
z.object({
|
|
516
|
+
type: z.literal("interval"),
|
|
517
|
+
value: z.number().int().min(1),
|
|
518
|
+
unit: intervalUnitSchema
|
|
519
|
+
})
|
|
520
|
+
]);
|
|
521
|
+
var previewScheduleSchema = z.object({
|
|
522
|
+
schedule: scheduleSchema,
|
|
523
|
+
/** IANA zone the schedule is read in. Defaults to UTC. */
|
|
524
|
+
timezone: z.string().optional()
|
|
525
|
+
});
|
|
526
|
+
var schedulePreviewSchema = z.object({
|
|
527
|
+
next_runs: z.array(dateTimeSchema)
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// src/schemas/monitor.ts
|
|
531
|
+
var monitorConfigSchema = z.object({
|
|
532
|
+
schedule: scheduleSchema,
|
|
533
|
+
checkin_margin: z.number().int(),
|
|
534
|
+
max_runtime: z.number().int(),
|
|
535
|
+
timezone: z.string(),
|
|
536
|
+
failure_issue_threshold: z.number().int(),
|
|
537
|
+
recovery_threshold: z.number().int()
|
|
538
|
+
});
|
|
539
|
+
var monitorConfigInputSchema = z.object({
|
|
540
|
+
schedule: scheduleSchema.optional(),
|
|
541
|
+
checkin_margin: z.number().int().min(1).optional(),
|
|
542
|
+
max_runtime: z.number().int().min(1).optional(),
|
|
543
|
+
timezone: z.string().optional(),
|
|
544
|
+
failure_issue_threshold: z.number().int().min(1).max(720).optional(),
|
|
545
|
+
recovery_threshold: z.number().int().min(1).max(720).optional()
|
|
546
|
+
});
|
|
547
|
+
var checkInStatusSchema = z.enum([
|
|
548
|
+
"ok",
|
|
549
|
+
"error",
|
|
550
|
+
"in_progress",
|
|
551
|
+
"missed",
|
|
552
|
+
"timeout",
|
|
553
|
+
"unknown"
|
|
554
|
+
]);
|
|
555
|
+
var monitorEnvironmentStatusSchema = z.enum(["active", "ok", "error"]);
|
|
556
|
+
var checkInSchema = z.object({
|
|
557
|
+
id: uuidSchema,
|
|
558
|
+
environment: z.string(),
|
|
559
|
+
status: checkInStatusSchema,
|
|
560
|
+
duration_ms: z.number().int().nullable(),
|
|
561
|
+
date_added: dateTimeSchema,
|
|
562
|
+
date_updated: dateTimeSchema,
|
|
563
|
+
expected_time: dateTimeSchema.nullable()
|
|
564
|
+
});
|
|
565
|
+
var monitorEnvironmentSchema = z.object({
|
|
566
|
+
id: uuidSchema,
|
|
567
|
+
environment: z.string(),
|
|
568
|
+
status: monitorEnvironmentStatusSchema,
|
|
569
|
+
next_checkin: dateTimeSchema.nullable(),
|
|
570
|
+
next_checkin_latest: dateTimeSchema.nullable(),
|
|
571
|
+
last_checkin: dateTimeSchema.nullable(),
|
|
572
|
+
/** Newest first. */
|
|
573
|
+
recent_checkins: z.array(checkInSchema)
|
|
574
|
+
});
|
|
575
|
+
var monitorSchema = z.object({
|
|
576
|
+
id: uuidSchema,
|
|
577
|
+
slug: z.string(),
|
|
578
|
+
name: z.string(),
|
|
579
|
+
config: monitorConfigSchema,
|
|
580
|
+
is_muted: z.boolean(),
|
|
581
|
+
created_at: dateTimeSchema,
|
|
582
|
+
environments: z.array(monitorEnvironmentSchema)
|
|
583
|
+
});
|
|
584
|
+
var createMonitorSchema = z.object({
|
|
585
|
+
name: z.string().trim().min(1).max(128),
|
|
586
|
+
/** Derived from `name` when left out. */
|
|
587
|
+
slug: z.string().min(1).max(50).optional(),
|
|
588
|
+
config: monitorConfigInputSchema
|
|
589
|
+
});
|
|
590
|
+
var updateMonitorSchema = z.object({
|
|
591
|
+
name: z.string().trim().min(1).max(128).optional(),
|
|
592
|
+
config: monitorConfigInputSchema.optional(),
|
|
593
|
+
is_muted: z.boolean().optional()
|
|
594
|
+
});
|
|
411
595
|
var metricDeltaSchema = z.object({
|
|
412
596
|
current: z.number().int(),
|
|
413
597
|
/**
|
|
@@ -580,14 +764,21 @@ var projectStorageSchema = z.object({
|
|
|
580
764
|
spans_count: z.number(),
|
|
581
765
|
logs_count: z.number(),
|
|
582
766
|
source_maps_count: z.number(),
|
|
583
|
-
|
|
767
|
+
/** `events_bytes + transactions_bytes + logs_bytes`. */
|
|
768
|
+
estimated_bytes: z.number(),
|
|
769
|
+
events_bytes: z.number(),
|
|
770
|
+
/** Transactions with their spans. */
|
|
771
|
+
transactions_bytes: z.number(),
|
|
772
|
+
logs_bytes: z.number()
|
|
584
773
|
});
|
|
585
774
|
var cleanupCountsSchema = z.object({
|
|
586
775
|
events: z.number(),
|
|
587
776
|
transactions: z.number(),
|
|
588
777
|
spans: z.number(),
|
|
589
778
|
logs: z.number(),
|
|
590
|
-
issues_removed: z.number()
|
|
779
|
+
issues_removed: z.number(),
|
|
780
|
+
/** Unused source maps deleted; only a retention cleanup removes them. */
|
|
781
|
+
source_maps: z.number().default(0)
|
|
591
782
|
});
|
|
592
783
|
var cleanupStatusSchema = z.object({
|
|
593
784
|
state: z.enum(["idle", "running", "completed", "failed"]),
|
|
@@ -600,6 +791,53 @@ var sourceMapGcResultSchema = z.object({
|
|
|
600
791
|
files_removed: z.number(),
|
|
601
792
|
bytes_freed: z.number()
|
|
602
793
|
});
|
|
794
|
+
var kindAgeSchema = z.object({
|
|
795
|
+
counts: z.array(z.number()),
|
|
796
|
+
oldest: dateTimeSchema.nullable()
|
|
797
|
+
});
|
|
798
|
+
var storageAgeSchema = z.object({
|
|
799
|
+
bucket_days: z.array(z.number()),
|
|
800
|
+
projects: z.array(
|
|
801
|
+
z.object({
|
|
802
|
+
project_id: z.number(),
|
|
803
|
+
events: kindAgeSchema,
|
|
804
|
+
transactions: kindAgeSchema,
|
|
805
|
+
logs: kindAgeSchema
|
|
806
|
+
})
|
|
807
|
+
)
|
|
808
|
+
});
|
|
809
|
+
var retentionDaysSchema = z.number().int().min(1).max(36500).nullable();
|
|
810
|
+
var retentionWindowsSchema = z.object({
|
|
811
|
+
events_days: retentionDaysSchema,
|
|
812
|
+
/** Transactions with their spans. */
|
|
813
|
+
transactions_days: retentionDaysSchema,
|
|
814
|
+
logs_days: retentionDaysSchema
|
|
815
|
+
});
|
|
816
|
+
var projectRetentionSchema = retentionWindowsSchema.extend({
|
|
817
|
+
project_id: z.number().int()
|
|
818
|
+
});
|
|
819
|
+
var retentionSettingsSchema = z.object({
|
|
820
|
+
defaults: retentionWindowsSchema,
|
|
821
|
+
overrides: z.array(projectRetentionSchema),
|
|
822
|
+
frequency: z.enum(["daily", "weekly"]),
|
|
823
|
+
/** Hour of the day, UTC. */
|
|
824
|
+
hour: z.number().int().min(0).max(23),
|
|
825
|
+
/** Day of a weekly cleanup, 0 = Sunday. */
|
|
826
|
+
weekday: z.number().int().min(0).max(6)
|
|
827
|
+
});
|
|
828
|
+
var retentionRunSchema = z.object({
|
|
829
|
+
started_at: dateTimeSchema,
|
|
830
|
+
finished_at: dateTimeSchema.nullable(),
|
|
831
|
+
status: z.enum(["running", "ok", "error"]),
|
|
832
|
+
removed: cleanupCountsSchema.nullable(),
|
|
833
|
+
error: z.string().nullable()
|
|
834
|
+
});
|
|
835
|
+
var retentionSchema = z.object({
|
|
836
|
+
settings: retentionSettingsSchema,
|
|
837
|
+
/** Null while everything is kept forever, and for up to a minute after the settings change. */
|
|
838
|
+
next_run_at: dateTimeSchema.nullable(),
|
|
839
|
+
last_run: retentionRunSchema.nullable()
|
|
840
|
+
});
|
|
603
841
|
var cleanupOptionsSchema = z.object({
|
|
604
842
|
older_than_days: z.number().int().min(1),
|
|
605
843
|
project_id: z.number().int().optional(),
|
|
@@ -1657,6 +1895,109 @@ var EventsResource = class extends BaseResource {
|
|
|
1657
1895
|
);
|
|
1658
1896
|
}
|
|
1659
1897
|
};
|
|
1898
|
+
|
|
1899
|
+
// src/resources/github.ts
|
|
1900
|
+
var GitHubResource = class extends BaseResource {
|
|
1901
|
+
/** The app, its installations and the webhook address (admin only). */
|
|
1902
|
+
async status() {
|
|
1903
|
+
return this.request(() => this.http.get("api/github"), gitHubStatusSchema);
|
|
1904
|
+
}
|
|
1905
|
+
/** The form to post to GitHub to create the app, under an org if given. */
|
|
1906
|
+
async manifest(organization) {
|
|
1907
|
+
return this.request(
|
|
1908
|
+
() => this.http.post("api/github/manifest", { json: { organization } }),
|
|
1909
|
+
gitHubManifestSchema
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1912
|
+
async disconnect() {
|
|
1913
|
+
return this.requestVoid(() => this.http.delete("api/github"));
|
|
1914
|
+
}
|
|
1915
|
+
/** Repositories the installations reach, for a project's settings. */
|
|
1916
|
+
async repositories(projectId) {
|
|
1917
|
+
return this.request(
|
|
1918
|
+
() => this.http.get("api/github/repositories", {
|
|
1919
|
+
searchParams: { project_id: projectId }
|
|
1920
|
+
}),
|
|
1921
|
+
gitHubRepositorySchema.array()
|
|
1922
|
+
);
|
|
1923
|
+
}
|
|
1924
|
+
async projectRepository(projectId) {
|
|
1925
|
+
return this.request(
|
|
1926
|
+
() => this.http.get(`api/projects/${projectId}/github`),
|
|
1927
|
+
projectRepositorySchema.nullable()
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1930
|
+
async setProjectRepository(projectId, input) {
|
|
1931
|
+
const validated = this.validateInput(input, updateProjectRepositorySchema);
|
|
1932
|
+
if (!validated.success) {
|
|
1933
|
+
return validated;
|
|
1934
|
+
}
|
|
1935
|
+
return this.request(
|
|
1936
|
+
() => this.http.put(`api/projects/${projectId}/github`, {
|
|
1937
|
+
json: validated.data
|
|
1938
|
+
}),
|
|
1939
|
+
projectRepositorySchema
|
|
1940
|
+
);
|
|
1941
|
+
}
|
|
1942
|
+
async removeProjectRepository(projectId) {
|
|
1943
|
+
return this.requestVoid(
|
|
1944
|
+
() => this.http.delete(`api/projects/${projectId}/github`)
|
|
1945
|
+
);
|
|
1946
|
+
}
|
|
1947
|
+
/** Copies the repository's CODEOWNERS into Rustrak. */
|
|
1948
|
+
async syncCodeowners(projectId) {
|
|
1949
|
+
return this.request(
|
|
1950
|
+
() => this.http.post(`api/projects/${projectId}/github/codeowners`),
|
|
1951
|
+
projectRepositorySchema
|
|
1952
|
+
);
|
|
1953
|
+
}
|
|
1954
|
+
/** Links, suspect commits and owners for one issue. */
|
|
1955
|
+
async issue(projectId, issueId) {
|
|
1956
|
+
return this.request(
|
|
1957
|
+
() => this.http.get(`api/projects/${projectId}/issues/${issueId}/github`),
|
|
1958
|
+
issueGitHubSchema
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
async createIssue(projectId, issueId, input = {}) {
|
|
1962
|
+
return this.request(
|
|
1963
|
+
() => this.http.post(
|
|
1964
|
+
`api/projects/${projectId}/issues/${issueId}/github/issues`,
|
|
1965
|
+
{ json: input }
|
|
1966
|
+
),
|
|
1967
|
+
issueLinkSchema
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
/** `reference` is a GitHub URL, `owner/repo#12` or `#12`. */
|
|
1971
|
+
async linkIssue(projectId, issueId, reference) {
|
|
1972
|
+
return this.request(
|
|
1973
|
+
() => this.http.post(
|
|
1974
|
+
`api/projects/${projectId}/issues/${issueId}/github/links`,
|
|
1975
|
+
{ json: { reference } }
|
|
1976
|
+
),
|
|
1977
|
+
issueLinkSchema
|
|
1978
|
+
);
|
|
1979
|
+
}
|
|
1980
|
+
async unlinkIssue(projectId, issueId, linkId) {
|
|
1981
|
+
return this.requestVoid(
|
|
1982
|
+
() => this.http.delete(
|
|
1983
|
+
`api/projects/${projectId}/issues/${issueId}/github/links/${linkId}`
|
|
1984
|
+
)
|
|
1985
|
+
);
|
|
1986
|
+
}
|
|
1987
|
+
/** The signed-in person's GitHub username, used to sync assignees. */
|
|
1988
|
+
async myLogin() {
|
|
1989
|
+
return this.request(
|
|
1990
|
+
() => this.http.get("api/github/me"),
|
|
1991
|
+
gitHubLoginSchema
|
|
1992
|
+
);
|
|
1993
|
+
}
|
|
1994
|
+
async setMyLogin(login) {
|
|
1995
|
+
return this.request(
|
|
1996
|
+
() => this.http.put("api/github/me", { json: { login } }),
|
|
1997
|
+
gitHubLoginSchema
|
|
1998
|
+
);
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
1660
2001
|
var serverVersionSchema = z.object({
|
|
1661
2002
|
version: z.string()
|
|
1662
2003
|
});
|
|
@@ -2003,6 +2344,77 @@ var MembersResource = class extends BaseResource {
|
|
|
2003
2344
|
);
|
|
2004
2345
|
}
|
|
2005
2346
|
};
|
|
2347
|
+
var MonitorsResource = class extends BaseResource {
|
|
2348
|
+
/** Every monitor of a project, with its environments and recent check-ins. */
|
|
2349
|
+
async list(projectId) {
|
|
2350
|
+
return this.request(
|
|
2351
|
+
() => this.http.get(`api/projects/${projectId}/monitors`),
|
|
2352
|
+
z.array(monitorSchema)
|
|
2353
|
+
);
|
|
2354
|
+
}
|
|
2355
|
+
async get(projectId, slug) {
|
|
2356
|
+
return this.request(
|
|
2357
|
+
() => this.http.get(
|
|
2358
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
|
|
2359
|
+
),
|
|
2360
|
+
monitorSchema
|
|
2361
|
+
);
|
|
2362
|
+
}
|
|
2363
|
+
async create(projectId, input) {
|
|
2364
|
+
const validated = this.validateInput(input, createMonitorSchema);
|
|
2365
|
+
if (!validated.success) {
|
|
2366
|
+
return validated;
|
|
2367
|
+
}
|
|
2368
|
+
return this.request(
|
|
2369
|
+
() => this.http.post(`api/projects/${projectId}/monitors`, {
|
|
2370
|
+
json: validated.data
|
|
2371
|
+
}),
|
|
2372
|
+
monitorSchema
|
|
2373
|
+
);
|
|
2374
|
+
}
|
|
2375
|
+
/** Fields left out keep their value, including each field of `config`. */
|
|
2376
|
+
async update(projectId, slug, input) {
|
|
2377
|
+
const validated = this.validateInput(input, updateMonitorSchema);
|
|
2378
|
+
if (!validated.success) {
|
|
2379
|
+
return validated;
|
|
2380
|
+
}
|
|
2381
|
+
return this.request(
|
|
2382
|
+
() => this.http.put(
|
|
2383
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`,
|
|
2384
|
+
{ json: validated.data }
|
|
2385
|
+
),
|
|
2386
|
+
monitorSchema
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2389
|
+
/** Deletes the monitor and its check-ins. Its issues stay. */
|
|
2390
|
+
async delete(projectId, slug) {
|
|
2391
|
+
return this.requestVoid(
|
|
2392
|
+
() => this.http.delete(
|
|
2393
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
|
|
2394
|
+
)
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
/** Check-ins of one monitor, newest first. */
|
|
2398
|
+
async listCheckIns(projectId, slug, options) {
|
|
2399
|
+
const searchParams = {};
|
|
2400
|
+
if (options?.page) {
|
|
2401
|
+
searchParams.page = String(options.page);
|
|
2402
|
+
}
|
|
2403
|
+
if (options?.per_page) {
|
|
2404
|
+
searchParams.per_page = String(options.per_page);
|
|
2405
|
+
}
|
|
2406
|
+
if (options?.environment) {
|
|
2407
|
+
searchParams.environment = options.environment;
|
|
2408
|
+
}
|
|
2409
|
+
return this.request(
|
|
2410
|
+
() => this.http.get(
|
|
2411
|
+
`api/projects/${projectId}/monitors/${encodeURIComponent(slug)}/checkins`,
|
|
2412
|
+
{ searchParams }
|
|
2413
|
+
),
|
|
2414
|
+
offsetPaginatedResponseSchema(checkInSchema)
|
|
2415
|
+
);
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2006
2418
|
|
|
2007
2419
|
// src/resources/projects.ts
|
|
2008
2420
|
var ProjectsResource = class extends BaseResource {
|
|
@@ -2104,6 +2516,21 @@ var ReleasesResource = class extends BaseResource {
|
|
|
2104
2516
|
}
|
|
2105
2517
|
};
|
|
2106
2518
|
|
|
2519
|
+
// src/resources/schedules.ts
|
|
2520
|
+
var SchedulesResource = class extends BaseResource {
|
|
2521
|
+
/** Validates a schedule and lists its next five runs. */
|
|
2522
|
+
async preview(input) {
|
|
2523
|
+
const validated = this.validateInput(input, previewScheduleSchema);
|
|
2524
|
+
if (!validated.success) {
|
|
2525
|
+
return validated;
|
|
2526
|
+
}
|
|
2527
|
+
return this.request(
|
|
2528
|
+
() => this.http.post("api/schedules/preview", { json: validated.data }),
|
|
2529
|
+
schedulePreviewSchema
|
|
2530
|
+
);
|
|
2531
|
+
}
|
|
2532
|
+
};
|
|
2533
|
+
|
|
2107
2534
|
// src/resources/sessions.ts
|
|
2108
2535
|
var SessionsResource = class extends BaseResource {
|
|
2109
2536
|
/**
|
|
@@ -2436,6 +2863,66 @@ var StorageResource = class extends BaseResource {
|
|
|
2436
2863
|
sourceMapGcResultSchema
|
|
2437
2864
|
);
|
|
2438
2865
|
}
|
|
2866
|
+
/**
|
|
2867
|
+
* Retention: how long each kind of data is kept, by default and per
|
|
2868
|
+
* project, when its cleanup runs next and how the last one went.
|
|
2869
|
+
*/
|
|
2870
|
+
async getRetention() {
|
|
2871
|
+
return this.request(
|
|
2872
|
+
() => this.http.get("api/storage/retention"),
|
|
2873
|
+
retentionSchema
|
|
2874
|
+
);
|
|
2875
|
+
}
|
|
2876
|
+
/** Replaces the retention settings. A new schedule applies within a minute. */
|
|
2877
|
+
async updateRetention(settings) {
|
|
2878
|
+
const validated = this.validateInput(settings, retentionSettingsSchema);
|
|
2879
|
+
if (!validated.success) {
|
|
2880
|
+
return validated;
|
|
2881
|
+
}
|
|
2882
|
+
return this.request(
|
|
2883
|
+
() => this.http.put("api/storage/retention", { json: validated.data }),
|
|
2884
|
+
retentionSchema
|
|
2885
|
+
);
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Enforces the saved retention now, without waiting for the schedule, and
|
|
2889
|
+
* deletes unused source maps. Returns the started job; follow it with
|
|
2890
|
+
* {@link getCleanupStatus}. A `validation` error while everything is kept
|
|
2891
|
+
* forever, `conflict` while a cleanup runs.
|
|
2892
|
+
*/
|
|
2893
|
+
async runRetention() {
|
|
2894
|
+
return this.request(
|
|
2895
|
+
() => this.http.post("api/storage/retention/run", {
|
|
2896
|
+
// No retry, as for `executeCleanup`: a lost response after the
|
|
2897
|
+
// cleanup started would be retried into a refused second run.
|
|
2898
|
+
retry: 0
|
|
2899
|
+
}),
|
|
2900
|
+
cleanupStatusSchema
|
|
2901
|
+
);
|
|
2902
|
+
}
|
|
2903
|
+
/** How long ago each project's data arrived, per kind, in age buckets. */
|
|
2904
|
+
async getAge() {
|
|
2905
|
+
return this.request(
|
|
2906
|
+
() => this.http.get("api/storage/age"),
|
|
2907
|
+
storageAgeSchema
|
|
2908
|
+
);
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Dry-run: what enforcing these retention settings now would delete, each
|
|
2912
|
+
* project against its own windows. Saves and deletes nothing.
|
|
2913
|
+
*/
|
|
2914
|
+
async previewRetention(settings) {
|
|
2915
|
+
const validated = this.validateInput(settings, retentionSettingsSchema);
|
|
2916
|
+
if (!validated.success) {
|
|
2917
|
+
return validated;
|
|
2918
|
+
}
|
|
2919
|
+
return this.request(
|
|
2920
|
+
() => this.http.post("api/storage/retention/preview", {
|
|
2921
|
+
json: validated.data
|
|
2922
|
+
}),
|
|
2923
|
+
cleanupCountsSchema
|
|
2924
|
+
);
|
|
2925
|
+
}
|
|
2439
2926
|
};
|
|
2440
2927
|
|
|
2441
2928
|
// src/resources/team.ts
|
|
@@ -2675,6 +3162,14 @@ var RustrakClient = class {
|
|
|
2675
3162
|
* Logs API resource (standalone logs)
|
|
2676
3163
|
*/
|
|
2677
3164
|
logs;
|
|
3165
|
+
/**
|
|
3166
|
+
* Cron monitors API resource (Sentry Crons)
|
|
3167
|
+
*/
|
|
3168
|
+
monitors;
|
|
3169
|
+
/**
|
|
3170
|
+
* Schedules API resource (previews for crontab/interval schedules)
|
|
3171
|
+
*/
|
|
3172
|
+
schedules;
|
|
2678
3173
|
/**
|
|
2679
3174
|
* Spans API resource (standalone + transaction-embedded spans, shared table)
|
|
2680
3175
|
*/
|
|
@@ -2695,6 +3190,10 @@ var RustrakClient = class {
|
|
|
2695
3190
|
* Health API resource (version info)
|
|
2696
3191
|
*/
|
|
2697
3192
|
health;
|
|
3193
|
+
/**
|
|
3194
|
+
* GitHub integration resource
|
|
3195
|
+
*/
|
|
3196
|
+
github;
|
|
2698
3197
|
/**
|
|
2699
3198
|
* Create a new Rustrak API client
|
|
2700
3199
|
*
|
|
@@ -2707,6 +3206,7 @@ var RustrakClient = class {
|
|
|
2707
3206
|
this.issues = new IssuesResource(this.http);
|
|
2708
3207
|
this.events = new EventsResource(this.http);
|
|
2709
3208
|
this.tokens = new TokensResource(this.http);
|
|
3209
|
+
this.github = new GitHubResource(this.http);
|
|
2710
3210
|
this.alertIntegrations = new AlertIntegrationsResource(this.http);
|
|
2711
3211
|
this.alertRules = new AlertRulesResource(this.http);
|
|
2712
3212
|
this.sourceMaps = new SourceMapsResource(this.http);
|
|
@@ -2717,6 +3217,8 @@ var RustrakClient = class {
|
|
|
2717
3217
|
this.releases = new ReleasesResource(this.http);
|
|
2718
3218
|
this.transactions = new TransactionsResource(this.http);
|
|
2719
3219
|
this.logs = new LogsResource(this.http);
|
|
3220
|
+
this.monitors = new MonitorsResource(this.http);
|
|
3221
|
+
this.schedules = new SchedulesResource(this.http);
|
|
2720
3222
|
this.spans = new SpansResource(this.http);
|
|
2721
3223
|
this.agents = new AgentsResource(this.http);
|
|
2722
3224
|
this.stats = new StatsResource(this.http);
|