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