@rustrak/client 0.3.9 → 0.3.11

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/dist/index.cjs CHANGED
@@ -525,24 +525,129 @@ var eventDetailSchema = zod.z.object({
525
525
  data: zod.z.record(zod.z.string(), zod.z.any())
526
526
  // Full Sentry event JSON
527
527
  });
528
+ var issueStatusSchema = zod.z.enum(["unresolved", "resolved", "ignored"]);
529
+ var issuePrioritySchema = zod.z.enum(["low", "medium", "high"]);
528
530
  var issueSchema = zod.z.object({
529
531
  id: uuidSchema,
530
532
  project_id: zod.z.number().int(),
531
533
  short_id: zod.z.string(),
532
534
  title: zod.z.string(),
533
535
  value: zod.z.string(),
536
+ culprit: zod.z.string(),
537
+ logger: zod.z.string(),
534
538
  first_seen: dateTimeSchema,
535
539
  last_seen: dateTimeSchema,
536
540
  event_count: zod.z.number().int(),
537
541
  level: zod.z.string().nullable(),
538
542
  platform: zod.z.string().nullable(),
543
+ // Status model (#165)
544
+ status: issueStatusSchema,
545
+ substatus: zod.z.string().nullable(),
546
+ priority: issuePrioritySchema.nullable(),
547
+ assigned_to: zod.z.number().int().nullable(),
548
+ assignee_type: zod.z.string().nullable(),
549
+ issue_type: zod.z.string(),
550
+ issue_category: zod.z.string(),
551
+ first_release: zod.z.string(),
552
+ last_release: zod.z.string(),
553
+ status_details: zod.z.record(zod.z.string(), zod.z.unknown()),
554
+ // Aggregate enrichment — only the single-issue GET populates this; the list
555
+ // and PATCH endpoints return the lean response, so default to 0 when absent.
556
+ user_report_count: zod.z.number().int().optional().default(0),
557
+ // Per-user fields — only present when the request carries a user session.
558
+ is_bookmarked: zod.z.boolean().optional(),
559
+ is_subscribed: zod.z.boolean().optional(),
560
+ has_seen: zod.z.boolean().optional(),
561
+ // Bulk list stats — only the list endpoint populates these (computed once
562
+ // per page); the single-issue GET and PATCH responses omit them.
563
+ user_count: zod.z.number().int().optional(),
564
+ trend: zod.z.array(zod.z.number().int()).optional(),
565
+ // Deprecated, derived from `status`; kept for backward compatibility.
539
566
  is_resolved: zod.z.boolean(),
540
567
  is_muted: zod.z.boolean()
541
568
  });
542
569
  var updateIssueStateSchema = zod.z.object({
570
+ status: zod.z.union([issueStatusSchema, zod.z.literal("resolvedInNextRelease")]).optional(),
571
+ substatus: zod.z.string().optional(),
572
+ priority: issuePrioritySchema.optional(),
573
+ assigned_to: zod.z.number().int().nullable().optional(),
574
+ assignee_type: zod.z.string().nullable().optional(),
543
575
  is_resolved: zod.z.boolean().optional(),
544
576
  is_muted: zod.z.boolean().optional()
545
577
  });
578
+ var issueHashSchema = zod.z.object({
579
+ id: zod.z.number().int(),
580
+ project_id: zod.z.number().int(),
581
+ issue_id: uuidSchema,
582
+ grouping_key: zod.z.string(),
583
+ grouping_key_hash: zod.z.string(),
584
+ created_at: dateTimeSchema
585
+ });
586
+ var tagValueCountSchema = zod.z.object({
587
+ value: zod.z.string(),
588
+ count: zod.z.number().int()
589
+ });
590
+ var issueTagValueSchema = zod.z.object({
591
+ key: zod.z.string(),
592
+ name: zod.z.string(),
593
+ value: zod.z.string(),
594
+ count: zod.z.number().int(),
595
+ first_seen: dateTimeSchema,
596
+ last_seen: dateTimeSchema
597
+ });
598
+ var tagSummarySchema = zod.z.object({
599
+ key: zod.z.string(),
600
+ total_values: zod.z.number().int(),
601
+ top_values: zod.z.array(tagValueCountSchema)
602
+ });
603
+ var issueAggregatesSchema = zod.z.object({
604
+ user_count: zod.z.number().int(),
605
+ tags: zod.z.array(tagSummarySchema)
606
+ });
607
+ zod.z.enum(["24h", "30d"]);
608
+ var issueStatsSchema = zod.z.object({
609
+ data: zod.z.array(zod.z.tuple([zod.z.number(), zod.z.number()]))
610
+ });
611
+ var activityEntrySchema = zod.z.object({
612
+ id: uuidSchema,
613
+ issue_id: uuidSchema,
614
+ user_id: zod.z.number().int().nullable(),
615
+ type: zod.z.string(),
616
+ data: zod.z.string(),
617
+ created_at: dateTimeSchema
618
+ });
619
+ var userReportSchema = zod.z.object({
620
+ id: uuidSchema,
621
+ project_id: zod.z.number().int(),
622
+ issue_id: uuidSchema.nullable(),
623
+ event_id: uuidSchema.nullable(),
624
+ name: zod.z.string(),
625
+ // Server stores '' for anonymous reports (column DEFAULT '' / unwrap_or_default),
626
+ // matching real Sentry's own save_userreport(report.get("email", "")) — accept it.
627
+ email: zod.z.union([zod.z.email(), zod.z.literal("")]),
628
+ comments: zod.z.string(),
629
+ created_at: dateTimeSchema
630
+ });
631
+ var createCommentSchema = zod.z.object({
632
+ text: zod.z.string()
633
+ });
634
+ var createUserReportSchema = zod.z.object({
635
+ name: zod.z.string().optional(),
636
+ email: zod.z.email().optional(),
637
+ comments: zod.z.string().optional(),
638
+ event_id: uuidSchema.optional()
639
+ });
640
+ var bulkUpdateIssuesSchema = zod.z.object({
641
+ ids: zod.z.array(uuidSchema),
642
+ status: zod.z.union([issueStatusSchema, zod.z.literal("resolvedInNextRelease")]).optional(),
643
+ priority: issuePrioritySchema.optional()
644
+ });
645
+ var bulkDeleteIssuesSchema = zod.z.object({
646
+ ids: zod.z.array(uuidSchema)
647
+ });
648
+ var createDeploySchema = zod.z.object({
649
+ version: zod.z.string()
650
+ });
546
651
  var logSchema = zod.z.object({
547
652
  id: uuidSchema,
548
653
  trace_id: zod.z.string().nullable(),
@@ -657,7 +762,10 @@ var sourceMapGcResultSchema = zod.z.object({
657
762
  });
658
763
  var cleanupOptionsSchema = zod.z.object({
659
764
  older_than_days: zod.z.number().int().min(1),
660
- project_id: zod.z.number().int().optional()
765
+ project_id: zod.z.number().int().optional(),
766
+ include_events: zod.z.boolean().optional(),
767
+ include_transactions: zod.z.boolean().optional(),
768
+ include_logs: zod.z.boolean().optional()
661
769
  });
662
770
  var authTokenSchema = zod.z.object({
663
771
  id: zod.z.number().int(),
@@ -790,8 +898,6 @@ var InvitationsResource = class extends BaseResource {
790
898
  await this.http.delete(`api/invitations/${token}`);
791
899
  }
792
900
  };
793
-
794
- // src/resources/issues.ts
795
901
  var IssuesResource = class extends BaseResource {
796
902
  /**
797
903
  * List issues for a project with offset-based pagination
@@ -813,6 +919,9 @@ var IssuesResource = class extends BaseResource {
813
919
  if (options?.filter) {
814
920
  searchParams.filter = options.filter;
815
921
  }
922
+ if (options?.q) {
923
+ searchParams.q = options.q;
924
+ }
816
925
  const data = await this.http.get(`api/projects/${projectId}/issues`, { searchParams }).json();
817
926
  return this.validate(data, offsetPaginatedResponseSchema(issueSchema));
818
927
  }
@@ -824,7 +933,7 @@ var IssuesResource = class extends BaseResource {
824
933
  return this.validate(data, issueSchema);
825
934
  }
826
935
  /**
827
- * Update issue state (resolve, mute, etc.)
936
+ * Update issue state (status, substatus, priority, assignment, …)
828
937
  */
829
938
  async updateState(projectId, issueId, input) {
830
939
  const validatedInput = this.validate(input, updateIssueStateSchema);
@@ -833,12 +942,139 @@ var IssuesResource = class extends BaseResource {
833
942
  }).json();
834
943
  return this.validate(data, issueSchema);
835
944
  }
945
+ /**
946
+ * Resolve an issue in the next release (suppresses regression until a deploy).
947
+ */
948
+ async resolveInNextRelease(projectId, issueId) {
949
+ return this.updateState(projectId, issueId, {
950
+ status: "resolvedInNextRelease"
951
+ });
952
+ }
836
953
  /**
837
954
  * Delete an issue
838
955
  */
839
956
  async delete(projectId, issueId) {
840
957
  await this.http.delete(`api/projects/${projectId}/issues/${issueId}`);
841
958
  }
959
+ /**
960
+ * Bulk-mutate issues (status and/or priority).
961
+ */
962
+ async bulkUpdate(projectId, input) {
963
+ const validatedInput = this.validate(input, bulkUpdateIssuesSchema);
964
+ const data = await this.http.put(`api/projects/${projectId}/issues`, { json: validatedInput }).json();
965
+ return this.validate(data, zod.z.object({ updated: zod.z.number().int() }));
966
+ }
967
+ /**
968
+ * Bulk-delete issues.
969
+ */
970
+ async bulkDelete(projectId, input) {
971
+ const validatedInput = this.validate(input, bulkDeleteIssuesSchema);
972
+ const data = await this.http.delete(`api/projects/${projectId}/issues`, { json: validatedInput }).json();
973
+ return this.validate(data, zod.z.object({ deleted: zod.z.number().int() }));
974
+ }
975
+ /**
976
+ * List the grouping hashes that map to an issue.
977
+ */
978
+ async getHashes(projectId, issueId) {
979
+ const data = await this.http.get(`api/projects/${projectId}/issues/${issueId}/hashes`).json();
980
+ return this.validate(data, zod.z.array(issueHashSchema));
981
+ }
982
+ /**
983
+ * List the distinct values (with counts) for a tag key across the issue.
984
+ * Returns a bare list, one entry per value (Sentry-compatible shape).
985
+ */
986
+ async getTagValues(projectId, issueId, key) {
987
+ const data = await this.http.get(
988
+ `api/projects/${projectId}/issues/${issueId}/tags/${encodeURIComponent(key)}`
989
+ ).json();
990
+ return this.validate(data, zod.z.array(issueTagValueSchema));
991
+ }
992
+ /**
993
+ * Fetch per-issue aggregates (unique user count + top tags).
994
+ */
995
+ async getAggregates(projectId, issueId) {
996
+ const data = await this.http.get(`api/projects/${projectId}/issues/${issueId}/aggregates`).json();
997
+ return this.validate(data, issueAggregatesSchema);
998
+ }
999
+ /**
1000
+ * Fetch a zero-filled event-count timeseries (24h or 30d).
1001
+ */
1002
+ async getStats(projectId, issueId, window = "24h") {
1003
+ const data = await this.http.get(`api/projects/${projectId}/issues/${issueId}/stats`, {
1004
+ searchParams: { window }
1005
+ }).json();
1006
+ return this.validate(data, issueStatsSchema);
1007
+ }
1008
+ /**
1009
+ * List an issue's activity log (status changes, comments/notes, …).
1010
+ */
1011
+ async getActivity(projectId, issueId) {
1012
+ const data = await this.http.get(`api/projects/${projectId}/issues/${issueId}/activity`).json();
1013
+ return this.validate(data, zod.z.array(activityEntrySchema));
1014
+ }
1015
+ /**
1016
+ * Add a comment (note) to an issue.
1017
+ */
1018
+ async addComment(projectId, issueId, input) {
1019
+ const validatedInput = this.validate(input, createCommentSchema);
1020
+ const data = await this.http.post(`api/projects/${projectId}/issues/${issueId}/comments`, {
1021
+ json: validatedInput
1022
+ }).json();
1023
+ return this.validate(data, activityEntrySchema);
1024
+ }
1025
+ /**
1026
+ * Set or clear the current user's bookmark on an issue.
1027
+ */
1028
+ async setBookmark(projectId, issueId, enabled) {
1029
+ const data = await this.http.put(`api/projects/${projectId}/issues/${issueId}/bookmark`, {
1030
+ json: { enabled }
1031
+ }).json();
1032
+ return this.validate(data, zod.z.object({ is_bookmarked: zod.z.boolean() }));
1033
+ }
1034
+ /**
1035
+ * Set or clear the current user's subscription to an issue.
1036
+ */
1037
+ async setSubscription(projectId, issueId, enabled) {
1038
+ const data = await this.http.put(`api/projects/${projectId}/issues/${issueId}/subscription`, {
1039
+ json: { enabled }
1040
+ }).json();
1041
+ return this.validate(data, zod.z.object({ is_subscribed: zod.z.boolean() }));
1042
+ }
1043
+ /**
1044
+ * Mark the issue as seen by the current user.
1045
+ */
1046
+ async markSeen(projectId, issueId) {
1047
+ const data = await this.http.post(`api/projects/${projectId}/issues/${issueId}/seen`).json();
1048
+ return this.validate(data, zod.z.object({ has_seen: zod.z.boolean() }));
1049
+ }
1050
+ /**
1051
+ * List user feedback reports for an issue.
1052
+ */
1053
+ async listUserReports(projectId, issueId) {
1054
+ const data = await this.http.get(`api/projects/${projectId}/issues/${issueId}/user-reports`).json();
1055
+ return this.validate(data, zod.z.array(userReportSchema));
1056
+ }
1057
+ /**
1058
+ * Attach a user feedback report to an issue.
1059
+ */
1060
+ async createUserReport(projectId, issueId, input) {
1061
+ const validatedInput = this.validate(input, createUserReportSchema);
1062
+ const data = await this.http.post(`api/projects/${projectId}/issues/${issueId}/user-reports`, {
1063
+ json: validatedInput
1064
+ }).json();
1065
+ return this.validate(data, userReportSchema);
1066
+ }
1067
+ /**
1068
+ * Record a deploy of a release, finalizing resolve-in-next-release issues.
1069
+ */
1070
+ async createDeploy(projectId, input) {
1071
+ const validatedInput = this.validate(input, createDeploySchema);
1072
+ const data = await this.http.post(`api/projects/${projectId}/deploys`, { json: validatedInput }).json();
1073
+ return this.validate(
1074
+ data,
1075
+ zod.z.object({ version: zod.z.string(), finalized: zod.z.number().int() })
1076
+ );
1077
+ }
842
1078
  };
843
1079
 
844
1080
  // src/resources/logs.ts