@rustrak/client 0.15.0 → 0.15.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/README.md CHANGED
@@ -135,6 +135,8 @@ await client.issues.delete(projectId, issueId);
135
135
  ```typescript
136
136
  const { items } = await client.events.list(projectId, issueId, { order: 'desc' });
137
137
  const event = await client.events.get(projectId, issueId, eventId);
138
+ // Resolve the ID returned by a Sentry SDK without knowing its issue first.
139
+ const captured = await client.events.getBySentryId(projectId, sentryEventId);
138
140
  console.log(event.data); // Full Sentry event payload
139
141
  ```
140
142
 
@@ -264,7 +266,7 @@ export default async function ProjectsPage() {
264
266
  // `kind` is what decides: only 'unauthenticated' means "send to login".
265
267
  // Redirecting on 'network' or 'server_error' turns a flaky connection
266
268
  // into a login loop.
267
- if (projects.error.kind === 'unauthenticated') redirect('/auth/login');
269
+ if (projects.error.kind === 'unauthenticated') redirect('/login');
268
270
  return <LoadFailed error={projects.error} />;
269
271
  }
270
272
 
@@ -317,7 +319,7 @@ import type {
317
319
 
318
320
  ## What is Rustrak?
319
321
 
320
- [Rustrak](https://rustrak.github.io/rustrak) is a self-hosted error tracking server written in Rust that is fully compatible with any Sentry SDK. Drop-in replacement for Sentry — no code changes needed. Runs on ~50 MB of memory as a single binary or Docker image.
322
+ [Rustrak](https://rustrak.github.io/rustrak) 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.
321
323
 
322
324
  - [Getting Started](https://rustrak.github.io/rustrak/getting-started/overview)
323
325
  - [Self-Hosting Guide](https://rustrak.github.io/rustrak/configuration/production)
package/dist/index.cjs CHANGED
@@ -443,6 +443,14 @@ var projectSchema = zod.z.object({
443
443
  dsn: zod.z.string(),
444
444
  stored_event_count: zod.z.number().int(),
445
445
  digested_event_count: zod.z.number().int(),
446
+ /** Accepted events the quota dropped instead of storing. */
447
+ rate_limited_event_count: zod.z.number().int(),
448
+ /**
449
+ * The project's own limits, or null where it follows the server's. They can
450
+ * only tighten `MAX_EVENTS_PER_PROJECT_*`, never raise it.
451
+ */
452
+ rate_limit_per_minute: zod.z.number().int().nullable(),
453
+ rate_limit_per_hour: zod.z.number().int().nullable(),
446
454
  created_at: dateTimeSchema,
447
455
  updated_at: dateTimeSchema,
448
456
  platform: zod.z.string().nullable(),
@@ -469,7 +477,14 @@ var updateProjectSchema = zod.z.object({
469
477
  * Slugified server-side. Unlike on create, a taken slug is a 409 rather than
470
478
  * being silently de-duplicated.
471
479
  */
472
- slug: zod.z.string().min(1).optional()
480
+ slug: zod.z.string().min(1).optional(),
481
+ /** A number sets the project's own limit; null removes it. */
482
+ rate_limit_per_minute: zod.z.number().int().min(1).nullable().optional(),
483
+ rate_limit_per_hour: zod.z.number().int().min(1).nullable().optional()
484
+ });
485
+ var rateLimitsSchema = zod.z.object({
486
+ project_per_minute: zod.z.number().int(),
487
+ project_per_hour: zod.z.number().int()
473
488
  });
474
489
  var releaseHealthRowSchema = zod.z.object({
475
490
  release: zod.z.string(),
@@ -712,6 +727,20 @@ var registerRequestSchema = zod.z.object({
712
727
  email: zod.z.string().email(),
713
728
  password: zod.z.string().min(1)
714
729
  });
730
+ var ssoConfigSchema = zod.z.object({
731
+ enabled: zod.z.boolean(),
732
+ provider_name: zod.z.string().nullable()
733
+ });
734
+ var ssoStartSchema = zod.z.object({
735
+ authorization_url: zod.z.string().url()
736
+ });
737
+ var ssoLinkSchema = zod.z.object({
738
+ email: zod.z.string(),
739
+ provider_name: zod.z.string()
740
+ });
741
+ var confirmSsoLinkRequestSchema = zod.z.object({
742
+ password: zod.z.string().min(1)
743
+ });
715
744
 
716
745
  // src/errors.ts
717
746
  var FIELD_ERROR_CODES = [
@@ -1384,6 +1413,59 @@ function readSetCookie(response) {
1384
1413
  return folded === null ? [] : [folded];
1385
1414
  }
1386
1415
  var AuthResource = class extends BaseResource {
1416
+ /** Return the public SSO login configuration. */
1417
+ async getSsoConfig() {
1418
+ return this.request(
1419
+ () => this.http.get("auth/sso/config"),
1420
+ ssoConfigSchema
1421
+ );
1422
+ }
1423
+ /** Begin SSO and return the provider URL plus the encrypted state cookie. */
1424
+ async startSso() {
1425
+ return this.requestResponse(
1426
+ () => this.http.post("auth/sso/start"),
1427
+ async (response) => {
1428
+ const cookies = readSetCookie(response);
1429
+ const body = await this.readJson(response);
1430
+ if (!body.success) return body;
1431
+ const data = this.validate(body.data, ssoStartSchema);
1432
+ if (!data.success) return data;
1433
+ return Ok({
1434
+ authorizationUrl: data.data.authorization_url,
1435
+ cookies
1436
+ });
1437
+ }
1438
+ );
1439
+ }
1440
+ /** The account an SSO login is waiting to link, if any. */
1441
+ async getSsoLink() {
1442
+ return this.request(() => this.http.get("auth/sso/link"), ssoLinkSchema);
1443
+ }
1444
+ /** Link the pending SSO identity with the account's password and sign in. */
1445
+ async confirmSsoLink(password) {
1446
+ const validatedInput = this.validateInput(
1447
+ { password },
1448
+ confirmSsoLinkRequestSchema
1449
+ );
1450
+ if (!validatedInput.success) {
1451
+ return validatedInput;
1452
+ }
1453
+ return this.requestResponse(
1454
+ () => this.http.post("auth/sso/link", { json: validatedInput.data }),
1455
+ (response) => this.readLoginResult(response)
1456
+ );
1457
+ }
1458
+ /** Complete an OIDC callback and return the normal Rustrak session cookie. */
1459
+ async completeSso(callback) {
1460
+ const searchParams = new URLSearchParams();
1461
+ if (callback.code) searchParams.set("code", callback.code);
1462
+ if (callback.state) searchParams.set("state", callback.state);
1463
+ if (callback.error) searchParams.set("error", callback.error);
1464
+ return this.requestResponse(
1465
+ () => this.http.get("auth/sso/callback", { searchParams }),
1466
+ (response) => this.readLoginResult(response)
1467
+ );
1468
+ }
1387
1469
  /**
1388
1470
  * Register a new user account
1389
1471
  * Creates a new user and automatically logs them in (sets session cookie)
@@ -1545,6 +1627,15 @@ var EventsResource = class extends BaseResource {
1545
1627
  eventDetailSchema
1546
1628
  );
1547
1629
  }
1630
+ /** Resolve the client-supplied Sentry event ID, including its owning issue. */
1631
+ async getBySentryId(projectId, eventId) {
1632
+ return this.request(
1633
+ () => this.http.get(
1634
+ `api/projects/${projectId}/events/sentry/${encodeURIComponent(eventId)}`
1635
+ ),
1636
+ eventDetailSchema
1637
+ );
1638
+ }
1548
1639
  };
1549
1640
  var serverVersionSchema = zod.z.object({
1550
1641
  version: zod.z.string()
@@ -1919,6 +2010,15 @@ var ProjectsResource = class extends BaseResource {
1919
2010
  offsetPaginatedResponseSchema(projectSchema)
1920
2011
  );
1921
2012
  }
2013
+ /**
2014
+ * The server's per-project limits, which a project without its own follows
2015
+ */
2016
+ async rateLimits() {
2017
+ return this.request(
2018
+ () => this.http.get("api/rate-limits"),
2019
+ rateLimitsSchema
2020
+ );
2021
+ }
1922
2022
  /**
1923
2023
  * Get a single project by ID
1924
2024
  */