@rustrak/client 0.12.3 → 0.14.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { z, ZodSchema, ZodError } from 'zod';
2
- import { KyInstance } from 'ky';
1
+ import { z, ZodSchema } from 'zod';
2
+ import { KyInstance, ResponsePromise } from 'ky';
3
3
 
4
4
  interface ClientConfig {
5
5
  baseUrl: string;
@@ -9,6 +9,94 @@ interface ClientConfig {
9
9
  headers?: Record<string, string>;
10
10
  }
11
11
 
12
+ type RustrakError = {
13
+ readonly kind: 'validation';
14
+ readonly status: number;
15
+ readonly message: string;
16
+ readonly fields?: readonly FieldError[];
17
+ } | {
18
+ readonly kind: 'unauthenticated';
19
+ readonly status: number;
20
+ readonly message: string;
21
+ readonly fields?: readonly FieldError[];
22
+ } | {
23
+ readonly kind: 'forbidden';
24
+ readonly status: number;
25
+ readonly message: string;
26
+ readonly fields?: readonly FieldError[];
27
+ } | {
28
+ readonly kind: 'not_found';
29
+ readonly status: number;
30
+ readonly message: string;
31
+ readonly fields?: readonly FieldError[];
32
+ } | {
33
+ readonly kind: 'conflict';
34
+ readonly status: number;
35
+ readonly message: string;
36
+ readonly fields?: readonly FieldError[];
37
+ } | {
38
+ readonly kind: 'gone';
39
+ readonly status: number;
40
+ readonly message: string;
41
+ readonly fields?: readonly FieldError[];
42
+ } | {
43
+ readonly kind: 'payload_too_large';
44
+ readonly status: number;
45
+ readonly message: string;
46
+ readonly fields?: readonly FieldError[];
47
+ } | {
48
+ readonly kind: 'rate_limited';
49
+ readonly status: number;
50
+ readonly message: string;
51
+ readonly retryAfter?: number;
52
+ readonly fields?: readonly FieldError[];
53
+ } | {
54
+ readonly kind: 'client_error';
55
+ readonly status: number;
56
+ readonly message: string;
57
+ readonly fields?: readonly FieldError[];
58
+ } | {
59
+ readonly kind: 'invalid_request';
60
+ readonly message: string;
61
+ } | {
62
+ readonly kind: 'server_error';
63
+ readonly status: number;
64
+ readonly message: string;
65
+ readonly incidentId?: string;
66
+ } | {
67
+ readonly kind: 'network';
68
+ readonly message: string;
69
+ readonly reason: 'timeout' | 'unreachable';
70
+ } | {
71
+ readonly kind: 'invalid_response';
72
+ readonly message: string;
73
+ };
74
+ type RustrakErrorKind = RustrakError['kind'];
75
+ declare const FIELD_ERROR_CODES: readonly ["required", "invalid", "already_exists", "too_short", "too_long", "custom"];
76
+ type FieldErrorCode = (typeof FIELD_ERROR_CODES)[number];
77
+ type FieldError = {
78
+ readonly field: string;
79
+ readonly code: FieldErrorCode;
80
+ readonly message?: string;
81
+ };
82
+ declare const SERVER_ERROR_MESSAGE = "The server failed to handle the request.";
83
+ declare const NETWORK_ERROR_MESSAGE = "The request could not reach the server.";
84
+ declare const TIMEOUT_ERROR_MESSAGE = "The request timed out.";
85
+ declare function isRetryable(error: RustrakError): boolean;
86
+
87
+ type Result<T, E> = {
88
+ readonly success: true;
89
+ readonly data: T;
90
+ } | {
91
+ readonly success: false;
92
+ readonly error: E;
93
+ };
94
+ declare function Ok<T>(data: T): Result<T, never>;
95
+ declare function Err<E>(error: E): Result<never, E>;
96
+ declare function unwrap<T, E>(result: Result<T, E>): T;
97
+ declare function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T;
98
+ declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
99
+
12
100
  declare const serverVersionSchema: z.ZodObject<{
13
101
  version: z.ZodString;
14
102
  }, z.core.$strip>;
@@ -183,15 +271,11 @@ declare const testIntegrationBodySchema: z.ZodObject<{
183
271
  }, z.core.$strip>;
184
272
 
185
273
  type ProviderType = z.infer<typeof providerTypeSchema>;
186
- type ChannelType = ProviderType;
187
274
  type AlertType = z.infer<typeof alertTypeSchema>;
188
275
  type AlertStatus = z.infer<typeof alertStatusSchema>;
189
276
  type AlertIntegration = z.infer<typeof alertIntegrationSchema>;
190
- type NotificationChannel = AlertIntegration;
191
277
  type CreateAlertIntegration = z.infer<typeof createAlertIntegrationSchema>;
192
- type CreateNotificationChannel = CreateAlertIntegration;
193
278
  type UpdateAlertIntegration = z.infer<typeof updateAlertIntegrationSchema>;
194
- type UpdateNotificationChannel = UpdateAlertIntegration;
195
279
  type AlertRuleChannelInput = z.infer<typeof alertRuleChannelInputSchema>;
196
280
  type RoutingOverride = Record<string, unknown>;
197
281
  type AlertRule = z.infer<typeof alertRuleSchema>;
@@ -256,6 +340,7 @@ interface ListProjectsOptions {
256
340
  page?: number;
257
341
  per_page?: number;
258
342
  order?: SortOrder;
343
+ stats_period?: string;
259
344
  }
260
345
  interface ListTransactionsOptions {
261
346
  page?: number;
@@ -566,6 +651,19 @@ type ProjectRole = z.infer<typeof projectRoleSchema>;
566
651
  type ProjectMember = z.infer<typeof projectMemberSchema>;
567
652
  type UpsertProjectMember = z.infer<typeof upsertProjectMemberSchema>;
568
653
 
654
+ declare const projectListStatsSchema: z.ZodObject<{
655
+ trend: z.ZodArray<z.ZodNumber>;
656
+ events: z.ZodObject<{
657
+ current: z.ZodNumber;
658
+ previous: z.ZodNullable<z.ZodNumber>;
659
+ }, z.core.$strip>;
660
+ new_issues: z.ZodObject<{
661
+ current: z.ZodNumber;
662
+ previous: z.ZodNullable<z.ZodNumber>;
663
+ }, z.core.$strip>;
664
+ open_issues: z.ZodNumber;
665
+ fatal_issues: z.ZodNumber;
666
+ }, z.core.$strip>;
569
667
  declare const projectSchema: z.ZodObject<{
570
668
  id: z.ZodNumber;
571
669
  name: z.ZodString;
@@ -577,17 +675,33 @@ declare const projectSchema: z.ZodObject<{
577
675
  created_at: z.ZodString;
578
676
  updated_at: z.ZodString;
579
677
  platform: z.ZodNullable<z.ZodString>;
678
+ stats: z.ZodOptional<z.ZodObject<{
679
+ trend: z.ZodArray<z.ZodNumber>;
680
+ events: z.ZodObject<{
681
+ current: z.ZodNumber;
682
+ previous: z.ZodNullable<z.ZodNumber>;
683
+ }, z.core.$strip>;
684
+ new_issues: z.ZodObject<{
685
+ current: z.ZodNumber;
686
+ previous: z.ZodNullable<z.ZodNumber>;
687
+ }, z.core.$strip>;
688
+ open_issues: z.ZodNumber;
689
+ fatal_issues: z.ZodNumber;
690
+ }, z.core.$strip>>;
580
691
  }, z.core.$strip>;
581
692
  declare const createProjectSchema: z.ZodObject<{
582
693
  name: z.ZodString;
583
694
  slug: z.ZodOptional<z.ZodString>;
695
+ platform: z.ZodOptional<z.ZodString>;
584
696
  }, z.core.$strip>;
585
697
  declare const updateProjectSchema: z.ZodObject<{
586
698
  name: z.ZodOptional<z.ZodString>;
587
699
  platform: z.ZodOptional<z.ZodString>;
700
+ slug: z.ZodOptional<z.ZodString>;
588
701
  }, z.core.$strip>;
589
702
 
590
703
  type Project = z.infer<typeof projectSchema>;
704
+ type ProjectListStats = z.infer<typeof projectListStatsSchema>;
591
705
  type CreateProject = z.infer<typeof createProjectSchema>;
592
706
  type UpdateProject = z.infer<typeof updateProjectSchema>;
593
707
 
@@ -638,6 +752,11 @@ declare const chunkUploadCapabilitySchema: z.ZodObject<{
638
752
  accept: z.ZodArray<z.ZodString>;
639
753
  concurrency: z.ZodOptional<z.ZodNumber>;
640
754
  }, z.core.$strip>;
755
+ declare const assembleInputSchema: z.ZodObject<{
756
+ checksum: z.ZodString;
757
+ chunks: z.ZodArray<z.ZodString>;
758
+ projects: z.ZodArray<z.ZodString>;
759
+ }, z.core.$strip>;
641
760
  declare const assembleResponseSchema: z.ZodObject<{
642
761
  state: z.ZodString;
643
762
  missingChunks: z.ZodArray<z.ZodString>;
@@ -664,11 +783,7 @@ type ChunkUploadCapability = z.infer<typeof chunkUploadCapabilitySchema>;
664
783
  type AssembleResponse = z.infer<typeof assembleResponseSchema>;
665
784
  type SourceMapFile = z.infer<typeof sourceMapFileSchema>;
666
785
  type ListSourceMapsResponse = z.infer<typeof listSourceMapsResponseSchema>;
667
- interface AssembleInput {
668
- checksum: string;
669
- chunks: string[];
670
- projects: string[];
671
- }
786
+ type AssembleInput = z.infer<typeof assembleInputSchema>;
672
787
 
673
788
  declare const eventTimeseriesPointSchema: z.ZodObject<{
674
789
  bucket: z.ZodString;
@@ -937,169 +1052,175 @@ type RegisterRequest = z.infer<typeof registerRequestSchema>;
937
1052
  declare abstract class BaseResource {
938
1053
  protected readonly http: KyInstance;
939
1054
  constructor(http: KyInstance);
940
- protected validate<T>(data: unknown, schema: ZodSchema<T>): T;
1055
+ protected validate<T>(data: unknown, schema: ZodSchema<T>): Result<T, RustrakError>;
1056
+ protected validateInput<T>(input: unknown, schema: ZodSchema<T>): Result<T, RustrakError>;
1057
+ protected requestResponse<T>(send: () => ResponsePromise, read: (response: Response) => Promise<Result<T, RustrakError>>): Promise<Result<T, RustrakError>>;
1058
+ protected readJson(response: Response): Promise<Result<unknown, RustrakError>>;
1059
+ protected request<T>(send: () => ResponsePromise, schema: ZodSchema<T>): Promise<Result<T, RustrakError>>;
1060
+ protected requestVoid(send: () => ResponsePromise): Promise<Result<void, RustrakError>>;
941
1061
  }
942
1062
 
943
1063
  declare class AgentsResource extends BaseResource {
944
- getRuns(projectId: number, options?: AgentTimeseriesOptions): Promise<AgentTimeseriesPoint[]>;
945
- getDuration(projectId: number, options?: AgentTimeseriesOptions): Promise<AgentDurationPoint[]>;
946
- getModelsByCalls(projectId: number, options?: AgentBreakdownOptions): Promise<GenAiBreakdownRow[]>;
947
- getModelsByTokens(projectId: number, options?: AgentBreakdownOptions): Promise<GenAiBreakdownRow[]>;
948
- getTools(projectId: number, options?: AgentBreakdownOptions): Promise<GenAiBreakdownRow[]>;
949
- getTraces(projectId: number, options?: AgentTracesOptions): Promise<OffsetPaginatedResponse<AgentTraceSummary>>;
1064
+ getRuns(projectId: number, options?: AgentTimeseriesOptions): Promise<Result<AgentTimeseriesPoint[], RustrakError>>;
1065
+ getDuration(projectId: number, options?: AgentTimeseriesOptions): Promise<Result<AgentDurationPoint[], RustrakError>>;
1066
+ getModelsByCalls(projectId: number, options?: AgentBreakdownOptions): Promise<Result<GenAiBreakdownRow[], RustrakError>>;
1067
+ getModelsByTokens(projectId: number, options?: AgentBreakdownOptions): Promise<Result<GenAiBreakdownRow[], RustrakError>>;
1068
+ getTools(projectId: number, options?: AgentBreakdownOptions): Promise<Result<GenAiBreakdownRow[], RustrakError>>;
1069
+ getTraces(projectId: number, options?: AgentTracesOptions): Promise<Result<OffsetPaginatedResponse<AgentTraceSummary>, RustrakError>>;
950
1070
  }
951
1071
 
952
1072
  declare class AlertIntegrationsResource extends BaseResource {
953
- list(): Promise<AlertIntegration[]>;
954
- get(id: number): Promise<AlertIntegration>;
955
- create(input: CreateAlertIntegration): Promise<AlertIntegration>;
956
- update(id: number, input: UpdateAlertIntegration): Promise<AlertIntegration>;
957
- delete(id: number): Promise<void>;
958
- test(id: number, routingOverride?: RoutingOverride): Promise<TestChannelResponse>;
1073
+ list(): Promise<Result<AlertIntegration[], RustrakError>>;
1074
+ get(id: number): Promise<Result<AlertIntegration, RustrakError>>;
1075
+ create(input: CreateAlertIntegration): Promise<Result<AlertIntegration, RustrakError>>;
1076
+ update(id: number, input: UpdateAlertIntegration): Promise<Result<AlertIntegration, RustrakError>>;
1077
+ delete(id: number): Promise<Result<void, RustrakError>>;
1078
+ test(id: number, routingOverride?: RoutingOverride): Promise<Result<TestChannelResponse, RustrakError>>;
959
1079
  }
960
1080
 
961
1081
  declare class AlertRulesResource extends BaseResource {
962
- list(projectId: number): Promise<AlertRule[]>;
963
- get(projectId: number, ruleId: number): Promise<AlertRule>;
964
- create(projectId: number, input: CreateAlertRule): Promise<AlertRule>;
965
- update(projectId: number, ruleId: number, input: UpdateAlertRule): Promise<AlertRule>;
966
- delete(projectId: number, ruleId: number): Promise<void>;
967
- listHistory(projectId: number, options?: ListAlertHistoryOptions): Promise<AlertHistory[]>;
1082
+ list(projectId: number): Promise<Result<AlertRule[], RustrakError>>;
1083
+ get(projectId: number, ruleId: number): Promise<Result<AlertRule, RustrakError>>;
1084
+ create(projectId: number, input: CreateAlertRule): Promise<Result<AlertRule, RustrakError>>;
1085
+ update(projectId: number, ruleId: number, input: UpdateAlertRule): Promise<Result<AlertRule, RustrakError>>;
1086
+ delete(projectId: number, ruleId: number): Promise<Result<void, RustrakError>>;
1087
+ listHistory(projectId: number, options?: ListAlertHistoryOptions): Promise<Result<AlertHistory[], RustrakError>>;
968
1088
  }
969
1089
 
970
1090
  declare class AuthResource extends BaseResource {
971
- register(credentials: RegisterRequest): Promise<LoginResult>;
972
- login(credentials: LoginRequest): Promise<LoginResult>;
973
- logout(): Promise<string[]>;
974
- getCurrentUser(): Promise<User>;
975
- getInvitation(token: string): Promise<InvitationInfo>;
976
- acceptInvitation(input: AcceptInvitation): Promise<LoginResult>;
1091
+ register(credentials: RegisterRequest): Promise<Result<LoginResult, RustrakError>>;
1092
+ login(credentials: LoginRequest): Promise<Result<LoginResult, RustrakError>>;
1093
+ logout(): Promise<Result<string[], RustrakError>>;
1094
+ getCurrentUser(): Promise<Result<User, RustrakError>>;
1095
+ getInvitation(token: string): Promise<Result<InvitationInfo, RustrakError>>;
1096
+ acceptInvitation(input: AcceptInvitation): Promise<Result<LoginResult, RustrakError>>;
1097
+ private readLoginResult;
977
1098
  }
978
1099
 
979
1100
  declare class EventsResource extends BaseResource {
980
- list(projectId: number, issueId: string, options?: ListEventsOptions): Promise<PaginatedResponse<Event>>;
981
- get(projectId: number, issueId: string, eventId: string): Promise<EventDetail>;
1101
+ list(projectId: number, issueId: string, options?: ListEventsOptions): Promise<Result<PaginatedResponse<Event>, RustrakError>>;
1102
+ get(projectId: number, issueId: string, eventId: string): Promise<Result<EventDetail, RustrakError>>;
982
1103
  }
983
1104
 
984
1105
  declare class HealthResource extends BaseResource {
985
- getVersion(): Promise<ServerVersion>;
1106
+ getVersion(): Promise<Result<ServerVersion, RustrakError>>;
986
1107
  }
987
1108
 
988
1109
  declare class InvitationsResource extends BaseResource {
989
- create(input: CreateInvitation): Promise<Invitation>;
990
- list(): Promise<Invitation[]>;
991
- revoke(token: string): Promise<void>;
1110
+ create(input: CreateInvitation): Promise<Result<Invitation, RustrakError>>;
1111
+ list(): Promise<Result<Invitation[], RustrakError>>;
1112
+ revoke(token: string): Promise<Result<void, RustrakError>>;
992
1113
  }
993
1114
 
994
1115
  declare class IssuesResource extends BaseResource {
995
- list(projectId: number, options?: ListIssuesOptions): Promise<OffsetPaginatedResponse<Issue>>;
996
- get(projectId: number, issueId: string): Promise<Issue>;
997
- updateState(projectId: number, issueId: string, input: UpdateIssueState): Promise<Issue>;
998
- resolveInNextRelease(projectId: number, issueId: string): Promise<Issue>;
999
- delete(projectId: number, issueId: string): Promise<void>;
1000
- bulkUpdate(projectId: number, input: BulkUpdateIssues): Promise<{
1116
+ list(projectId: number, options?: ListIssuesOptions): Promise<Result<OffsetPaginatedResponse<Issue>, RustrakError>>;
1117
+ get(projectId: number, issueId: string): Promise<Result<Issue, RustrakError>>;
1118
+ updateState(projectId: number, issueId: string, input: UpdateIssueState): Promise<Result<Issue, RustrakError>>;
1119
+ resolveInNextRelease(projectId: number, issueId: string): Promise<Result<Issue, RustrakError>>;
1120
+ delete(projectId: number, issueId: string): Promise<Result<void, RustrakError>>;
1121
+ bulkUpdate(projectId: number, input: BulkUpdateIssues): Promise<Result<{
1001
1122
  updated: number;
1002
- }>;
1003
- bulkDelete(projectId: number, input: BulkDeleteIssues): Promise<{
1123
+ }, RustrakError>>;
1124
+ bulkDelete(projectId: number, input: BulkDeleteIssues): Promise<Result<{
1004
1125
  deleted: number;
1005
- }>;
1006
- getHashes(projectId: number, issueId: string): Promise<IssueHash[]>;
1007
- getTagValues(projectId: number, issueId: string, key: string): Promise<IssueTagValue[]>;
1008
- getAggregates(projectId: number, issueId: string): Promise<IssueAggregates>;
1009
- getStats(projectId: number, issueId: string, window?: IssueStatsWindow): Promise<IssueStats>;
1010
- getActivity(projectId: number, issueId: string): Promise<ActivityEntry[]>;
1011
- addComment(projectId: number, issueId: string, input: CreateComment): Promise<ActivityEntry>;
1012
- setBookmark(projectId: number, issueId: string, enabled: boolean): Promise<{
1126
+ }, RustrakError>>;
1127
+ getHashes(projectId: number, issueId: string): Promise<Result<IssueHash[], RustrakError>>;
1128
+ getTagValues(projectId: number, issueId: string, key: string): Promise<Result<IssueTagValue[], RustrakError>>;
1129
+ getAggregates(projectId: number, issueId: string): Promise<Result<IssueAggregates, RustrakError>>;
1130
+ getStats(projectId: number, issueId: string, window?: IssueStatsWindow): Promise<Result<IssueStats, RustrakError>>;
1131
+ getActivity(projectId: number, issueId: string): Promise<Result<ActivityEntry[], RustrakError>>;
1132
+ addComment(projectId: number, issueId: string, input: CreateComment): Promise<Result<ActivityEntry, RustrakError>>;
1133
+ setBookmark(projectId: number, issueId: string, enabled: boolean): Promise<Result<{
1013
1134
  is_bookmarked: boolean;
1014
- }>;
1015
- setSubscription(projectId: number, issueId: string, enabled: boolean): Promise<{
1135
+ }, RustrakError>>;
1136
+ setSubscription(projectId: number, issueId: string, enabled: boolean): Promise<Result<{
1016
1137
  is_subscribed: boolean;
1017
- }>;
1018
- markSeen(projectId: number, issueId: string): Promise<{
1138
+ }, RustrakError>>;
1139
+ markSeen(projectId: number, issueId: string): Promise<Result<{
1019
1140
  has_seen: boolean;
1020
- }>;
1021
- listUserReports(projectId: number, issueId: string): Promise<UserReport[]>;
1022
- createUserReport(projectId: number, issueId: string, input: CreateUserReport): Promise<UserReport>;
1141
+ }, RustrakError>>;
1142
+ listUserReports(projectId: number, issueId: string): Promise<Result<UserReport[], RustrakError>>;
1143
+ createUserReport(projectId: number, issueId: string, input: CreateUserReport): Promise<Result<UserReport, RustrakError>>;
1023
1144
  }
1024
1145
 
1025
1146
  declare class LogsResource extends BaseResource {
1026
- list(projectId: number, options?: ListLogsOptions): Promise<OffsetPaginatedResponse<Log>>;
1147
+ list(projectId: number, options?: ListLogsOptions): Promise<Result<OffsetPaginatedResponse<Log>, RustrakError>>;
1027
1148
  }
1028
1149
 
1029
1150
  declare class MembersResource extends BaseResource {
1030
- list(projectId: number): Promise<ProjectMember[]>;
1031
- upsert(projectId: number, input: UpsertProjectMember): Promise<void>;
1032
- remove(projectId: number, userId: number): Promise<void>;
1151
+ list(projectId: number): Promise<Result<ProjectMember[], RustrakError>>;
1152
+ upsert(projectId: number, input: UpsertProjectMember): Promise<Result<void, RustrakError>>;
1153
+ remove(projectId: number, userId: number): Promise<Result<void, RustrakError>>;
1033
1154
  }
1034
1155
 
1035
1156
  declare class ProjectsResource extends BaseResource {
1036
- list(options?: ListProjectsOptions): Promise<OffsetPaginatedResponse<Project>>;
1037
- get(id: number): Promise<Project>;
1038
- create(input: CreateProject): Promise<Project>;
1039
- update(id: number, input: UpdateProject): Promise<Project>;
1040
- delete(id: number): Promise<void>;
1157
+ list(options?: ListProjectsOptions): Promise<Result<OffsetPaginatedResponse<Project>, RustrakError>>;
1158
+ get(id: number): Promise<Result<Project, RustrakError>>;
1159
+ create(input: CreateProject): Promise<Result<Project, RustrakError>>;
1160
+ update(id: number, input: UpdateProject): Promise<Result<Project, RustrakError>>;
1161
+ delete(id: number): Promise<Result<void, RustrakError>>;
1041
1162
  }
1042
1163
 
1043
1164
  declare class ReleasesResource extends BaseResource {
1044
- newIssues(projectId: number, release: string, limit?: number): Promise<Issue[]>;
1165
+ newIssues(projectId: number, release: string, limit?: number): Promise<Result<Issue[], RustrakError>>;
1045
1166
  }
1046
1167
 
1047
1168
  declare class SessionsResource extends BaseResource {
1048
- stats(projectId: number, options?: ReleaseHealthStatsOptions): Promise<OffsetPaginatedResponse<ReleaseHealthRow>>;
1049
- summary(projectId: number, period?: string): Promise<SessionSummary>;
1050
- timeseries(projectId: number, period?: string, interval?: number): Promise<SessionTimeseries>;
1169
+ stats(projectId: number, options?: ReleaseHealthStatsOptions): Promise<Result<OffsetPaginatedResponse<ReleaseHealthRow>, RustrakError>>;
1170
+ summary(projectId: number, period?: string): Promise<Result<SessionSummary, RustrakError>>;
1171
+ timeseries(projectId: number, period?: string, interval?: number): Promise<Result<SessionTimeseries, RustrakError>>;
1051
1172
  }
1052
1173
 
1053
1174
  declare class SourceMapsResource extends BaseResource {
1054
- getChunkUploadCapability(orgSlug: string): Promise<ChunkUploadCapability>;
1175
+ getChunkUploadCapability(orgSlug: string): Promise<Result<ChunkUploadCapability, RustrakError>>;
1055
1176
  uploadChunks(orgSlug: string, chunks: {
1056
1177
  hash: string;
1057
1178
  data: Blob;
1058
- }[], chunksPerRequest?: number): Promise<void>;
1059
- assembleBundle(orgSlug: string, input: AssembleInput): Promise<AssembleResponse>;
1060
- list(orgSlug: string, projectSlug: string): Promise<ListSourceMapsResponse>;
1179
+ }[], chunksPerRequest?: number): Promise<Result<void, RustrakError>>;
1180
+ assembleBundle(orgSlug: string, input: AssembleInput): Promise<Result<AssembleResponse, RustrakError>>;
1181
+ list(orgSlug: string, projectSlug: string): Promise<Result<ListSourceMapsResponse, RustrakError>>;
1061
1182
  }
1062
1183
 
1063
1184
  declare class SpansResource extends BaseResource {
1064
- list(projectId: number, options?: ListSpansOptions): Promise<OffsetPaginatedResponse<Span>>;
1185
+ list(projectId: number, options?: ListSpansOptions): Promise<Result<OffsetPaginatedResponse<Span>, RustrakError>>;
1065
1186
  }
1066
1187
 
1067
1188
  declare class StatsResource extends BaseResource {
1068
- timeseries(projectId: number, period?: string, interval?: number): Promise<EventTimeseries>;
1069
- summary(projectId: number, period?: string): Promise<ProjectStatsSummary>;
1189
+ timeseries(projectId: number, period?: string, interval?: number): Promise<Result<EventTimeseries, RustrakError>>;
1190
+ summary(projectId: number, period?: string): Promise<Result<ProjectStatsSummary, RustrakError>>;
1070
1191
  }
1071
1192
 
1072
1193
  declare class StorageResource extends BaseResource {
1073
- getSummary(): Promise<StorageSummary>;
1074
- getProjects(): Promise<ProjectStorage[]>;
1075
- previewCleanup(options: CleanupOptions): Promise<CleanupCounts>;
1076
- executeCleanup(options: CleanupOptions): Promise<CleanupCounts>;
1077
- previewGcSourceMaps(): Promise<SourceMapGcResult>;
1078
- gcSourceMaps(): Promise<SourceMapGcResult>;
1194
+ getSummary(): Promise<Result<StorageSummary, RustrakError>>;
1195
+ getProjects(): Promise<Result<ProjectStorage[], RustrakError>>;
1196
+ previewCleanup(options: CleanupOptions): Promise<Result<CleanupCounts, RustrakError>>;
1197
+ executeCleanup(options: CleanupOptions): Promise<Result<CleanupCounts, RustrakError>>;
1198
+ previewGcSourceMaps(): Promise<Result<SourceMapGcResult, RustrakError>>;
1199
+ gcSourceMaps(): Promise<Result<SourceMapGcResult, RustrakError>>;
1079
1200
  }
1080
1201
 
1081
1202
  declare class TeamResource extends BaseResource {
1082
- list(): Promise<TeamMember[]>;
1083
- updateRole(userId: number, role: GlobalRole): Promise<void>;
1084
- remove(userId: number): Promise<void>;
1203
+ list(): Promise<Result<TeamMember[], RustrakError>>;
1204
+ updateRole(userId: number, role: GlobalRole): Promise<Result<void, RustrakError>>;
1205
+ remove(userId: number): Promise<Result<void, RustrakError>>;
1085
1206
  }
1086
1207
 
1087
1208
  declare class TokensResource extends BaseResource {
1088
- list(): Promise<AuthToken[]>;
1089
- get(id: number): Promise<AuthTokenCreated>;
1090
- create(input: CreateAuthToken): Promise<AuthTokenCreated>;
1091
- delete(id: number): Promise<void>;
1209
+ list(): Promise<Result<AuthToken[], RustrakError>>;
1210
+ get(id: number): Promise<Result<AuthTokenCreated, RustrakError>>;
1211
+ create(input: CreateAuthToken): Promise<Result<AuthTokenCreated, RustrakError>>;
1212
+ delete(id: number): Promise<Result<void, RustrakError>>;
1092
1213
  }
1093
1214
 
1094
1215
  declare class TransactionsResource extends BaseResource {
1095
- list(projectId: number, options?: ListTransactionsOptions): Promise<OffsetPaginatedResponse<Transaction>>;
1096
- getSpans(projectId: number, transactionId: string): Promise<Span[]>;
1216
+ list(projectId: number, options?: ListTransactionsOptions): Promise<Result<OffsetPaginatedResponse<Transaction>, RustrakError>>;
1217
+ getSpans(projectId: number, transactionId: string): Promise<Result<Span[], RustrakError>>;
1097
1218
  getStats(projectId: number, options?: {
1098
1219
  page?: number;
1099
1220
  per_page?: number;
1100
- }): Promise<OffsetPaginatedResponse<TransactionStats>>;
1101
- getStatForGroup(projectId: number, name: string, op?: string): Promise<TransactionStats>;
1102
- get(projectId: number, transactionId: string): Promise<TransactionDetail>;
1221
+ }): Promise<Result<OffsetPaginatedResponse<TransactionStats>, RustrakError>>;
1222
+ getStatForGroup(projectId: number, name: string, op?: string): Promise<Result<TransactionStats, RustrakError>>;
1223
+ get(projectId: number, transactionId: string): Promise<Result<TransactionDetail, RustrakError>>;
1103
1224
  }
1104
1225
 
1105
1226
  declare class RustrakClient {
@@ -1127,44 +1248,4 @@ declare class RustrakClient {
1127
1248
  constructor(config: ClientConfig);
1128
1249
  }
1129
1250
 
1130
- declare class RustrakError extends Error {
1131
- readonly retryable: boolean;
1132
- readonly statusCode?: number;
1133
- readonly cause?: Error;
1134
- constructor(message: string, options?: {
1135
- retryable?: boolean;
1136
- statusCode?: number;
1137
- cause?: Error;
1138
- });
1139
- }
1140
-
1141
- declare class NetworkError extends RustrakError {
1142
- constructor(message: string, cause?: Error);
1143
- }
1144
- declare class AuthenticationError extends RustrakError {
1145
- constructor(message?: string);
1146
- }
1147
- declare class AuthorizationError extends RustrakError {
1148
- constructor(message?: string);
1149
- }
1150
- declare class NotFoundError extends RustrakError {
1151
- constructor(resource: string);
1152
- }
1153
- declare class RateLimitError extends RustrakError {
1154
- readonly retryAfter?: number;
1155
- constructor(message?: string, retryAfter?: string | number);
1156
- }
1157
- declare class ServerError extends RustrakError {
1158
- constructor(message: string, statusCode?: number);
1159
- }
1160
- declare class BadRequestError extends RustrakError {
1161
- constructor(message: string);
1162
- }
1163
-
1164
- declare class ValidationError extends RustrakError {
1165
- readonly validationErrors?: ZodError;
1166
- constructor(message: string, validationErrors?: ZodError);
1167
- getValidationDetails(): string;
1168
- }
1169
-
1170
- export { type AcceptInvitation, type ActivityEntry, type AgentBreakdownOptions, type AgentDurationPoint, type AgentTimeseriesOptions, type AgentTimeseriesPoint, type AgentTraceSummary, type AgentTracesOptions, type AlertHistory, type AlertIntegration, type AlertRule, type AlertRuleChannelInput, type AlertStatus, type AlertType, type ApiError, type AssembleInput, type AssembleResponse, type AuthResponse, type AuthToken, type AuthTokenCreated, AuthenticationError, AuthorizationError, BadRequestError, type BulkDeleteIssues, type BulkUpdateIssues, type ChannelType, type ChunkUploadCapability, type CleanupCounts, type CleanupOptions, type ClientConfig, type CreateAlertIntegration, type CreateAlertRule, type CreateAuthToken, type CreateComment, type CreateInvitation, type CreateNotificationChannel, type CreateProject, type CreateUserReport, type Event, type EventDetail, type EventTimeseries, type EventTimeseriesPoint, type GenAiBreakdownRow, type GlobalRole, type Invitation, type InvitationInfo, type Issue, type IssueAggregates, type IssueFilter, type IssueHash, type IssuePriority, type IssueSort, type IssueStats, type IssueStatsWindow, type IssueStatus, type IssueTagValue, type ListAlertHistoryOptions, type ListEventsOptions, type ListIssuesOptions, type ListLogsOptions, type ListProjectsOptions, type ListSourceMapsResponse, type ListSpansOptions, type ListTransactionsOptions, type Log, type LoginRequest, type LoginResult, type MetricDelta, NetworkError, NotFoundError, type NotificationChannel, type OffsetPaginatedResponse, type PaginatedResponse, type Project, type ProjectMember, type ProjectRole, type ProjectStatsSummary, type ProjectStorage, type ProviderType, RateLimitError, type RegisterRequest, type ReleaseHealthRow, type ReleaseHealthStatsOptions, type RoutingOverride, RustrakClient, RustrakError, ServerError, type ServerVersion, type SessionSummary, type SessionTimeseries, type SessionTimeseriesPoint, type SortOrder, type SourceMapFile, type SourceMapGcResult, type SourceMapStorage, type Span, type StorageSummary, type TagSummary, type TagValueCount, type TeamMember, type TestChannelResponse, type TestIntegrationBody, type Transaction, type TransactionDetail, type TransactionStats, type UpdateAlertIntegration, type UpdateAlertRule, type UpdateIssueState, type UpdateNotificationChannel, type UpdateProject, type UpdateUserRole, type UpsertProjectMember, type User, type UserReport, ValidationError };
1251
+ export { type AcceptInvitation, type ActivityEntry, type AgentBreakdownOptions, type AgentDurationPoint, type AgentTimeseriesOptions, type AgentTimeseriesPoint, type AgentTraceSummary, type AgentTracesOptions, type AlertHistory, type AlertIntegration, type AlertRule, type AlertRuleChannelInput, type AlertStatus, type AlertType, type ApiError, type AssembleInput, type AssembleResponse, type AuthResponse, type AuthToken, type AuthTokenCreated, type BulkDeleteIssues, type BulkUpdateIssues, type ChunkUploadCapability, type CleanupCounts, type CleanupOptions, type ClientConfig, type CreateAlertIntegration, type CreateAlertRule, type CreateAuthToken, type CreateComment, type CreateInvitation, type CreateProject, type CreateUserReport, Err, type Event, type EventDetail, type EventTimeseries, type EventTimeseriesPoint, FIELD_ERROR_CODES, type FieldError, type FieldErrorCode, type GenAiBreakdownRow, type GlobalRole, type Invitation, type InvitationInfo, type Issue, type IssueAggregates, type IssueFilter, type IssueHash, type IssuePriority, type IssueSort, type IssueStats, type IssueStatsWindow, type IssueStatus, type IssueTagValue, type ListAlertHistoryOptions, type ListEventsOptions, type ListIssuesOptions, type ListLogsOptions, type ListProjectsOptions, type ListSourceMapsResponse, type ListSpansOptions, type ListTransactionsOptions, type Log, type LoginRequest, type LoginResult, type MetricDelta, NETWORK_ERROR_MESSAGE, type OffsetPaginatedResponse, Ok, type PaginatedResponse, type Project, type ProjectListStats, type ProjectMember, type ProjectRole, type ProjectStatsSummary, type ProjectStorage, type ProviderType, type RegisterRequest, type ReleaseHealthRow, type ReleaseHealthStatsOptions, type Result, type RoutingOverride, RustrakClient, type RustrakError, type RustrakErrorKind, SERVER_ERROR_MESSAGE, type ServerVersion, type SessionSummary, type SessionTimeseries, type SessionTimeseriesPoint, type SortOrder, type SourceMapFile, type SourceMapGcResult, type SourceMapStorage, type Span, type StorageSummary, TIMEOUT_ERROR_MESSAGE, type TagSummary, type TagValueCount, type TeamMember, type TestChannelResponse, type TestIntegrationBody, type Transaction, type TransactionDetail, type TransactionStats, type UpdateAlertIntegration, type UpdateAlertRule, type UpdateIssueState, type UpdateProject, type UpdateUserRole, type UpsertProjectMember, type User, type UserReport, isRetryable, mapResult, unwrap, unwrapOr };