@rustrak/client 0.13.0 → 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>;
@@ -668,6 +752,11 @@ declare const chunkUploadCapabilitySchema: z.ZodObject<{
668
752
  accept: z.ZodArray<z.ZodString>;
669
753
  concurrency: z.ZodOptional<z.ZodNumber>;
670
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>;
671
760
  declare const assembleResponseSchema: z.ZodObject<{
672
761
  state: z.ZodString;
673
762
  missingChunks: z.ZodArray<z.ZodString>;
@@ -694,11 +783,7 @@ type ChunkUploadCapability = z.infer<typeof chunkUploadCapabilitySchema>;
694
783
  type AssembleResponse = z.infer<typeof assembleResponseSchema>;
695
784
  type SourceMapFile = z.infer<typeof sourceMapFileSchema>;
696
785
  type ListSourceMapsResponse = z.infer<typeof listSourceMapsResponseSchema>;
697
- interface AssembleInput {
698
- checksum: string;
699
- chunks: string[];
700
- projects: string[];
701
- }
786
+ type AssembleInput = z.infer<typeof assembleInputSchema>;
702
787
 
703
788
  declare const eventTimeseriesPointSchema: z.ZodObject<{
704
789
  bucket: z.ZodString;
@@ -967,169 +1052,175 @@ type RegisterRequest = z.infer<typeof registerRequestSchema>;
967
1052
  declare abstract class BaseResource {
968
1053
  protected readonly http: KyInstance;
969
1054
  constructor(http: KyInstance);
970
- 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>>;
971
1061
  }
972
1062
 
973
1063
  declare class AgentsResource extends BaseResource {
974
- getRuns(projectId: number, options?: AgentTimeseriesOptions): Promise<AgentTimeseriesPoint[]>;
975
- getDuration(projectId: number, options?: AgentTimeseriesOptions): Promise<AgentDurationPoint[]>;
976
- getModelsByCalls(projectId: number, options?: AgentBreakdownOptions): Promise<GenAiBreakdownRow[]>;
977
- getModelsByTokens(projectId: number, options?: AgentBreakdownOptions): Promise<GenAiBreakdownRow[]>;
978
- getTools(projectId: number, options?: AgentBreakdownOptions): Promise<GenAiBreakdownRow[]>;
979
- 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>>;
980
1070
  }
981
1071
 
982
1072
  declare class AlertIntegrationsResource extends BaseResource {
983
- list(): Promise<AlertIntegration[]>;
984
- get(id: number): Promise<AlertIntegration>;
985
- create(input: CreateAlertIntegration): Promise<AlertIntegration>;
986
- update(id: number, input: UpdateAlertIntegration): Promise<AlertIntegration>;
987
- delete(id: number): Promise<void>;
988
- 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>>;
989
1079
  }
990
1080
 
991
1081
  declare class AlertRulesResource extends BaseResource {
992
- list(projectId: number): Promise<AlertRule[]>;
993
- get(projectId: number, ruleId: number): Promise<AlertRule>;
994
- create(projectId: number, input: CreateAlertRule): Promise<AlertRule>;
995
- update(projectId: number, ruleId: number, input: UpdateAlertRule): Promise<AlertRule>;
996
- delete(projectId: number, ruleId: number): Promise<void>;
997
- 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>>;
998
1088
  }
999
1089
 
1000
1090
  declare class AuthResource extends BaseResource {
1001
- register(credentials: RegisterRequest): Promise<LoginResult>;
1002
- login(credentials: LoginRequest): Promise<LoginResult>;
1003
- logout(): Promise<string[]>;
1004
- getCurrentUser(): Promise<User>;
1005
- getInvitation(token: string): Promise<InvitationInfo>;
1006
- 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;
1007
1098
  }
1008
1099
 
1009
1100
  declare class EventsResource extends BaseResource {
1010
- list(projectId: number, issueId: string, options?: ListEventsOptions): Promise<PaginatedResponse<Event>>;
1011
- 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>>;
1012
1103
  }
1013
1104
 
1014
1105
  declare class HealthResource extends BaseResource {
1015
- getVersion(): Promise<ServerVersion>;
1106
+ getVersion(): Promise<Result<ServerVersion, RustrakError>>;
1016
1107
  }
1017
1108
 
1018
1109
  declare class InvitationsResource extends BaseResource {
1019
- create(input: CreateInvitation): Promise<Invitation>;
1020
- list(): Promise<Invitation[]>;
1021
- 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>>;
1022
1113
  }
1023
1114
 
1024
1115
  declare class IssuesResource extends BaseResource {
1025
- list(projectId: number, options?: ListIssuesOptions): Promise<OffsetPaginatedResponse<Issue>>;
1026
- get(projectId: number, issueId: string): Promise<Issue>;
1027
- updateState(projectId: number, issueId: string, input: UpdateIssueState): Promise<Issue>;
1028
- resolveInNextRelease(projectId: number, issueId: string): Promise<Issue>;
1029
- delete(projectId: number, issueId: string): Promise<void>;
1030
- 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<{
1031
1122
  updated: number;
1032
- }>;
1033
- bulkDelete(projectId: number, input: BulkDeleteIssues): Promise<{
1123
+ }, RustrakError>>;
1124
+ bulkDelete(projectId: number, input: BulkDeleteIssues): Promise<Result<{
1034
1125
  deleted: number;
1035
- }>;
1036
- getHashes(projectId: number, issueId: string): Promise<IssueHash[]>;
1037
- getTagValues(projectId: number, issueId: string, key: string): Promise<IssueTagValue[]>;
1038
- getAggregates(projectId: number, issueId: string): Promise<IssueAggregates>;
1039
- getStats(projectId: number, issueId: string, window?: IssueStatsWindow): Promise<IssueStats>;
1040
- getActivity(projectId: number, issueId: string): Promise<ActivityEntry[]>;
1041
- addComment(projectId: number, issueId: string, input: CreateComment): Promise<ActivityEntry>;
1042
- 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<{
1043
1134
  is_bookmarked: boolean;
1044
- }>;
1045
- setSubscription(projectId: number, issueId: string, enabled: boolean): Promise<{
1135
+ }, RustrakError>>;
1136
+ setSubscription(projectId: number, issueId: string, enabled: boolean): Promise<Result<{
1046
1137
  is_subscribed: boolean;
1047
- }>;
1048
- markSeen(projectId: number, issueId: string): Promise<{
1138
+ }, RustrakError>>;
1139
+ markSeen(projectId: number, issueId: string): Promise<Result<{
1049
1140
  has_seen: boolean;
1050
- }>;
1051
- listUserReports(projectId: number, issueId: string): Promise<UserReport[]>;
1052
- 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>>;
1053
1144
  }
1054
1145
 
1055
1146
  declare class LogsResource extends BaseResource {
1056
- list(projectId: number, options?: ListLogsOptions): Promise<OffsetPaginatedResponse<Log>>;
1147
+ list(projectId: number, options?: ListLogsOptions): Promise<Result<OffsetPaginatedResponse<Log>, RustrakError>>;
1057
1148
  }
1058
1149
 
1059
1150
  declare class MembersResource extends BaseResource {
1060
- list(projectId: number): Promise<ProjectMember[]>;
1061
- upsert(projectId: number, input: UpsertProjectMember): Promise<void>;
1062
- 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>>;
1063
1154
  }
1064
1155
 
1065
1156
  declare class ProjectsResource extends BaseResource {
1066
- list(options?: ListProjectsOptions): Promise<OffsetPaginatedResponse<Project>>;
1067
- get(id: number): Promise<Project>;
1068
- create(input: CreateProject): Promise<Project>;
1069
- update(id: number, input: UpdateProject): Promise<Project>;
1070
- 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>>;
1071
1162
  }
1072
1163
 
1073
1164
  declare class ReleasesResource extends BaseResource {
1074
- newIssues(projectId: number, release: string, limit?: number): Promise<Issue[]>;
1165
+ newIssues(projectId: number, release: string, limit?: number): Promise<Result<Issue[], RustrakError>>;
1075
1166
  }
1076
1167
 
1077
1168
  declare class SessionsResource extends BaseResource {
1078
- stats(projectId: number, options?: ReleaseHealthStatsOptions): Promise<OffsetPaginatedResponse<ReleaseHealthRow>>;
1079
- summary(projectId: number, period?: string): Promise<SessionSummary>;
1080
- 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>>;
1081
1172
  }
1082
1173
 
1083
1174
  declare class SourceMapsResource extends BaseResource {
1084
- getChunkUploadCapability(orgSlug: string): Promise<ChunkUploadCapability>;
1175
+ getChunkUploadCapability(orgSlug: string): Promise<Result<ChunkUploadCapability, RustrakError>>;
1085
1176
  uploadChunks(orgSlug: string, chunks: {
1086
1177
  hash: string;
1087
1178
  data: Blob;
1088
- }[], chunksPerRequest?: number): Promise<void>;
1089
- assembleBundle(orgSlug: string, input: AssembleInput): Promise<AssembleResponse>;
1090
- 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>>;
1091
1182
  }
1092
1183
 
1093
1184
  declare class SpansResource extends BaseResource {
1094
- list(projectId: number, options?: ListSpansOptions): Promise<OffsetPaginatedResponse<Span>>;
1185
+ list(projectId: number, options?: ListSpansOptions): Promise<Result<OffsetPaginatedResponse<Span>, RustrakError>>;
1095
1186
  }
1096
1187
 
1097
1188
  declare class StatsResource extends BaseResource {
1098
- timeseries(projectId: number, period?: string, interval?: number): Promise<EventTimeseries>;
1099
- 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>>;
1100
1191
  }
1101
1192
 
1102
1193
  declare class StorageResource extends BaseResource {
1103
- getSummary(): Promise<StorageSummary>;
1104
- getProjects(): Promise<ProjectStorage[]>;
1105
- previewCleanup(options: CleanupOptions): Promise<CleanupCounts>;
1106
- executeCleanup(options: CleanupOptions): Promise<CleanupCounts>;
1107
- previewGcSourceMaps(): Promise<SourceMapGcResult>;
1108
- 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>>;
1109
1200
  }
1110
1201
 
1111
1202
  declare class TeamResource extends BaseResource {
1112
- list(): Promise<TeamMember[]>;
1113
- updateRole(userId: number, role: GlobalRole): Promise<void>;
1114
- 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>>;
1115
1206
  }
1116
1207
 
1117
1208
  declare class TokensResource extends BaseResource {
1118
- list(): Promise<AuthToken[]>;
1119
- get(id: number): Promise<AuthTokenCreated>;
1120
- create(input: CreateAuthToken): Promise<AuthTokenCreated>;
1121
- 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>>;
1122
1213
  }
1123
1214
 
1124
1215
  declare class TransactionsResource extends BaseResource {
1125
- list(projectId: number, options?: ListTransactionsOptions): Promise<OffsetPaginatedResponse<Transaction>>;
1126
- 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>>;
1127
1218
  getStats(projectId: number, options?: {
1128
1219
  page?: number;
1129
1220
  per_page?: number;
1130
- }): Promise<OffsetPaginatedResponse<TransactionStats>>;
1131
- getStatForGroup(projectId: number, name: string, op?: string): Promise<TransactionStats>;
1132
- 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>>;
1133
1224
  }
1134
1225
 
1135
1226
  declare class RustrakClient {
@@ -1157,44 +1248,4 @@ declare class RustrakClient {
1157
1248
  constructor(config: ClientConfig);
1158
1249
  }
1159
1250
 
1160
- declare class RustrakError extends Error {
1161
- readonly retryable: boolean;
1162
- readonly statusCode?: number;
1163
- readonly cause?: Error;
1164
- constructor(message: string, options?: {
1165
- retryable?: boolean;
1166
- statusCode?: number;
1167
- cause?: Error;
1168
- });
1169
- }
1170
-
1171
- declare class NetworkError extends RustrakError {
1172
- constructor(message: string, cause?: Error);
1173
- }
1174
- declare class AuthenticationError extends RustrakError {
1175
- constructor(message?: string);
1176
- }
1177
- declare class AuthorizationError extends RustrakError {
1178
- constructor(message?: string);
1179
- }
1180
- declare class NotFoundError extends RustrakError {
1181
- constructor(resource: string);
1182
- }
1183
- declare class RateLimitError extends RustrakError {
1184
- readonly retryAfter?: number;
1185
- constructor(message?: string, retryAfter?: string | number);
1186
- }
1187
- declare class ServerError extends RustrakError {
1188
- constructor(message: string, statusCode?: number);
1189
- }
1190
- declare class BadRequestError extends RustrakError {
1191
- constructor(message: string);
1192
- }
1193
-
1194
- declare class ValidationError extends RustrakError {
1195
- readonly validationErrors?: ZodError;
1196
- constructor(message: string, validationErrors?: ZodError);
1197
- getValidationDetails(): string;
1198
- }
1199
-
1200
- 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 ProjectListStats, 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 };