@rustrak/client 0.17.0 → 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 +302 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +414 -1
- package/dist/index.d.ts +414 -1
- package/dist/index.js +302 -2
- 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
|
@@ -508,6 +508,96 @@ var upsertProjectMemberSchema = zod.z.object({
|
|
|
508
508
|
user_id: zod.z.number().int(),
|
|
509
509
|
role: projectRoleSchema
|
|
510
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
|
+
});
|
|
511
601
|
var metricDeltaSchema = zod.z.object({
|
|
512
602
|
current: zod.z.number().int(),
|
|
513
603
|
/**
|
|
@@ -680,14 +770,21 @@ var projectStorageSchema = zod.z.object({
|
|
|
680
770
|
spans_count: zod.z.number(),
|
|
681
771
|
logs_count: zod.z.number(),
|
|
682
772
|
source_maps_count: zod.z.number(),
|
|
683
|
-
|
|
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()
|
|
684
779
|
});
|
|
685
780
|
var cleanupCountsSchema = zod.z.object({
|
|
686
781
|
events: zod.z.number(),
|
|
687
782
|
transactions: zod.z.number(),
|
|
688
783
|
spans: zod.z.number(),
|
|
689
784
|
logs: zod.z.number(),
|
|
690
|
-
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)
|
|
691
788
|
});
|
|
692
789
|
var cleanupStatusSchema = zod.z.object({
|
|
693
790
|
state: zod.z.enum(["idle", "running", "completed", "failed"]),
|
|
@@ -700,6 +797,53 @@ var sourceMapGcResultSchema = zod.z.object({
|
|
|
700
797
|
files_removed: zod.z.number(),
|
|
701
798
|
bytes_freed: zod.z.number()
|
|
702
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
|
+
});
|
|
703
847
|
var cleanupOptionsSchema = zod.z.object({
|
|
704
848
|
older_than_days: zod.z.number().int().min(1),
|
|
705
849
|
project_id: zod.z.number().int().optional(),
|
|
@@ -2206,6 +2350,77 @@ var MembersResource = class extends BaseResource {
|
|
|
2206
2350
|
);
|
|
2207
2351
|
}
|
|
2208
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
|
+
};
|
|
2209
2424
|
|
|
2210
2425
|
// src/resources/projects.ts
|
|
2211
2426
|
var ProjectsResource = class extends BaseResource {
|
|
@@ -2307,6 +2522,21 @@ var ReleasesResource = class extends BaseResource {
|
|
|
2307
2522
|
}
|
|
2308
2523
|
};
|
|
2309
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
|
+
|
|
2310
2540
|
// src/resources/sessions.ts
|
|
2311
2541
|
var SessionsResource = class extends BaseResource {
|
|
2312
2542
|
/**
|
|
@@ -2639,6 +2869,66 @@ var StorageResource = class extends BaseResource {
|
|
|
2639
2869
|
sourceMapGcResultSchema
|
|
2640
2870
|
);
|
|
2641
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
|
+
}
|
|
2642
2932
|
};
|
|
2643
2933
|
|
|
2644
2934
|
// src/resources/team.ts
|
|
@@ -2878,6 +3168,14 @@ var RustrakClient = class {
|
|
|
2878
3168
|
* Logs API resource (standalone logs)
|
|
2879
3169
|
*/
|
|
2880
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;
|
|
2881
3179
|
/**
|
|
2882
3180
|
* Spans API resource (standalone + transaction-embedded spans, shared table)
|
|
2883
3181
|
*/
|
|
@@ -2925,6 +3223,8 @@ var RustrakClient = class {
|
|
|
2925
3223
|
this.releases = new ReleasesResource(this.http);
|
|
2926
3224
|
this.transactions = new TransactionsResource(this.http);
|
|
2927
3225
|
this.logs = new LogsResource(this.http);
|
|
3226
|
+
this.monitors = new MonitorsResource(this.http);
|
|
3227
|
+
this.schedules = new SchedulesResource(this.http);
|
|
2928
3228
|
this.spans = new SpansResource(this.http);
|
|
2929
3229
|
this.agents = new AgentsResource(this.http);
|
|
2930
3230
|
this.stats = new StatsResource(this.http);
|