@rustrak/client 0.18.0 → 0.19.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.
Files changed (119) hide show
  1. package/README.md +312 -123
  2. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  3. package/dist/client.cjs +86 -0
  4. package/dist/client.cjs.map +1 -0
  5. package/dist/client.d.cts +18 -0
  6. package/dist/client.d.cts.map +1 -0
  7. package/dist/client.d.mts +18 -0
  8. package/dist/client.d.mts.map +1 -0
  9. package/dist/client.mjs +86 -0
  10. package/dist/client.mjs.map +1 -0
  11. package/dist/config.d.cts +10 -0
  12. package/dist/config.d.cts.map +1 -0
  13. package/dist/config.d.mts +10 -0
  14. package/dist/config.d.mts.map +1 -0
  15. package/dist/errors.cjs +52 -0
  16. package/dist/errors.cjs.map +1 -0
  17. package/dist/errors.d.cts +77 -0
  18. package/dist/errors.d.cts.map +1 -0
  19. package/dist/errors.d.mts +77 -0
  20. package/dist/errors.d.mts.map +1 -0
  21. package/dist/errors.mjs +48 -0
  22. package/dist/errors.mjs.map +1 -0
  23. package/dist/generated/client/client.gen.cjs +174 -0
  24. package/dist/generated/client/client.gen.cjs.map +1 -0
  25. package/dist/generated/client/client.gen.mjs +174 -0
  26. package/dist/generated/client/client.gen.mjs.map +1 -0
  27. package/dist/generated/client/types.gen.d.cts +71 -0
  28. package/dist/generated/client/types.gen.d.cts.map +1 -0
  29. package/dist/generated/client/types.gen.d.mts +71 -0
  30. package/dist/generated/client/types.gen.d.mts.map +1 -0
  31. package/dist/generated/client/utils.gen.cjs +184 -0
  32. package/dist/generated/client/utils.gen.cjs.map +1 -0
  33. package/dist/generated/client/utils.gen.d.cts +21 -0
  34. package/dist/generated/client/utils.gen.d.cts.map +1 -0
  35. package/dist/generated/client/utils.gen.d.mts +21 -0
  36. package/dist/generated/client/utils.gen.d.mts.map +1 -0
  37. package/dist/generated/client/utils.gen.mjs +177 -0
  38. package/dist/generated/client/utils.gen.mjs.map +1 -0
  39. package/dist/generated/client.gen.cjs +7 -0
  40. package/dist/generated/client.gen.cjs.map +1 -0
  41. package/dist/generated/client.gen.mjs +8 -0
  42. package/dist/generated/client.gen.mjs.map +1 -0
  43. package/dist/generated/core/auth.gen.cjs +12 -0
  44. package/dist/generated/core/auth.gen.cjs.map +1 -0
  45. package/dist/generated/core/auth.gen.d.cts +11 -0
  46. package/dist/generated/core/auth.gen.d.cts.map +1 -0
  47. package/dist/generated/core/auth.gen.d.mts +11 -0
  48. package/dist/generated/core/auth.gen.d.mts.map +1 -0
  49. package/dist/generated/core/auth.gen.mjs +12 -0
  50. package/dist/generated/core/auth.gen.mjs.map +1 -0
  51. package/dist/generated/core/bodySerializer.gen.cjs +21 -0
  52. package/dist/generated/core/bodySerializer.gen.cjs.map +1 -0
  53. package/dist/generated/core/bodySerializer.gen.d.cts +15 -0
  54. package/dist/generated/core/bodySerializer.gen.d.cts.map +1 -0
  55. package/dist/generated/core/bodySerializer.gen.d.mts +15 -0
  56. package/dist/generated/core/bodySerializer.gen.d.mts.map +1 -0
  57. package/dist/generated/core/bodySerializer.gen.mjs +20 -0
  58. package/dist/generated/core/bodySerializer.gen.mjs.map +1 -0
  59. package/dist/generated/core/pathSerializer.gen.cjs +87 -0
  60. package/dist/generated/core/pathSerializer.gen.cjs.map +1 -0
  61. package/dist/generated/core/pathSerializer.gen.d.cts +9 -0
  62. package/dist/generated/core/pathSerializer.gen.d.cts.map +1 -0
  63. package/dist/generated/core/pathSerializer.gen.d.mts +9 -0
  64. package/dist/generated/core/pathSerializer.gen.d.mts.map +1 -0
  65. package/dist/generated/core/pathSerializer.gen.mjs +82 -0
  66. package/dist/generated/core/pathSerializer.gen.mjs.map +1 -0
  67. package/dist/generated/core/serverSentEvents.gen.cjs +96 -0
  68. package/dist/generated/core/serverSentEvents.gen.cjs.map +1 -0
  69. package/dist/generated/core/serverSentEvents.gen.d.cts +25 -0
  70. package/dist/generated/core/serverSentEvents.gen.d.cts.map +1 -0
  71. package/dist/generated/core/serverSentEvents.gen.d.mts +25 -0
  72. package/dist/generated/core/serverSentEvents.gen.d.mts.map +1 -0
  73. package/dist/generated/core/serverSentEvents.gen.mjs +96 -0
  74. package/dist/generated/core/serverSentEvents.gen.mjs.map +1 -0
  75. package/dist/generated/core/types.gen.d.cts +27 -0
  76. package/dist/generated/core/types.gen.d.cts.map +1 -0
  77. package/dist/generated/core/types.gen.d.mts +27 -0
  78. package/dist/generated/core/types.gen.d.mts.map +1 -0
  79. package/dist/generated/core/utils.gen.cjs +81 -0
  80. package/dist/generated/core/utils.gen.cjs.map +1 -0
  81. package/dist/generated/core/utils.gen.mjs +78 -0
  82. package/dist/generated/core/utils.gen.mjs.map +1 -0
  83. package/dist/generated/sdk.gen.cjs +3138 -0
  84. package/dist/generated/sdk.gen.cjs.map +1 -0
  85. package/dist/generated/sdk.gen.d.cts +276 -0
  86. package/dist/generated/sdk.gen.d.cts.map +1 -0
  87. package/dist/generated/sdk.gen.d.mts +276 -0
  88. package/dist/generated/sdk.gen.d.mts.map +1 -0
  89. package/dist/generated/sdk.gen.mjs +3110 -0
  90. package/dist/generated/sdk.gen.mjs.map +1 -0
  91. package/dist/generated/types.gen.d.cts +3679 -0
  92. package/dist/generated/types.gen.d.cts.map +1 -0
  93. package/dist/generated/types.gen.d.mts +3679 -0
  94. package/dist/generated/types.gen.d.mts.map +1 -0
  95. package/dist/generated/zod.gen.cjs +3076 -0
  96. package/dist/generated/zod.gen.cjs.map +1 -0
  97. package/dist/generated/zod.gen.mjs +2618 -0
  98. package/dist/generated/zod.gen.mjs.map +1 -0
  99. package/dist/index.cjs +15 -3248
  100. package/dist/index.d.cts +6 -2037
  101. package/dist/index.d.mts +6 -0
  102. package/dist/index.mjs +4 -0
  103. package/dist/result.cjs +59 -0
  104. package/dist/result.cjs.map +1 -0
  105. package/dist/result.d.cts +15 -0
  106. package/dist/result.d.cts.map +1 -0
  107. package/dist/result.d.mts +15 -0
  108. package/dist/result.d.mts.map +1 -0
  109. package/dist/result.mjs +55 -0
  110. package/dist/result.mjs.map +1 -0
  111. package/dist/utils/http.cjs +339 -0
  112. package/dist/utils/http.cjs.map +1 -0
  113. package/dist/utils/http.mjs +336 -0
  114. package/dist/utils/http.mjs.map +1 -0
  115. package/package.json +17 -12
  116. package/dist/index.cjs.map +0 -1
  117. package/dist/index.d.ts +0 -2037
  118. package/dist/index.js +0 -3232
  119. package/dist/index.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,3248 +1,15 @@
1
- 'use strict';
2
-
3
- var zod = require('zod');
4
- var ky = require('ky');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var ky__default = /*#__PURE__*/_interopDefault(ky);
9
-
10
- // src/resources/agents.ts
11
- var paginatedResponseSchema = (itemSchema) => zod.z.object({
12
- items: zod.z.array(itemSchema),
13
- next_cursor: zod.z.string().optional(),
14
- has_more: zod.z.boolean()
15
- });
16
- var offsetPaginatedResponseSchema = (itemSchema) => zod.z.object({
17
- items: zod.z.array(itemSchema),
18
- total_count: zod.z.number().int(),
19
- page: zod.z.number().int(),
20
- per_page: zod.z.number().int(),
21
- total_pages: zod.z.number().int()
22
- });
23
- zod.z.enum(["asc", "desc"]);
24
- zod.z.enum([
25
- "digest_order",
26
- "last_seen",
27
- "event_count"
28
- ]);
29
- var issueFilterSchema = zod.z.enum(["open", "resolved", "muted", "all"]);
30
- var dateTimeSchema = zod.z.string().datetime();
31
- var uuidSchema = zod.z.string().uuid();
32
- var eventIdSchema = zod.z.string().regex(
33
- /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
34
- "Invalid event id"
35
- );
36
- zod.z.object({
37
- error: zod.z.string(),
38
- message: zod.z.string().optional()
39
- });
40
-
41
- // src/schemas/agent.ts
42
- var agentTimeseriesPointSchema = zod.z.object({
43
- bucket: dateTimeSchema,
44
- value: zod.z.number()
45
- });
46
- var agentDurationPointSchema = zod.z.object({
47
- bucket: dateTimeSchema,
48
- avg_ms: zod.z.number(),
49
- p95_ms: zod.z.number()
50
- });
51
- var genAiBreakdownRowSchema = zod.z.object({
52
- label: zod.z.string(),
53
- value: zod.z.number()
54
- });
55
- var agentTraceSummarySchema = zod.z.object({
56
- trace_id: zod.z.string(),
57
- /** Every distinct agent that ran in this trace, earliest first. */
58
- agent_names: zod.z.array(zod.z.string()),
59
- duration_ms: zod.z.number().nullable(),
60
- total_tokens: zod.z.number(),
61
- tool_call_count: zod.z.number().int(),
62
- /** `ai_client` spans: how many times a model was actually called. */
63
- llm_call_count: zod.z.number().int(),
64
- /** AI spans in this trace whose status is set and not `ok`. */
65
- error_count: zod.z.number().int(),
66
- started_at: dateTimeSchema
67
- });
68
- var agentSummarySchema = zod.z.object({
69
- agent_runs: zod.z.number().int(),
70
- llm_calls: zod.z.number().int(),
71
- tool_calls: zod.z.number().int(),
72
- error_count: zod.z.number().int(),
73
- total_tokens: zod.z.number(),
74
- avg_duration_ms: zod.z.number(),
75
- p95_duration_ms: zod.z.number()
76
- });
77
- var agentModelRowSchema = zod.z.object({
78
- model: zod.z.string(),
79
- requests: zod.z.number().int(),
80
- errors: zod.z.number().int(),
81
- avg_ms: zod.z.number(),
82
- p95_ms: zod.z.number(),
83
- input_tokens: zod.z.number(),
84
- cached_input_tokens: zod.z.number(),
85
- output_tokens: zod.z.number(),
86
- reasoning_output_tokens: zod.z.number(),
87
- total_tokens: zod.z.number()
88
- });
89
- var agentToolRowSchema = zod.z.object({
90
- tool: zod.z.string(),
91
- calls: zod.z.number().int(),
92
- errors: zod.z.number().int(),
93
- avg_ms: zod.z.number(),
94
- p95_ms: zod.z.number()
95
- });
96
- var providerTypeSchema = zod.z.enum([
97
- "webhook",
98
- "email",
99
- "slack",
100
- "custom_webhook"
101
- ]);
102
- var alertTypeSchema = zod.z.enum(["new_issue", "regression", "unmute"]);
103
- var alertStatusSchema = zod.z.enum([
104
- "pending",
105
- "sent",
106
- "failed",
107
- "skipped"
108
- ]);
109
- var alertIntegrationSchema = zod.z.object({
110
- id: zod.z.number().int(),
111
- name: zod.z.string(),
112
- provider_type: providerTypeSchema,
113
- credentials: zod.z.record(zod.z.string(), zod.z.unknown()),
114
- is_enabled: zod.z.boolean(),
115
- failure_count: zod.z.number().int(),
116
- last_failure_at: dateTimeSchema.nullable(),
117
- last_failure_message: zod.z.string().nullable(),
118
- last_success_at: dateTimeSchema.nullable(),
119
- created_at: dateTimeSchema,
120
- updated_at: dateTimeSchema
121
- });
122
- var createAlertIntegrationSchema = zod.z.object({
123
- name: zod.z.string().min(1),
124
- provider_type: providerTypeSchema,
125
- credentials: zod.z.record(zod.z.string(), zod.z.unknown()),
126
- is_enabled: zod.z.boolean().optional()
127
- });
128
- var updateAlertIntegrationSchema = zod.z.object({
129
- name: zod.z.string().min(1).optional(),
130
- credentials: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
131
- is_enabled: zod.z.boolean().optional()
132
- });
133
- var alertRuleChannelInputSchema = zod.z.object({
134
- integration_id: zod.z.number().int(),
135
- routing_override: zod.z.record(zod.z.string(), zod.z.unknown()).default({})
136
- });
137
- var alertRuleConditionsSchema = zod.z.object({
138
- /** The quietest level that still fires. The server takes `null` as absent. */
139
- min_level: zod.z.enum(["debug", "info", "warning", "error", "fatal"]).nullish(),
140
- /** When non-empty, the only environments that fire. */
141
- environments: zod.z.array(zod.z.string()).optional(),
142
- /** A new issue fires when it reaches this many events, not on its first. */
143
- min_events: zod.z.number().int().min(1).nullish()
144
- });
145
- var alertRuleSchema = zod.z.object({
146
- id: zod.z.number().int(),
147
- project_id: zod.z.number().int(),
148
- name: zod.z.string(),
149
- alert_type: alertTypeSchema,
150
- is_enabled: zod.z.boolean(),
151
- // A rule stored before the filters existed may hold any object. The server
152
- // evaluates one it cannot read as no filters; one bad row must not fail the
153
- // whole list either.
154
- conditions: alertRuleConditionsSchema.catch({}),
155
- cooldown_minutes: zod.z.number().int(),
156
- last_triggered_at: dateTimeSchema.nullable(),
157
- created_at: dateTimeSchema,
158
- updated_at: dateTimeSchema,
159
- channels: zod.z.array(alertRuleChannelInputSchema).default([]),
160
- integration_ids: zod.z.array(zod.z.number().int())
161
- });
162
- var createAlertRuleSchema = zod.z.object({
163
- name: zod.z.string().min(1),
164
- alert_type: alertTypeSchema,
165
- channels: zod.z.array(alertRuleChannelInputSchema).default([]),
166
- is_enabled: zod.z.boolean().optional(),
167
- conditions: alertRuleConditionsSchema.optional(),
168
- cooldown_minutes: zod.z.number().int().min(0).optional()
169
- });
170
- var updateAlertRuleSchema = zod.z.object({
171
- name: zod.z.string().min(1).optional(),
172
- is_enabled: zod.z.boolean().optional(),
173
- conditions: alertRuleConditionsSchema.optional(),
174
- cooldown_minutes: zod.z.number().int().min(0).optional(),
175
- channels: zod.z.array(alertRuleChannelInputSchema).optional()
176
- });
177
- var alertHistorySchema = zod.z.object({
178
- id: zod.z.number().int(),
179
- alert_rule_id: zod.z.number().int().nullable(),
180
- integration_id: zod.z.number().int().nullable(),
181
- issue_id: zod.z.string().uuid().nullable(),
182
- project_id: zod.z.number().int().nullable(),
183
- alert_type: zod.z.string(),
184
- channel_type: zod.z.string(),
185
- channel_name: zod.z.string(),
186
- status: alertStatusSchema,
187
- attempt_count: zod.z.number().int(),
188
- next_retry_at: dateTimeSchema.nullable(),
189
- error_message: zod.z.string().nullable(),
190
- http_status_code: zod.z.number().int().nullable(),
191
- idempotency_key: zod.z.string(),
192
- created_at: dateTimeSchema,
193
- sent_at: dateTimeSchema.nullable()
194
- });
195
- var testChannelResponseSchema = zod.z.object({
196
- success: zod.z.boolean(),
197
- message: zod.z.string(),
198
- /**
199
- * What the endpoint answered, when it answered anything.
200
- *
201
- * Delivery is judged by the HTTP status and the body is not interpreted, so
202
- * the body is handed back instead: a group bot that refuses a message still
203
- * answers 200 and explains itself here.
204
- */
205
- response_body: zod.z.string().nullish()
206
- });
207
- var previewTemplateResponseSchema = zod.z.object({
208
- ok: zod.z.boolean(),
209
- rendered: zod.z.string().nullish(),
210
- error: zod.z.string().nullish()
211
- });
212
- var testIntegrationBodySchema = zod.z.object({
213
- routing_override: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
214
- });
215
- var eventSchema = zod.z.object({
216
- id: uuidSchema,
217
- event_id: eventIdSchema,
218
- issue_id: uuidSchema.nullable(),
219
- title: zod.z.string(),
220
- timestamp: dateTimeSchema,
221
- level: zod.z.string(),
222
- platform: zod.z.string(),
223
- release: zod.z.string(),
224
- environment: zod.z.string(),
225
- event_type: zod.z.string()
226
- });
227
- var eventDetailSchema = zod.z.object({
228
- id: uuidSchema,
229
- event_id: eventIdSchema,
230
- issue_id: uuidSchema.nullable(),
231
- title: zod.z.string(),
232
- timestamp: dateTimeSchema,
233
- ingested_at: dateTimeSchema,
234
- level: zod.z.string(),
235
- platform: zod.z.string(),
236
- release: zod.z.string(),
237
- environment: zod.z.string(),
238
- server_name: zod.z.string(),
239
- sdk_name: zod.z.string(),
240
- sdk_version: zod.z.string(),
241
- event_type: zod.z.string(),
242
- data: zod.z.record(zod.z.string(), zod.z.any())
243
- // Full Sentry event JSON
244
- });
245
- var gitHubAppSchema = zod.z.object({
246
- app_id: zod.z.number().int(),
247
- slug: zod.z.string(),
248
- html_url: zod.z.string(),
249
- owner_login: zod.z.string(),
250
- install_url: zod.z.string(),
251
- last_webhook_at: dateTimeSchema.nullable(),
252
- created_at: dateTimeSchema
253
- });
254
- var gitHubInstallationSchema = zod.z.object({
255
- id: zod.z.number().int(),
256
- account_login: zod.z.string(),
257
- account_type: zod.z.string(),
258
- suspended: zod.z.boolean(),
259
- created_at: dateTimeSchema
260
- });
261
- var gitHubStatusSchema = zod.z.object({
262
- app: gitHubAppSchema.nullable(),
263
- installations: zod.z.array(gitHubInstallationSchema),
264
- webhook_url: zod.z.string()
265
- });
266
- var gitHubManifestSchema = zod.z.object({
267
- action_url: zod.z.string(),
268
- manifest: zod.z.string()
269
- });
270
- var gitHubRepositorySchema = zod.z.object({
271
- installation_id: zod.z.number().int(),
272
- full_name: zod.z.string(),
273
- default_branch: zod.z.string(),
274
- private: zod.z.boolean(),
275
- html_url: zod.z.string()
276
- });
277
- var codeMappingSchema = zod.z.object({
278
- stack_root: zod.z.string(),
279
- source_root: zod.z.string()
280
- });
281
- var projectRepositorySchema = zod.z.object({
282
- project_id: zod.z.number().int(),
283
- installation_id: zod.z.number().int(),
284
- repo_full_name: zod.z.string(),
285
- default_branch: zod.z.string(),
286
- html_url: zod.z.string(),
287
- code_mappings: zod.z.array(codeMappingSchema),
288
- /** Open a GitHub issue for new issues that pass `auto_create_conditions`. */
289
- auto_create_issues: zod.z.boolean(),
290
- auto_create_conditions: alertRuleConditionsSchema,
291
- codeowners_rules: zod.z.number().int().nullable(),
292
- codeowners_synced_at: dateTimeSchema.nullable()
293
- });
294
- var updateProjectRepositorySchema = zod.z.object({
295
- installation_id: zod.z.number().int(),
296
- repo_full_name: zod.z.string().min(1),
297
- code_mappings: zod.z.array(codeMappingSchema).optional(),
298
- auto_create_issues: zod.z.boolean().optional(),
299
- auto_create_conditions: alertRuleConditionsSchema.optional()
300
- });
301
- var issueLinkSchema = zod.z.object({
302
- id: zod.z.number().int(),
303
- issue_id: zod.z.string(),
304
- repo_full_name: zod.z.string(),
305
- number: zod.z.number().int(),
306
- title: zod.z.string(),
307
- url: zod.z.string(),
308
- state: zod.z.string(),
309
- created_at: dateTimeSchema
310
- });
311
- var repoCommitSchema = zod.z.object({
312
- repo_full_name: zod.z.string(),
313
- sha: zod.z.string(),
314
- message: zod.z.string(),
315
- author_name: zod.z.string(),
316
- author_login: zod.z.string().nullable(),
317
- url: zod.z.string(),
318
- committed_at: dateTimeSchema
319
- });
320
- var issueGitHubSchema = zod.z.object({
321
- links: zod.z.array(issueLinkSchema),
322
- suspect_commits: zod.z.array(repoCommitSchema),
323
- owners: zod.z.array(zod.z.string())
324
- });
325
- var gitHubLoginSchema = zod.z.object({
326
- login: zod.z.string().nullable()
327
- });
328
- var globalRoleSchema = zod.z.enum(["admin", "member"]);
329
- var teamMemberSchema = zod.z.object({
330
- id: zod.z.number().int(),
331
- email: zod.z.string().email(),
332
- role: globalRoleSchema,
333
- is_active: zod.z.boolean(),
334
- /** True for the first-registered account, which cannot be demoted or deleted. */
335
- is_primary: zod.z.boolean().optional(),
336
- created_at: dateTimeSchema,
337
- last_login: dateTimeSchema.nullable().optional()
338
- });
339
- var updateUserRoleSchema = zod.z.object({
340
- role: globalRoleSchema
341
- });
342
-
343
- // src/schemas/invitation.ts
344
- var invitationStatusSchema = zod.z.string();
345
- var invitationSchema = zod.z.object({
346
- token: zod.z.string(),
347
- email: zod.z.string().email(),
348
- role: globalRoleSchema,
349
- status: invitationStatusSchema,
350
- expires_at: dateTimeSchema,
351
- created_at: dateTimeSchema
352
- });
353
- var invitationInfoSchema = zod.z.object({
354
- email: zod.z.string().email(),
355
- role: globalRoleSchema,
356
- status: invitationStatusSchema,
357
- expires_at: dateTimeSchema
358
- });
359
- var createInvitationSchema = zod.z.object({
360
- email: zod.z.string().email(),
361
- role: globalRoleSchema
362
- });
363
- var acceptInvitationSchema = zod.z.object({
364
- token: zod.z.string().min(1),
365
- password: zod.z.string().min(1)
366
- });
367
- var issueStatusSchema = zod.z.enum(["unresolved", "resolved", "ignored"]);
368
- var issuePrioritySchema = zod.z.enum(["low", "medium", "high"]);
369
- var issueSchema = zod.z.object({
370
- id: uuidSchema,
371
- project_id: zod.z.number().int(),
372
- short_id: zod.z.string(),
373
- title: zod.z.string(),
374
- value: zod.z.string(),
375
- culprit: zod.z.string(),
376
- logger: zod.z.string(),
377
- first_seen: dateTimeSchema,
378
- last_seen: dateTimeSchema,
379
- event_count: zod.z.number().int(),
380
- level: zod.z.string().nullable(),
381
- platform: zod.z.string().nullable(),
382
- // Status model (#165)
383
- status: issueStatusSchema,
384
- substatus: zod.z.string().nullable(),
385
- priority: issuePrioritySchema.nullable(),
386
- assigned_to: zod.z.number().int().nullable(),
387
- assignee_type: zod.z.string().nullable(),
388
- issue_type: zod.z.string(),
389
- issue_category: zod.z.string(),
390
- first_release: zod.z.string(),
391
- last_release: zod.z.string(),
392
- status_details: zod.z.record(zod.z.string(), zod.z.unknown()),
393
- // Aggregate enrichment — only the single-issue GET populates this; the list
394
- // and PATCH endpoints return the lean response, so default to 0 when absent.
395
- user_report_count: zod.z.number().int().optional().default(0),
396
- // Per-user fields — only present when the request carries a user session.
397
- is_bookmarked: zod.z.boolean().optional(),
398
- is_subscribed: zod.z.boolean().optional(),
399
- has_seen: zod.z.boolean().optional(),
400
- // Bulk list stats — only the list endpoint populates these (computed once
401
- // per page); the single-issue GET and PATCH responses omit them.
402
- user_count: zod.z.number().int().optional(),
403
- trend: zod.z.array(zod.z.number().int()).optional(),
404
- // Deprecated, derived from `status`; kept for backward compatibility.
405
- is_resolved: zod.z.boolean(),
406
- is_muted: zod.z.boolean()
407
- });
408
- var updateIssueStateSchema = zod.z.object({
409
- status: zod.z.union([issueStatusSchema, zod.z.literal("resolvedInNextRelease")]).optional(),
410
- substatus: zod.z.string().optional(),
411
- priority: issuePrioritySchema.optional(),
412
- assigned_to: zod.z.number().int().nullable().optional(),
413
- assignee_type: zod.z.string().nullable().optional(),
414
- is_resolved: zod.z.boolean().optional(),
415
- is_muted: zod.z.boolean().optional()
416
- });
417
- var issueHashSchema = zod.z.object({
418
- id: zod.z.number().int(),
419
- project_id: zod.z.number().int(),
420
- issue_id: uuidSchema,
421
- grouping_key: zod.z.string(),
422
- grouping_key_hash: zod.z.string(),
423
- created_at: dateTimeSchema
424
- });
425
- var tagValueCountSchema = zod.z.object({
426
- value: zod.z.string(),
427
- count: zod.z.number().int()
428
- });
429
- var issueTagValueSchema = zod.z.object({
430
- key: zod.z.string(),
431
- name: zod.z.string(),
432
- value: zod.z.string(),
433
- count: zod.z.number().int(),
434
- first_seen: dateTimeSchema,
435
- last_seen: dateTimeSchema
436
- });
437
- var tagSummarySchema = zod.z.object({
438
- key: zod.z.string(),
439
- total_values: zod.z.number().int(),
440
- top_values: zod.z.array(tagValueCountSchema)
441
- });
442
- var issueAggregatesSchema = zod.z.object({
443
- user_count: zod.z.number().int(),
444
- tags: zod.z.array(tagSummarySchema)
445
- });
446
- zod.z.enum(["24h", "30d"]);
447
- var issueStatsSchema = zod.z.object({
448
- data: zod.z.array(zod.z.tuple([zod.z.number(), zod.z.number()]))
449
- });
450
- var activityEntrySchema = zod.z.object({
451
- id: uuidSchema,
452
- issue_id: uuidSchema,
453
- user_id: zod.z.number().int().nullable(),
454
- type: zod.z.string(),
455
- data: zod.z.string(),
456
- created_at: dateTimeSchema
457
- });
458
- var userReportSchema = zod.z.object({
459
- id: uuidSchema,
460
- project_id: zod.z.number().int(),
461
- issue_id: uuidSchema.nullable(),
462
- event_id: uuidSchema.nullable(),
463
- name: zod.z.string(),
464
- // Server stores '' for anonymous reports (column DEFAULT '' / unwrap_or_default),
465
- // matching real Sentry's own save_userreport(report.get("email", "")) — accept it.
466
- email: zod.z.union([zod.z.email(), zod.z.literal("")]),
467
- comments: zod.z.string(),
468
- created_at: dateTimeSchema
469
- });
470
- var createCommentSchema = zod.z.object({
471
- text: zod.z.string()
472
- });
473
- var createUserReportSchema = zod.z.object({
474
- name: zod.z.string().optional(),
475
- email: zod.z.email().optional(),
476
- comments: zod.z.string().optional(),
477
- event_id: uuidSchema.optional()
478
- });
479
- var bulkUpdateIssuesSchema = zod.z.object({
480
- ids: zod.z.array(uuidSchema),
481
- status: zod.z.union([issueStatusSchema, zod.z.literal("resolvedInNextRelease")]).optional(),
482
- priority: issuePrioritySchema.optional()
483
- });
484
- var bulkDeleteIssuesSchema = zod.z.union([
485
- zod.z.strictObject({ ids: zod.z.array(uuidSchema) }),
486
- zod.z.strictObject({ filter: issueFilterSchema })
487
- ]);
488
- var logSchema = zod.z.object({
489
- id: uuidSchema,
490
- trace_id: zod.z.string().nullable(),
491
- span_id: zod.z.string().nullable(),
492
- level: zod.z.string(),
493
- /** OTel severity number (1=trace … 21=fatal). Null for unknown levels. */
494
- severity_number: zod.z.number().int().nullable(),
495
- body: zod.z.string(),
496
- attributes: zod.z.record(zod.z.string(), zod.z.any()),
497
- timestamp: dateTimeSchema,
498
- ingested_at: dateTimeSchema
499
- });
500
- var projectRoleSchema = zod.z.enum(["viewer", "editor", "admin"]);
501
- var projectMemberSchema = zod.z.object({
502
- user_id: zod.z.number().int(),
503
- email: zod.z.string().email(),
504
- role: projectRoleSchema,
505
- created_at: dateTimeSchema
506
- });
507
- var upsertProjectMemberSchema = zod.z.object({
508
- user_id: zod.z.number().int(),
509
- role: projectRoleSchema
510
- });
511
- var intervalUnitSchema = zod.z.enum([
512
- "minute",
513
- "hour",
514
- "day",
515
- "week",
516
- "month",
517
- "year"
518
- ]);
519
- var scheduleSchema = zod.z.discriminatedUnion("type", [
520
- zod.z.object({ type: zod.z.literal("crontab"), value: zod.z.string() }),
521
- zod.z.object({
522
- type: zod.z.literal("interval"),
523
- value: zod.z.number().int().min(1),
524
- unit: intervalUnitSchema
525
- })
526
- ]);
527
- var previewScheduleSchema = zod.z.object({
528
- schedule: scheduleSchema,
529
- /** IANA zone the schedule is read in. Defaults to UTC. */
530
- timezone: zod.z.string().optional()
531
- });
532
- var schedulePreviewSchema = zod.z.object({
533
- next_runs: zod.z.array(dateTimeSchema)
534
- });
535
-
536
- // src/schemas/monitor.ts
537
- var monitorConfigSchema = zod.z.object({
538
- schedule: scheduleSchema,
539
- checkin_margin: zod.z.number().int(),
540
- max_runtime: zod.z.number().int(),
541
- timezone: zod.z.string(),
542
- failure_issue_threshold: zod.z.number().int(),
543
- recovery_threshold: zod.z.number().int()
544
- });
545
- var monitorConfigInputSchema = zod.z.object({
546
- schedule: scheduleSchema.optional(),
547
- checkin_margin: zod.z.number().int().min(1).optional(),
548
- max_runtime: zod.z.number().int().min(1).optional(),
549
- timezone: zod.z.string().optional(),
550
- failure_issue_threshold: zod.z.number().int().min(1).max(720).optional(),
551
- recovery_threshold: zod.z.number().int().min(1).max(720).optional()
552
- });
553
- var checkInStatusSchema = zod.z.enum([
554
- "ok",
555
- "error",
556
- "in_progress",
557
- "missed",
558
- "timeout",
559
- "unknown"
560
- ]);
561
- var monitorEnvironmentStatusSchema = zod.z.enum(["active", "ok", "error"]);
562
- var checkInSchema = zod.z.object({
563
- id: uuidSchema,
564
- environment: zod.z.string(),
565
- status: checkInStatusSchema,
566
- duration_ms: zod.z.number().int().nullable(),
567
- date_added: dateTimeSchema,
568
- date_updated: dateTimeSchema,
569
- expected_time: dateTimeSchema.nullable()
570
- });
571
- var monitorEnvironmentSchema = zod.z.object({
572
- id: uuidSchema,
573
- environment: zod.z.string(),
574
- status: monitorEnvironmentStatusSchema,
575
- next_checkin: dateTimeSchema.nullable(),
576
- next_checkin_latest: dateTimeSchema.nullable(),
577
- last_checkin: dateTimeSchema.nullable(),
578
- /** Newest first. */
579
- recent_checkins: zod.z.array(checkInSchema)
580
- });
581
- var monitorSchema = zod.z.object({
582
- id: uuidSchema,
583
- slug: zod.z.string(),
584
- name: zod.z.string(),
585
- config: monitorConfigSchema,
586
- is_muted: zod.z.boolean(),
587
- created_at: dateTimeSchema,
588
- environments: zod.z.array(monitorEnvironmentSchema)
589
- });
590
- var createMonitorSchema = zod.z.object({
591
- name: zod.z.string().trim().min(1).max(128),
592
- /** Derived from `name` when left out. */
593
- slug: zod.z.string().min(1).max(50).optional(),
594
- config: monitorConfigInputSchema
595
- });
596
- var updateMonitorSchema = zod.z.object({
597
- name: zod.z.string().trim().min(1).max(128).optional(),
598
- config: monitorConfigInputSchema.optional(),
599
- is_muted: zod.z.boolean().optional()
600
- });
601
- var metricDeltaSchema = zod.z.object({
602
- current: zod.z.number().int(),
603
- /**
604
- * The same window immediately before this one. Null only for all-time
605
- * requests, where a `0` would render as a misleading "+100%".
606
- */
607
- previous: zod.z.number().int().nullable()
608
- });
609
- var projectListStatsSchema = zod.z.object({
610
- /**
611
- * Distinct issues active in each bucket, oldest first. A shape, not a
612
- * total: an issue firing all day appears in every bucket it touched.
613
- */
614
- trend: zod.z.array(zod.z.number().int()),
615
- events: metricDeltaSchema,
616
- /** Issues first seen in the window. Drives the "getting worse" signal. */
617
- new_issues: metricDeltaSchema,
618
- /** Unresolved issues right now, independent of the window. */
619
- open_issues: zod.z.number().int(),
620
- /** The subset of `open_issues` at `fatal` level. */
621
- fatal_issues: zod.z.number().int()
622
- });
623
- var projectSchema = zod.z.object({
624
- id: zod.z.number().int(),
625
- name: zod.z.string(),
626
- slug: zod.z.string(),
627
- sentry_key: uuidSchema,
628
- dsn: zod.z.string(),
629
- stored_event_count: zod.z.number().int(),
630
- digested_event_count: zod.z.number().int(),
631
- /** Accepted events the quota dropped instead of storing. */
632
- rate_limited_event_count: zod.z.number().int(),
633
- /**
634
- * The project's own limits, or null where it follows the server's. They can
635
- * only tighten `MAX_EVENTS_PER_PROJECT_*`, never raise it.
636
- */
637
- rate_limit_per_minute: zod.z.number().int().nullable(),
638
- rate_limit_per_hour: zod.z.number().int().nullable(),
639
- created_at: dateTimeSchema,
640
- updated_at: dateTimeSchema,
641
- platform: zod.z.string().nullable(),
642
- stats: projectListStatsSchema.optional()
643
- });
644
- var createProjectSchema = zod.z.object({
645
- name: zod.z.string().min(1),
646
- /**
647
- * Slugified server-side. Supplying it means the user chose it, so a taken
648
- * slug is a 409. Omitting it derives one from the name and silently
649
- * de-duplicates, since nobody chose that value.
650
- */
651
- slug: zod.z.string().min(1).optional(),
652
- /**
653
- * Validated server-side against SELECTABLE_PLATFORMS. Omitting it leaves the
654
- * project eligible for platform auto-detection from its first event.
655
- */
656
- platform: zod.z.string().min(1).optional()
657
- });
658
- var updateProjectSchema = zod.z.object({
659
- name: zod.z.string().min(1).optional(),
660
- platform: zod.z.string().min(1).optional(),
661
- /**
662
- * Slugified server-side. Unlike on create, a taken slug is a 409 rather than
663
- * being silently de-duplicated.
664
- */
665
- slug: zod.z.string().min(1).optional(),
666
- /** A number sets the project's own limit; null removes it. */
667
- rate_limit_per_minute: zod.z.number().int().min(1).nullable().optional(),
668
- rate_limit_per_hour: zod.z.number().int().min(1).nullable().optional()
669
- });
670
- var rateLimitsSchema = zod.z.object({
671
- project_per_minute: zod.z.number().int(),
672
- project_per_hour: zod.z.number().int()
673
- });
674
- var releaseHealthRowSchema = zod.z.object({
675
- release: zod.z.string(),
676
- environment: zod.z.string(),
677
- total: zod.z.number().int(),
678
- errored: zod.z.number().int(),
679
- crashed: zod.z.number().int(),
680
- abnormal: zod.z.number().int(),
681
- healthy: zod.z.number().int(),
682
- crash_free_sessions_rate: zod.z.number().nullable(),
683
- crash_free_users_rate: zod.z.number().nullable()
684
- });
685
- var sessionSummarySchema = zod.z.object({
686
- total: zod.z.number().int(),
687
- errored: zod.z.number().int(),
688
- crashed: zod.z.number().int(),
689
- abnormal: zod.z.number().int(),
690
- crash_free_sessions_rate: zod.z.number().nullable(),
691
- crash_free_users_rate: zod.z.number().nullable(),
692
- active_releases: zod.z.number().int()
693
- });
694
- var sessionTimeseriesPointSchema = zod.z.object({
695
- bucket: dateTimeSchema,
696
- total: zod.z.number().int(),
697
- crashed: zod.z.number().int(),
698
- crash_free_sessions_rate: zod.z.number().nullable()
699
- });
700
- var sessionTimeseriesSchema = zod.z.array(sessionTimeseriesPointSchema);
701
- var chunkUploadCapabilitySchema = zod.z.object({
702
- url: zod.z.string(),
703
- chunkSize: zod.z.number().int(),
704
- chunksPerRequest: zod.z.number().int(),
705
- maxRequestSize: zod.z.number().int(),
706
- hashAlgorithm: zod.z.string(),
707
- accept: zod.z.array(zod.z.string()),
708
- concurrency: zod.z.number().int().optional()
709
- });
710
- var assembleInputSchema = zod.z.object({
711
- checksum: zod.z.string().min(1),
712
- chunks: zod.z.array(zod.z.string().min(1)),
713
- projects: zod.z.array(zod.z.string().min(1)).min(1)
714
- });
715
- var assembleResponseSchema = zod.z.object({
716
- state: zod.z.string(),
717
- missingChunks: zod.z.array(zod.z.string()),
718
- detail: zod.z.string().optional()
719
- });
720
- var sourceMapFileSchema = zod.z.object({
721
- debugId: zod.z.string(),
722
- fileType: zod.z.string(),
723
- size: zod.z.number().int(),
724
- timesUsed: zod.z.number().int(),
725
- dateUploaded: zod.z.string()
726
- });
727
- var listSourceMapsResponseSchema = zod.z.object({
728
- data: zod.z.array(sourceMapFileSchema)
729
- });
730
- var eventTimeseriesPointSchema = zod.z.object({
731
- bucket: dateTimeSchema,
732
- total: zod.z.number().int(),
733
- fatal: zod.z.number().int(),
734
- error: zod.z.number().int(),
735
- warning: zod.z.number().int(),
736
- info: zod.z.number().int()
737
- });
738
- var eventTimeseriesSchema = zod.z.array(eventTimeseriesPointSchema);
739
- var metricDeltaSchema2 = zod.z.object({
740
- current: zod.z.number().int(),
741
- previous: zod.z.number().int().nullable()
742
- });
743
- var projectStatsSummarySchema = zod.z.object({
744
- /** Resolved window in hours, or `null` for all time. */
745
- period_hours: zod.z.number().int().nullable(),
746
- events: metricDeltaSchema2,
747
- new_issues: metricDeltaSchema2,
748
- /** Currently unresolved issues, independent of the window. */
749
- open_issues: zod.z.number().int()
750
- });
751
- var sourceMapStorageSchema = zod.z.object({
752
- chunk_bytes: zod.z.number(),
753
- source_file_bytes: zod.z.number(),
754
- total_bytes: zod.z.number(),
755
- file_count: zod.z.number()
756
- });
757
- var storageSummarySchema = zod.z.object({
758
- total_db_size_bytes: zod.z.number(),
759
- events_count: zod.z.number(),
760
- transactions_count: zod.z.number(),
761
- spans_count: zod.z.number(),
762
- logs_count: zod.z.number(),
763
- source_maps: sourceMapStorageSchema
764
- });
765
- var projectStorageSchema = zod.z.object({
766
- project_id: zod.z.number(),
767
- project_name: zod.z.string(),
768
- events_count: zod.z.number(),
769
- transactions_count: zod.z.number(),
770
- spans_count: zod.z.number(),
771
- logs_count: zod.z.number(),
772
- source_maps_count: zod.z.number(),
773
- /** `events_bytes + transactions_bytes + logs_bytes`. */
774
- estimated_bytes: zod.z.number(),
775
- events_bytes: zod.z.number(),
776
- /** Transactions with their spans. */
777
- transactions_bytes: zod.z.number(),
778
- logs_bytes: zod.z.number()
779
- });
780
- var cleanupCountsSchema = zod.z.object({
781
- events: zod.z.number(),
782
- transactions: zod.z.number(),
783
- spans: zod.z.number(),
784
- logs: zod.z.number(),
785
- issues_removed: zod.z.number(),
786
- /** Unused source maps deleted; only a retention cleanup removes them. */
787
- source_maps: zod.z.number().default(0)
788
- });
789
- var cleanupStatusSchema = zod.z.object({
790
- state: zod.z.enum(["idle", "running", "completed", "failed"]),
791
- removed: cleanupCountsSchema,
792
- started_at: zod.z.string().nullable(),
793
- finished_at: zod.z.string().nullable(),
794
- error: zod.z.string().nullable()
795
- });
796
- var sourceMapGcResultSchema = zod.z.object({
797
- files_removed: zod.z.number(),
798
- bytes_freed: zod.z.number()
799
- });
800
- var kindAgeSchema = zod.z.object({
801
- counts: zod.z.array(zod.z.number()),
802
- oldest: dateTimeSchema.nullable()
803
- });
804
- var storageAgeSchema = zod.z.object({
805
- bucket_days: zod.z.array(zod.z.number()),
806
- projects: zod.z.array(
807
- zod.z.object({
808
- project_id: zod.z.number(),
809
- events: kindAgeSchema,
810
- transactions: kindAgeSchema,
811
- logs: kindAgeSchema
812
- })
813
- )
814
- });
815
- var retentionDaysSchema = zod.z.number().int().min(1).max(36500).nullable();
816
- var retentionWindowsSchema = zod.z.object({
817
- events_days: retentionDaysSchema,
818
- /** Transactions with their spans. */
819
- transactions_days: retentionDaysSchema,
820
- logs_days: retentionDaysSchema
821
- });
822
- var projectRetentionSchema = retentionWindowsSchema.extend({
823
- project_id: zod.z.number().int()
824
- });
825
- var retentionSettingsSchema = zod.z.object({
826
- defaults: retentionWindowsSchema,
827
- overrides: zod.z.array(projectRetentionSchema),
828
- frequency: zod.z.enum(["daily", "weekly"]),
829
- /** Hour of the day, UTC. */
830
- hour: zod.z.number().int().min(0).max(23),
831
- /** Day of a weekly cleanup, 0 = Sunday. */
832
- weekday: zod.z.number().int().min(0).max(6)
833
- });
834
- var retentionRunSchema = zod.z.object({
835
- started_at: dateTimeSchema,
836
- finished_at: dateTimeSchema.nullable(),
837
- status: zod.z.enum(["running", "ok", "error"]),
838
- removed: cleanupCountsSchema.nullable(),
839
- error: zod.z.string().nullable()
840
- });
841
- var retentionSchema = zod.z.object({
842
- settings: retentionSettingsSchema,
843
- /** Null while everything is kept forever, and for up to a minute after the settings change. */
844
- next_run_at: dateTimeSchema.nullable(),
845
- last_run: retentionRunSchema.nullable()
846
- });
847
- var cleanupOptionsSchema = zod.z.object({
848
- older_than_days: zod.z.number().int().min(1),
849
- project_id: zod.z.number().int().optional(),
850
- include_events: zod.z.boolean().optional(),
851
- include_transactions: zod.z.boolean().optional(),
852
- include_logs: zod.z.boolean().optional()
853
- });
854
- var authTokenSchema = zod.z.object({
855
- id: zod.z.number().int(),
856
- token_prefix: zod.z.string(),
857
- description: zod.z.string().nullable(),
858
- created_at: dateTimeSchema,
859
- last_used_at: dateTimeSchema.nullable()
860
- });
861
- var authTokenCreatedSchema = zod.z.object({
862
- id: zod.z.number().int(),
863
- token: zod.z.string(),
864
- description: zod.z.string().nullable(),
865
- created_at: dateTimeSchema
866
- });
867
- var createAuthTokenSchema = zod.z.object({
868
- description: zod.z.string().optional()
869
- });
870
- var transactionSchema = zod.z.object({
871
- id: uuidSchema,
872
- event_id: eventIdSchema,
873
- transaction_name: zod.z.string(),
874
- timestamp: dateTimeSchema,
875
- start_timestamp: dateTimeSchema.nullable(),
876
- duration_ms: zod.z.number().nullable(),
877
- platform: zod.z.string(),
878
- environment: zod.z.string(),
879
- release: zod.z.string(),
880
- ingested_at: dateTimeSchema
881
- });
882
- var transactionDetailSchema = zod.z.object({
883
- id: uuidSchema,
884
- event_id: eventIdSchema,
885
- transaction_name: zod.z.string(),
886
- timestamp: dateTimeSchema,
887
- start_timestamp: dateTimeSchema.nullable(),
888
- duration_ms: zod.z.number().nullable(),
889
- platform: zod.z.string(),
890
- environment: zod.z.string(),
891
- release: zod.z.string(),
892
- ingested_at: dateTimeSchema,
893
- data: zod.z.record(zod.z.string(), zod.z.any())
894
- // Full Sentry transaction payload
895
- });
896
- var spanSchema = zod.z.object({
897
- id: uuidSchema,
898
- /** Parent transaction, if this span was extracted from one. `null` for a standalone span. */
899
- transaction_id: uuidSchema.nullable(),
900
- span_id: zod.z.string().nullable(),
901
- trace_id: zod.z.string().nullable(),
902
- parent_span_id: zod.z.string().nullable(),
903
- op: zod.z.string().nullable(),
904
- description: zod.z.string().nullable(),
905
- status: zod.z.string().nullable(),
906
- start_timestamp: dateTimeSchema.nullable(),
907
- timestamp: dateTimeSchema.nullable(),
908
- duration_ms: zod.z.number().nullable(),
909
- exclusive_time_ms: zod.z.number().nullable(),
910
- is_segment: zod.z.boolean(),
911
- segment_id: zod.z.string().nullable(),
912
- /** Reported by the span itself, or stamped from its parent transaction. Null only for rows ingested before that stamping existed. */
913
- platform: zod.z.string().nullable(),
914
- release: zod.z.string().nullable(),
915
- environment: zod.z.string().nullable(),
916
- /** gen_ai.* denormalized fields — all null unless recognized as an AI span. */
917
- gen_ai_operation_type: zod.z.string().nullable(),
918
- gen_ai_agent_name: zod.z.string().nullable(),
919
- gen_ai_request_model: zod.z.string().nullable(),
920
- gen_ai_response_model: zod.z.string().nullable(),
921
- gen_ai_tool_name: zod.z.string().nullable(),
922
- gen_ai_conversation_id: zod.z.string().nullable(),
923
- gen_ai_usage_input_tokens: zod.z.number().nullable(),
924
- gen_ai_usage_output_tokens: zod.z.number().nullable(),
925
- gen_ai_usage_total_tokens: zod.z.number().nullable()
926
- });
927
- var spanDetailSchema = spanSchema.extend({
928
- attributes: zod.z.record(zod.z.string(), zod.z.any()),
929
- /** Always absent for a Spans Protocol v2 span: v2 has no tags concept. */
930
- tags: zod.z.record(zod.z.string(), zod.z.any()).nullish()
931
- });
932
- var transactionStatsSchema = zod.z.object({
933
- transaction_name: zod.z.string(),
934
- op: zod.z.string().nullable(),
935
- count: zod.z.number().int(),
936
- p50_ms: zod.z.number(),
937
- p95_ms: zod.z.number(),
938
- p99_ms: zod.z.number(),
939
- failure_rate: zod.z.number()
940
- });
941
- var userSchema = zod.z.object({
942
- id: zod.z.number().int().positive(),
943
- email: zod.z.string().email(),
944
- role: globalRoleSchema,
945
- is_admin: zod.z.boolean(),
946
- /**
947
- * The dashboard language this user chose.
948
- *
949
- * `null` means they never chose one, which a consumer should treat as
950
- * "infer it" rather than as English. Optional as well as nullable so a
951
- * client stays compatible with a server predating the column.
952
- */
953
- language: zod.z.string().nullable().optional(),
954
- /** The IANA timezone this user chose, `null` when they never chose one. */
955
- timezone: zod.z.string().nullable().optional()
956
- });
957
- var updatePreferencesRequestSchema = zod.z.object({
958
- language: zod.z.string().nullable().optional(),
959
- timezone: zod.z.string().nullable().optional()
960
- });
961
- var authResponseSchema = zod.z.object({
962
- user: userSchema
963
- });
964
- zod.z.object({
965
- user: userSchema,
966
- cookies: zod.z.array(zod.z.string())
967
- });
968
- var loginRequestSchema = zod.z.object({
969
- email: zod.z.string().email(),
970
- password: zod.z.string().min(1)
971
- });
972
- var registerRequestSchema = zod.z.object({
973
- email: zod.z.string().email(),
974
- password: zod.z.string().min(1)
975
- });
976
- var ssoConfigSchema = zod.z.object({
977
- enabled: zod.z.boolean(),
978
- provider_name: zod.z.string().nullable()
979
- });
980
- var ssoStartSchema = zod.z.object({
981
- authorization_url: zod.z.string().url()
982
- });
983
- var ssoLinkSchema = zod.z.object({
984
- email: zod.z.string(),
985
- provider_name: zod.z.string()
986
- });
987
- var confirmSsoLinkRequestSchema = zod.z.object({
988
- password: zod.z.string().min(1)
989
- });
990
- var changePasswordRequestSchema = zod.z.object({
991
- current_password: zod.z.string().min(1),
992
- new_password: zod.z.string().min(1)
993
- });
994
-
995
- // src/errors.ts
996
- var FIELD_ERROR_CODES = [
997
- "required",
998
- "invalid",
999
- "already_exists",
1000
- "too_short",
1001
- "too_long",
1002
- "custom"
1003
- ];
1004
- var SERVER_ERROR_MESSAGE = "The server failed to handle the request.";
1005
- var NETWORK_ERROR_MESSAGE = "The request could not reach the server.";
1006
- var TIMEOUT_ERROR_MESSAGE = "The request timed out.";
1007
- function isRetryable(error) {
1008
- return error.kind === "network" || error.kind === "server_error" || error.kind === "rate_limited";
1009
- }
1010
-
1011
- // src/result.ts
1012
- function Ok(data) {
1013
- return { success: true, data };
1014
- }
1015
- function Err(error) {
1016
- return { success: false, error };
1017
- }
1018
- function unwrap(result) {
1019
- if (result.success) {
1020
- return result.data;
1021
- }
1022
- throw new Error(
1023
- `unwrap() called on a failed Result: ${describe(result.error)}`
1024
- );
1025
- }
1026
- function unwrapOr(result, fallback) {
1027
- return result.success ? result.data : fallback;
1028
- }
1029
- function mapResult(result, fn) {
1030
- return result.success ? Ok(fn(result.data)) : result;
1031
- }
1032
- function describe(error) {
1033
- if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
1034
- return error.message;
1035
- }
1036
- return String(error);
1037
- }
1038
- var RustrakTransportFailure = class extends Error {
1039
- rustrakError;
1040
- constructor(error) {
1041
- super(error.message);
1042
- this.name = "RustrakTransportFailure";
1043
- this.rustrakError = error;
1044
- }
1045
- };
1046
- function isTransportFailure(value) {
1047
- return value instanceof RustrakTransportFailure;
1048
- }
1049
- function readErrorMessage(error, status) {
1050
- const fallback = `HTTP ${status} error`;
1051
- const body = error.data;
1052
- if (body && typeof body === "object") {
1053
- const nested = typeof body.error === "object" ? body.error?.message : body.error;
1054
- return nested || body.message || fallback;
1055
- }
1056
- return fallback;
1057
- }
1058
- var KNOWN_FIELD_ERROR_CODES = new Set(FIELD_ERROR_CODES);
1059
- function isFieldErrorCode(value) {
1060
- return typeof value === "string" && KNOWN_FIELD_ERROR_CODES.has(value);
1061
- }
1062
- var warnedFieldErrorCodes = /* @__PURE__ */ new Set();
1063
- function warnUnknownFieldErrorCode(code, field) {
1064
- if (warnedFieldErrorCodes.has(code)) return;
1065
- warnedFieldErrorCodes.add(code);
1066
- console.warn(
1067
- `[@rustrak/client] Dropped a field error with an unrecognised code "${code}" (field "${field}"). This client build does not know that code, so the affected inputs degrade to a form-level error. The server is most likely newer than @rustrak/client; upgrade the client to match the server version.`
1068
- );
1069
- }
1070
- function readIncidentId(error) {
1071
- const body = error.data;
1072
- const raw = body && typeof body === "object" ? body.error?.incident_id : void 0;
1073
- return typeof raw === "string" && raw.length > 0 ? raw : void 0;
1074
- }
1075
- function readFieldErrors(error) {
1076
- const body = error.data;
1077
- const raw = body && typeof body === "object" ? body.error?.fields : void 0;
1078
- if (!Array.isArray(raw)) {
1079
- return void 0;
1080
- }
1081
- const fields = [];
1082
- for (const entry of raw) {
1083
- if (typeof entry !== "object" || entry === null) continue;
1084
- const { field, code, message } = entry;
1085
- if (typeof field !== "string") continue;
1086
- if (!isFieldErrorCode(code)) {
1087
- if (typeof code === "string") warnUnknownFieldErrorCode(code, field);
1088
- continue;
1089
- }
1090
- fields.push(
1091
- code === "custom" && typeof message === "string" ? { field, code, message } : { field, code }
1092
- );
1093
- }
1094
- return fields.length > 0 ? fields : void 0;
1095
- }
1096
- function readRetryAfter(response) {
1097
- const header = response.headers.get("Retry-After")?.trim();
1098
- if (!header) {
1099
- return void 0;
1100
- }
1101
- if (/^\d+$/.test(header)) {
1102
- return Number.parseInt(header, 10);
1103
- }
1104
- if (/^[+-]\d+$/.test(header)) {
1105
- return void 0;
1106
- }
1107
- const date = Date.parse(header);
1108
- if (Number.isNaN(date)) {
1109
- return void 0;
1110
- }
1111
- return Math.max(0, Math.ceil((date - Date.now()) / 1e3));
1112
- }
1113
- function annotate(base, fields) {
1114
- return fields === void 0 ? base : { ...base, fields };
1115
- }
1116
- function transformHttpError(error) {
1117
- const { response } = error;
1118
- const status = response.status;
1119
- if (status >= 500) {
1120
- const base = {
1121
- kind: "server_error",
1122
- status,
1123
- message: SERVER_ERROR_MESSAGE
1124
- };
1125
- const incidentId = readIncidentId(error);
1126
- return incidentId === void 0 ? base : { ...base, incidentId };
1127
- }
1128
- const message = readErrorMessage(error, status);
1129
- const fields = readFieldErrors(error);
1130
- switch (status) {
1131
- case 400:
1132
- return annotate({ kind: "validation", status, message }, fields);
1133
- case 401:
1134
- return annotate({ kind: "unauthenticated", status, message }, fields);
1135
- case 403:
1136
- return annotate({ kind: "forbidden", status, message }, fields);
1137
- case 404:
1138
- return annotate({ kind: "not_found", status, message }, fields);
1139
- case 409:
1140
- return annotate({ kind: "conflict", status, message }, fields);
1141
- case 410:
1142
- return annotate({ kind: "gone", status, message }, fields);
1143
- case 413:
1144
- return annotate({ kind: "payload_too_large", status, message }, fields);
1145
- case 429: {
1146
- const retryAfter = readRetryAfter(response);
1147
- return annotate(
1148
- retryAfter === void 0 ? { kind: "rate_limited", status, message } : { kind: "rate_limited", status, message, retryAfter },
1149
- fields
1150
- );
1151
- }
1152
- default:
1153
- return annotate({ kind: "client_error", status, message }, fields);
1154
- }
1155
- }
1156
- function createKyInstance(config) {
1157
- const headers = {
1158
- // `Accept` is set here rather than relied on from ky. The `.json()`
1159
- // shortcut sets it before the request is issued, and `BaseResource` no
1160
- // longer uses that shortcut: it awaits the `Response` and parses the body
1161
- // itself, so without this every one of the 86 methods would send `*/*` and
1162
- // any content-negotiating hop could answer with HTML.
1163
- Accept: "application/json",
1164
- "Content-Type": "application/json",
1165
- ...config.headers
1166
- };
1167
- if (config.token) {
1168
- headers.Authorization = `Bearer ${config.token}`;
1169
- }
1170
- return ky__default.default.create({
1171
- prefix: config.baseUrl,
1172
- timeout: config.timeout ?? 3e4,
1173
- credentials: "include",
1174
- retry: {
1175
- limit: config.maxRetries ?? 2,
1176
- statusCodes: [408, 500, 502, 503, 504],
1177
- methods: ["get", "post", "put", "patch", "delete"]
1178
- },
1179
- headers,
1180
- hooks: {
1181
- beforeError: [
1182
- ({ error }) => {
1183
- if (error.name === "TimeoutError") {
1184
- throw new RustrakTransportFailure({
1185
- kind: "network",
1186
- message: TIMEOUT_ERROR_MESSAGE,
1187
- reason: "timeout"
1188
- });
1189
- }
1190
- if (ky.isHTTPError(error)) {
1191
- throw new RustrakTransportFailure(transformHttpError(error));
1192
- }
1193
- throw new RustrakTransportFailure({
1194
- kind: "network",
1195
- message: NETWORK_ERROR_MESSAGE,
1196
- reason: "unreachable"
1197
- });
1198
- }
1199
- ]
1200
- }
1201
- });
1202
- }
1203
-
1204
- // src/resources/base.ts
1205
- var TRANSPORT_TYPE_ERROR = /terminated|aborted|socket|network|closed|reset|fetch failed/i;
1206
- function isProgrammingError(error) {
1207
- if (!(error instanceof Error)) {
1208
- return true;
1209
- }
1210
- if (error instanceof ReferenceError || error instanceof RangeError) {
1211
- return true;
1212
- }
1213
- if (error instanceof TypeError) {
1214
- return error.cause === void 0 && !TRANSPORT_TYPE_ERROR.test(error.message);
1215
- }
1216
- return false;
1217
- }
1218
- function classifyBodyFailure(error) {
1219
- if (error instanceof SyntaxError) {
1220
- return {
1221
- kind: "invalid_response",
1222
- message: "The server returned a body that is not valid JSON."
1223
- };
1224
- }
1225
- if (isProgrammingError(error)) {
1226
- return "rethrow";
1227
- }
1228
- return {
1229
- kind: "network",
1230
- message: NETWORK_ERROR_MESSAGE,
1231
- reason: error instanceof Error && error.name === "TimeoutError" ? "timeout" : "unreachable"
1232
- };
1233
- }
1234
- function discardBody(response) {
1235
- try {
1236
- void response.body?.cancel().catch(() => {
1237
- });
1238
- } catch {
1239
- }
1240
- }
1241
- var BaseResource = class {
1242
- http;
1243
- constructor(http) {
1244
- this.http = http;
1245
- }
1246
- /**
1247
- * Validate an API response against its Zod schema.
1248
- *
1249
- * Failure is `invalid_response`: "our own response schema did not match",
1250
- * never "the user's input was rejected". No Zod issues are attached: they
1251
- * embed the offending response data.
1252
- */
1253
- validate(data, schema) {
1254
- const result = schema.safeParse(data);
1255
- if (!result.success) {
1256
- return Err({
1257
- kind: "invalid_response",
1258
- message: "The server response did not match the expected schema."
1259
- });
1260
- }
1261
- return Ok(result.data);
1262
- }
1263
- /**
1264
- * Validate caller-supplied input before it reaches the network.
1265
- *
1266
- * Failure is `invalid_request` and has no `status`: nothing was sent.
1267
- */
1268
- validateInput(input, schema) {
1269
- const result = schema.safeParse(input);
1270
- if (!result.success) {
1271
- return Err({
1272
- kind: "invalid_request",
1273
- message: "The request input did not match the expected schema."
1274
- });
1275
- }
1276
- return Ok(result.data);
1277
- }
1278
- /**
1279
- * The boundary. Runs `send`, converts a transport failure into an `Err`, and
1280
- * hands the `Response` to `read`.
1281
- *
1282
- * Anything thrown that is not the internal carrier is a programming error and
1283
- * is rethrown.
1284
- */
1285
- async requestResponse(send, read) {
1286
- let response;
1287
- try {
1288
- response = await send();
1289
- } catch (error) {
1290
- if (isTransportFailure(error)) {
1291
- return Err(error.rustrakError);
1292
- }
1293
- throw error;
1294
- }
1295
- return read(response);
1296
- }
1297
- /**
1298
- * Read a JSON body, mapping a failed read onto the right `kind`.
1299
- *
1300
- * Shared with `AuthResource`, which needs the `Set-Cookie` headers off the
1301
- * raw `Response` and so cannot go through {@link BaseResource.request}.
1302
- */
1303
- async readJson(response) {
1304
- try {
1305
- return Ok(await response.json());
1306
- } catch (error) {
1307
- const failure = classifyBodyFailure(error);
1308
- if (failure === "rethrow") {
1309
- throw error;
1310
- }
1311
- return Err(failure);
1312
- }
1313
- }
1314
- /** Send a request and validate its JSON body against `schema`. */
1315
- async request(send, schema) {
1316
- return this.requestResponse(send, async (response) => {
1317
- const body = await this.readJson(response);
1318
- if (!body.success) {
1319
- return body;
1320
- }
1321
- return this.validate(body.data, schema);
1322
- });
1323
- }
1324
- /** Send a request whose response body carries no contract (204, or ignored). */
1325
- async requestVoid(send) {
1326
- return this.requestResponse(send, async (response) => {
1327
- discardBody(response);
1328
- return Ok(void 0);
1329
- });
1330
- }
1331
- };
1332
-
1333
- // src/resources/agents.ts
1334
- function timeseriesSearchParams(options) {
1335
- const searchParams = {};
1336
- if (options?.period_hours) {
1337
- searchParams.period_hours = String(options.period_hours);
1338
- }
1339
- if (options?.interval_hours) {
1340
- searchParams.interval_hours = String(options.interval_hours);
1341
- }
1342
- if (options?.environment) {
1343
- searchParams.environment = options.environment;
1344
- }
1345
- return searchParams;
1346
- }
1347
- function breakdownSearchParams(options) {
1348
- const searchParams = {};
1349
- if (options?.period_hours) {
1350
- searchParams.period_hours = String(options.period_hours);
1351
- }
1352
- if (options?.limit) {
1353
- searchParams.limit = String(options.limit);
1354
- }
1355
- if (options?.environment) {
1356
- searchParams.environment = options.environment;
1357
- }
1358
- return searchParams;
1359
- }
1360
- var AgentsResource = class extends BaseResource {
1361
- /**
1362
- * Time-bucketed count of agent-run spans (`gen_ai.operation.type:agent`).
1363
- */
1364
- async getRuns(projectId, options) {
1365
- return this.request(
1366
- () => this.http.get(`api/projects/${projectId}/agents/runs`, {
1367
- searchParams: timeseriesSearchParams(options)
1368
- }),
1369
- zod.z.array(agentTimeseriesPointSchema)
1370
- );
1371
- }
1372
- /**
1373
- * Time-bucketed avg/p95 duration for `agent`/`ai_client` spans.
1374
- */
1375
- async getDuration(projectId, options) {
1376
- return this.request(
1377
- () => this.http.get(`api/projects/${projectId}/agents/duration`, {
1378
- searchParams: timeseriesSearchParams(options)
1379
- }),
1380
- zod.z.array(agentDurationPointSchema)
1381
- );
1382
- }
1383
- /**
1384
- * Top models by LLM call count (`gen_ai.operation.type:ai_client`).
1385
- */
1386
- async getModelsByCalls(projectId, options) {
1387
- return this.request(
1388
- () => this.http.get(`api/projects/${projectId}/agents/models/calls`, {
1389
- searchParams: breakdownSearchParams(options)
1390
- }),
1391
- zod.z.array(genAiBreakdownRowSchema)
1392
- );
1393
- }
1394
- /**
1395
- * Top models by total tokens used (`gen_ai.operation.type:ai_client`).
1396
- */
1397
- async getModelsByTokens(projectId, options) {
1398
- return this.request(
1399
- () => this.http.get(`api/projects/${projectId}/agents/models/tokens`, {
1400
- searchParams: breakdownSearchParams(options)
1401
- }),
1402
- zod.z.array(genAiBreakdownRowSchema)
1403
- );
1404
- }
1405
- /**
1406
- * Top tools by call count (`gen_ai.operation.type:tool`).
1407
- */
1408
- async getTools(projectId, options) {
1409
- return this.request(
1410
- () => this.http.get(`api/projects/${projectId}/agents/tools`, {
1411
- searchParams: breakdownSearchParams(options)
1412
- }),
1413
- zod.z.array(genAiBreakdownRowSchema)
1414
- );
1415
- }
1416
- /**
1417
- * Paginated per-trace_id aggregate (duration, tokens, tool usage) across
1418
- * all AI spans sharing that trace, regardless of origin.
1419
- */
1420
- async getTraces(projectId, options) {
1421
- const searchParams = {};
1422
- if (options?.page) {
1423
- searchParams.page = String(options.page);
1424
- }
1425
- if (options?.per_page) {
1426
- searchParams.per_page = String(options.per_page);
1427
- }
1428
- if (options?.period_hours) {
1429
- searchParams.period_hours = String(options.period_hours);
1430
- }
1431
- if (options?.environment) {
1432
- searchParams.environment = options.environment;
1433
- }
1434
- return this.request(
1435
- () => this.http.get(`api/projects/${projectId}/agents/traces`, {
1436
- searchParams
1437
- }),
1438
- offsetPaginatedResponseSchema(agentTraceSummarySchema)
1439
- );
1440
- }
1441
- /**
1442
- * Headline totals over the selected window — the numbers the charts show
1443
- * the shape of but cannot state.
1444
- */
1445
- async getSummary(projectId, options) {
1446
- return this.request(
1447
- () => this.http.get(`api/projects/${projectId}/agents/summary`, {
1448
- searchParams: breakdownSearchParams(options)
1449
- }),
1450
- agentSummarySchema
1451
- );
1452
- }
1453
- /**
1454
- * Per-model table: volume, failures, latency and the full token split.
1455
- */
1456
- async getModelsTable(projectId, options) {
1457
- return this.request(
1458
- () => this.http.get(`api/projects/${projectId}/agents/models`, {
1459
- searchParams: breakdownSearchParams(options)
1460
- }),
1461
- zod.z.array(agentModelRowSchema)
1462
- );
1463
- }
1464
- /**
1465
- * Per-tool table: call volume, failures and latency.
1466
- */
1467
- async getToolsTable(projectId, options) {
1468
- return this.request(
1469
- () => this.http.get(`api/projects/${projectId}/agents/tools/stats`, {
1470
- searchParams: breakdownSearchParams(options)
1471
- }),
1472
- zod.z.array(agentToolRowSchema)
1473
- );
1474
- }
1475
- /**
1476
- * Environments present in this project's AI spans — the options the filter
1477
- * offers, read from the data rather than hardcoded.
1478
- */
1479
- async getEnvironments(projectId) {
1480
- return this.request(
1481
- () => this.http.get(`api/projects/${projectId}/agents/environments`),
1482
- zod.z.array(zod.z.string())
1483
- );
1484
- }
1485
- };
1486
- var AlertIntegrationsResource = class extends BaseResource {
1487
- /**
1488
- * List all alert integrations
1489
- */
1490
- async list() {
1491
- return this.request(
1492
- () => this.http.get("api/integrations"),
1493
- zod.z.array(alertIntegrationSchema)
1494
- );
1495
- }
1496
- /**
1497
- * Get a single alert integration by ID
1498
- */
1499
- async get(id) {
1500
- return this.request(
1501
- () => this.http.get(`api/integrations/${id}`),
1502
- alertIntegrationSchema
1503
- );
1504
- }
1505
- /**
1506
- * Create a new alert integration
1507
- */
1508
- async create(input) {
1509
- const validatedInput = this.validateInput(
1510
- input,
1511
- createAlertIntegrationSchema
1512
- );
1513
- if (!validatedInput.success) {
1514
- return validatedInput;
1515
- }
1516
- return this.request(
1517
- () => this.http.post("api/integrations", { json: validatedInput.data }),
1518
- alertIntegrationSchema
1519
- );
1520
- }
1521
- /**
1522
- * Update an existing alert integration
1523
- */
1524
- async update(id, input) {
1525
- const validatedInput = this.validateInput(
1526
- input,
1527
- updateAlertIntegrationSchema
1528
- );
1529
- if (!validatedInput.success) {
1530
- return validatedInput;
1531
- }
1532
- return this.request(
1533
- () => this.http.patch(`api/integrations/${id}`, {
1534
- json: validatedInput.data
1535
- }),
1536
- alertIntegrationSchema
1537
- );
1538
- }
1539
- /**
1540
- * Delete an alert integration
1541
- */
1542
- async delete(id) {
1543
- return this.requestVoid(() => this.http.delete(`api/integrations/${id}`));
1544
- }
1545
- /**
1546
- * Send a test notification to verify integration configuration.
1547
- * For Slack bot_token integrations, routingOverride must include `channel`.
1548
- */
1549
- async test(id, routingOverride) {
1550
- let body;
1551
- if (routingOverride !== void 0) {
1552
- const validatedInput = this.validateInput(
1553
- { routing_override: routingOverride },
1554
- testIntegrationBodySchema
1555
- );
1556
- if (!validatedInput.success) {
1557
- return validatedInput;
1558
- }
1559
- body = validatedInput.data;
1560
- }
1561
- return this.request(
1562
- () => this.http.post(
1563
- `api/integrations/${id}/test`,
1564
- body !== void 0 ? { json: body } : void 0
1565
- ),
1566
- testChannelResponseSchema
1567
- );
1568
- }
1569
- /**
1570
- * Render a Custom Webhook template against a sample payload.
1571
- *
1572
- * Answers with the body that would be sent, or with why it would not
1573
- * render. It goes to the server because the server owns the template
1574
- * engine: a preview computed anywhere else would eventually disagree with
1575
- * what a delivery actually sends.
1576
- */
1577
- async previewTemplate(template) {
1578
- return this.request(
1579
- () => this.http.post("api/integrations/preview-template", {
1580
- json: { template }
1581
- }),
1582
- previewTemplateResponseSchema
1583
- );
1584
- }
1585
- };
1586
- var AlertRulesResource = class extends BaseResource {
1587
- /**
1588
- * List all alert rules for a project
1589
- */
1590
- async list(projectId) {
1591
- return this.request(
1592
- () => this.http.get(`api/projects/${projectId}/alert-rules`),
1593
- zod.z.array(alertRuleSchema)
1594
- );
1595
- }
1596
- /**
1597
- * Get a single alert rule by ID
1598
- */
1599
- async get(projectId, ruleId) {
1600
- return this.request(
1601
- () => this.http.get(`api/projects/${projectId}/alert-rules/${ruleId}`),
1602
- alertRuleSchema
1603
- );
1604
- }
1605
- /**
1606
- * Create a new alert rule for a project
1607
- */
1608
- async create(projectId, input) {
1609
- const validatedInput = this.validateInput(input, createAlertRuleSchema);
1610
- if (!validatedInput.success) {
1611
- return validatedInput;
1612
- }
1613
- return this.request(
1614
- () => this.http.post(`api/projects/${projectId}/alert-rules`, {
1615
- json: validatedInput.data
1616
- }),
1617
- alertRuleSchema
1618
- );
1619
- }
1620
- /**
1621
- * Update an existing alert rule
1622
- */
1623
- async update(projectId, ruleId, input) {
1624
- const validatedInput = this.validateInput(input, updateAlertRuleSchema);
1625
- if (!validatedInput.success) {
1626
- return validatedInput;
1627
- }
1628
- return this.request(
1629
- () => this.http.patch(`api/projects/${projectId}/alert-rules/${ruleId}`, {
1630
- json: validatedInput.data
1631
- }),
1632
- alertRuleSchema
1633
- );
1634
- }
1635
- /**
1636
- * Delete an alert rule
1637
- */
1638
- async delete(projectId, ruleId) {
1639
- return this.requestVoid(
1640
- () => this.http.delete(`api/projects/${projectId}/alert-rules/${ruleId}`)
1641
- );
1642
- }
1643
- /**
1644
- * List alert history for a project
1645
- */
1646
- async listHistory(projectId, options) {
1647
- const searchParams = new URLSearchParams();
1648
- if (options?.limit !== void 0) {
1649
- searchParams.set("limit", options.limit.toString());
1650
- }
1651
- const query = searchParams.toString();
1652
- const url = query ? `api/projects/${projectId}/alert-history?${query}` : `api/projects/${projectId}/alert-history`;
1653
- return this.request(() => this.http.get(url), zod.z.array(alertHistorySchema));
1654
- }
1655
- };
1656
-
1657
- // src/resources/auth.ts
1658
- function readSetCookie(response) {
1659
- if (typeof response.headers.getSetCookie === "function") {
1660
- return response.headers.getSetCookie();
1661
- }
1662
- const folded = response.headers.get("set-cookie");
1663
- return folded === null ? [] : [folded];
1664
- }
1665
- var AuthResource = class extends BaseResource {
1666
- /** Return the public SSO login configuration. */
1667
- async getSsoConfig() {
1668
- return this.request(
1669
- () => this.http.get("auth/sso/config"),
1670
- ssoConfigSchema
1671
- );
1672
- }
1673
- /** Begin SSO and return the provider URL plus the encrypted state cookie. */
1674
- async startSso() {
1675
- return this.requestResponse(
1676
- () => this.http.post("auth/sso/start"),
1677
- async (response) => {
1678
- const cookies = readSetCookie(response);
1679
- const body = await this.readJson(response);
1680
- if (!body.success) return body;
1681
- const data = this.validate(body.data, ssoStartSchema);
1682
- if (!data.success) return data;
1683
- return Ok({
1684
- authorizationUrl: data.data.authorization_url,
1685
- cookies
1686
- });
1687
- }
1688
- );
1689
- }
1690
- /** The account an SSO login is waiting to link, if any. */
1691
- async getSsoLink() {
1692
- return this.request(() => this.http.get("auth/sso/link"), ssoLinkSchema);
1693
- }
1694
- /** Link the pending SSO identity with the account's password and sign in. */
1695
- async confirmSsoLink(password) {
1696
- const validatedInput = this.validateInput(
1697
- { password },
1698
- confirmSsoLinkRequestSchema
1699
- );
1700
- if (!validatedInput.success) {
1701
- return validatedInput;
1702
- }
1703
- return this.requestResponse(
1704
- () => this.http.post("auth/sso/link", { json: validatedInput.data }),
1705
- (response) => this.readLoginResult(response)
1706
- );
1707
- }
1708
- /** Complete an OIDC callback and return the normal Rustrak session cookie. */
1709
- async completeSso(callback) {
1710
- const searchParams = new URLSearchParams();
1711
- if (callback.code) searchParams.set("code", callback.code);
1712
- if (callback.state) searchParams.set("state", callback.state);
1713
- if (callback.error) searchParams.set("error", callback.error);
1714
- return this.requestResponse(
1715
- () => this.http.get("auth/sso/callback", { searchParams }),
1716
- (response) => this.readLoginResult(response)
1717
- );
1718
- }
1719
- /**
1720
- * Register a new user account
1721
- * Creates a new user and automatically logs them in (sets session cookie)
1722
- * @param credentials - Email and password for the new account
1723
- * @returns LoginResult with user information and session cookies
1724
- */
1725
- async register(credentials) {
1726
- const validatedInput = this.validateInput(
1727
- credentials,
1728
- registerRequestSchema
1729
- );
1730
- if (!validatedInput.success) {
1731
- return validatedInput;
1732
- }
1733
- return this.requestResponse(
1734
- () => this.http.post("auth/register", { json: validatedInput.data }),
1735
- (response) => this.readLoginResult(response)
1736
- );
1737
- }
1738
- /**
1739
- * Login with email and password
1740
- * Authenticates the user and sets a session cookie
1741
- * @param credentials - Email and password
1742
- * @returns LoginResult with user information and session cookies
1743
- */
1744
- async login(credentials) {
1745
- const validatedInput = this.validateInput(credentials, loginRequestSchema);
1746
- if (!validatedInput.success) {
1747
- return validatedInput;
1748
- }
1749
- return this.requestResponse(
1750
- () => this.http.post("auth/login", { json: validatedInput.data }),
1751
- (response) => this.readLoginResult(response)
1752
- );
1753
- }
1754
- /**
1755
- * Logout the current user
1756
- * Clears the session cookie
1757
- * @returns Array of Set-Cookie headers (typically clearing cookies)
1758
- */
1759
- async logout() {
1760
- return this.requestResponse(
1761
- () => this.http.post("auth/logout"),
1762
- async (response) => {
1763
- const cookies = readSetCookie(response);
1764
- discardBody(response);
1765
- return Ok(cookies);
1766
- }
1767
- );
1768
- }
1769
- /**
1770
- * Get current authenticated user
1771
- * Requires a valid session cookie
1772
- *
1773
- * No session is `{success: false, kind: 'unauthenticated'}`, not a `null`
1774
- * user: it is the literal reading of the server's 401. Callers must send the
1775
- * visitor to login on `unauthenticated` **only**. Treating `network` or
1776
- * `server_error` the same way turns a flaky connection into a login loop.
1777
- *
1778
- * @returns The current user, or `unauthenticated` when there is no session
1779
- */
1780
- async getCurrentUser() {
1781
- return this.request(() => this.http.get("auth/me"), userSchema);
1782
- }
1783
- /**
1784
- * Stores how this reader wants the dashboard presented to them.
1785
- *
1786
- * A key left out is left alone; a key sent as `null` is cleared. That is why
1787
- * the request type is optional *and* nullable rather than one or the other:
1788
- * "do not touch" and "forget my choice" are different instructions.
1789
- */
1790
- async updatePreferences(preferences) {
1791
- const validatedInput = this.validateInput(
1792
- preferences,
1793
- updatePreferencesRequestSchema
1794
- );
1795
- if (!validatedInput.success) return validatedInput;
1796
- return this.request(
1797
- () => this.http.patch("auth/me", { json: validatedInput.data }),
1798
- userSchema
1799
- );
1800
- }
1801
- /** Replaces the signed-in user's password, given the current one. */
1802
- async changePassword(request) {
1803
- const validatedInput = this.validateInput(
1804
- request,
1805
- changePasswordRequestSchema
1806
- );
1807
- if (!validatedInput.success) return validatedInput;
1808
- return this.requestVoid(
1809
- () => this.http.post("auth/me/password", {
1810
- json: validatedInput.data,
1811
- retry: 0
1812
- })
1813
- );
1814
- }
1815
- /**
1816
- * Get the details of a pending invitation by its token (public endpoint)
1817
- * Used by the accept-invitation page before the user has an account
1818
- * @param token - Invitation token
1819
- * @returns Invitation info (email, role, status, expiry)
1820
- */
1821
- async getInvitation(token) {
1822
- return this.request(
1823
- () => this.http.get(`auth/invitation/${token}`),
1824
- invitationInfoSchema
1825
- );
1826
- }
1827
- /**
1828
- * Accept a pending invitation, creating the user account and logging in
1829
- * @param input - Invitation token and the new account's password
1830
- * @returns LoginResult with user information and session cookies
1831
- */
1832
- async acceptInvitation(input) {
1833
- const validatedInput = this.validateInput(input, acceptInvitationSchema);
1834
- if (!validatedInput.success) {
1835
- return validatedInput;
1836
- }
1837
- return this.requestResponse(
1838
- () => this.http.post("auth/accept-invitation", {
1839
- json: validatedInput.data
1840
- }),
1841
- (response) => this.readLoginResult(response)
1842
- );
1843
- }
1844
- /**
1845
- * The three session-establishing endpoints share a body and need the
1846
- * `Set-Cookie` headers off the raw `Response`, which is why they go through
1847
- * `requestResponse` rather than the plain JSON path.
1848
- */
1849
- async readLoginResult(response) {
1850
- const cookies = readSetCookie(response);
1851
- const body = await this.readJson(response);
1852
- if (!body.success) {
1853
- return body;
1854
- }
1855
- const authResponse = this.validate(body.data, authResponseSchema);
1856
- if (!authResponse.success) {
1857
- return authResponse;
1858
- }
1859
- return Ok({ user: authResponse.data.user, cookies });
1860
- }
1861
- };
1862
-
1863
- // src/resources/events.ts
1864
- var EventsResource = class extends BaseResource {
1865
- /**
1866
- * List events for an issue with pagination
1867
- */
1868
- async list(projectId, issueId, options) {
1869
- const searchParams = {};
1870
- if (options?.order) {
1871
- searchParams.order = options.order;
1872
- }
1873
- if (options?.cursor) {
1874
- searchParams.cursor = options.cursor;
1875
- }
1876
- return this.request(
1877
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/events`, {
1878
- searchParams
1879
- }),
1880
- paginatedResponseSchema(eventSchema)
1881
- );
1882
- }
1883
- /**
1884
- * Get a single event by ID with full details
1885
- */
1886
- async get(projectId, issueId, eventId) {
1887
- return this.request(
1888
- () => this.http.get(
1889
- `api/projects/${projectId}/issues/${issueId}/events/${eventId}`
1890
- ),
1891
- eventDetailSchema
1892
- );
1893
- }
1894
- /** Resolve the client-supplied Sentry event ID, including its owning issue. */
1895
- async getBySentryId(projectId, eventId) {
1896
- return this.request(
1897
- () => this.http.get(
1898
- `api/projects/${projectId}/events/sentry/${encodeURIComponent(eventId)}`
1899
- ),
1900
- eventDetailSchema
1901
- );
1902
- }
1903
- };
1904
-
1905
- // src/resources/github.ts
1906
- var GitHubResource = class extends BaseResource {
1907
- /** The app, its installations and the webhook address (admin only). */
1908
- async status() {
1909
- return this.request(() => this.http.get("api/github"), gitHubStatusSchema);
1910
- }
1911
- /** The form to post to GitHub to create the app, under an org if given. */
1912
- async manifest(organization) {
1913
- return this.request(
1914
- () => this.http.post("api/github/manifest", { json: { organization } }),
1915
- gitHubManifestSchema
1916
- );
1917
- }
1918
- async disconnect() {
1919
- return this.requestVoid(() => this.http.delete("api/github"));
1920
- }
1921
- /** Repositories the installations reach, for a project's settings. */
1922
- async repositories(projectId) {
1923
- return this.request(
1924
- () => this.http.get("api/github/repositories", {
1925
- searchParams: { project_id: projectId }
1926
- }),
1927
- gitHubRepositorySchema.array()
1928
- );
1929
- }
1930
- async projectRepository(projectId) {
1931
- return this.request(
1932
- () => this.http.get(`api/projects/${projectId}/github`),
1933
- projectRepositorySchema.nullable()
1934
- );
1935
- }
1936
- async setProjectRepository(projectId, input) {
1937
- const validated = this.validateInput(input, updateProjectRepositorySchema);
1938
- if (!validated.success) {
1939
- return validated;
1940
- }
1941
- return this.request(
1942
- () => this.http.put(`api/projects/${projectId}/github`, {
1943
- json: validated.data
1944
- }),
1945
- projectRepositorySchema
1946
- );
1947
- }
1948
- async removeProjectRepository(projectId) {
1949
- return this.requestVoid(
1950
- () => this.http.delete(`api/projects/${projectId}/github`)
1951
- );
1952
- }
1953
- /** Copies the repository's CODEOWNERS into Rustrak. */
1954
- async syncCodeowners(projectId) {
1955
- return this.request(
1956
- () => this.http.post(`api/projects/${projectId}/github/codeowners`),
1957
- projectRepositorySchema
1958
- );
1959
- }
1960
- /** Links, suspect commits and owners for one issue. */
1961
- async issue(projectId, issueId) {
1962
- return this.request(
1963
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/github`),
1964
- issueGitHubSchema
1965
- );
1966
- }
1967
- async createIssue(projectId, issueId, input = {}) {
1968
- return this.request(
1969
- () => this.http.post(
1970
- `api/projects/${projectId}/issues/${issueId}/github/issues`,
1971
- { json: input }
1972
- ),
1973
- issueLinkSchema
1974
- );
1975
- }
1976
- /** `reference` is a GitHub URL, `owner/repo#12` or `#12`. */
1977
- async linkIssue(projectId, issueId, reference) {
1978
- return this.request(
1979
- () => this.http.post(
1980
- `api/projects/${projectId}/issues/${issueId}/github/links`,
1981
- { json: { reference } }
1982
- ),
1983
- issueLinkSchema
1984
- );
1985
- }
1986
- async unlinkIssue(projectId, issueId, linkId) {
1987
- return this.requestVoid(
1988
- () => this.http.delete(
1989
- `api/projects/${projectId}/issues/${issueId}/github/links/${linkId}`
1990
- )
1991
- );
1992
- }
1993
- /** The signed-in person's GitHub username, used to sync assignees. */
1994
- async myLogin() {
1995
- return this.request(
1996
- () => this.http.get("api/github/me"),
1997
- gitHubLoginSchema
1998
- );
1999
- }
2000
- async setMyLogin(login) {
2001
- return this.request(
2002
- () => this.http.put("api/github/me", { json: { login } }),
2003
- gitHubLoginSchema
2004
- );
2005
- }
2006
- };
2007
- var serverVersionSchema = zod.z.object({
2008
- version: zod.z.string()
2009
- });
2010
-
2011
- // src/resources/health.ts
2012
- var HealthResource = class extends BaseResource {
2013
- /**
2014
- * The version the server reports for itself.
2015
- *
2016
- * Authenticated: the server answers this one to a session or a Bearer token
2017
- * only, and returns 401 to anonymous callers. `/health` and `/health/ready`
2018
- * stay open for probes; a version number is what tells a stranger which
2019
- * advisories apply to your instance, so it is not probe material.
2020
- */
2021
- async getVersion() {
2022
- return this.request(
2023
- () => this.http.get("health/version"),
2024
- serverVersionSchema
2025
- );
2026
- }
2027
- };
2028
-
2029
- // src/resources/invitations.ts
2030
- var InvitationsResource = class extends BaseResource {
2031
- /**
2032
- * Create a new invitation
2033
- * @param input - Email and global role for the invited user
2034
- */
2035
- async create(input) {
2036
- const validatedInput = this.validateInput(input, createInvitationSchema);
2037
- if (!validatedInput.success) {
2038
- return validatedInput;
2039
- }
2040
- return this.request(
2041
- () => this.http.post("api/invitations", { json: validatedInput.data }),
2042
- invitationSchema
2043
- );
2044
- }
2045
- /**
2046
- * List all invitations
2047
- */
2048
- async list() {
2049
- return this.request(
2050
- () => this.http.get("api/invitations"),
2051
- invitationSchema.array()
2052
- );
2053
- }
2054
- /**
2055
- * Revoke a pending invitation
2056
- * @param token - Invitation token to revoke
2057
- */
2058
- async revoke(token) {
2059
- return this.requestVoid(() => this.http.delete(`api/invitations/${token}`));
2060
- }
2061
- };
2062
- var IssuesResource = class extends BaseResource {
2063
- /**
2064
- * List issues for a project with offset-based pagination
2065
- */
2066
- async list(projectId, options) {
2067
- const searchParams = {};
2068
- if (options?.page !== void 0) {
2069
- searchParams.page = options.page.toString();
2070
- }
2071
- if (options?.per_page !== void 0) {
2072
- searchParams.per_page = options.per_page.toString();
2073
- }
2074
- if (options?.sort) {
2075
- searchParams.sort = options.sort;
2076
- }
2077
- if (options?.order) {
2078
- searchParams.order = options.order;
2079
- }
2080
- if (options?.filter) {
2081
- searchParams.filter = options.filter;
2082
- }
2083
- if (options?.q) {
2084
- searchParams.q = options.q;
2085
- }
2086
- return this.request(
2087
- () => this.http.get(`api/projects/${projectId}/issues`, { searchParams }),
2088
- offsetPaginatedResponseSchema(issueSchema)
2089
- );
2090
- }
2091
- /**
2092
- * Get a single issue by ID
2093
- */
2094
- async get(projectId, issueId) {
2095
- return this.request(
2096
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}`),
2097
- issueSchema
2098
- );
2099
- }
2100
- /**
2101
- * Update issue state (status, substatus, priority, assignment, …)
2102
- */
2103
- async updateState(projectId, issueId, input) {
2104
- const validatedInput = this.validateInput(input, updateIssueStateSchema);
2105
- if (!validatedInput.success) {
2106
- return validatedInput;
2107
- }
2108
- return this.request(
2109
- () => this.http.patch(`api/projects/${projectId}/issues/${issueId}`, {
2110
- json: validatedInput.data
2111
- }),
2112
- issueSchema
2113
- );
2114
- }
2115
- /**
2116
- * Resolve an issue in the next release (suppresses regression until a deploy).
2117
- */
2118
- async resolveInNextRelease(projectId, issueId) {
2119
- return this.updateState(projectId, issueId, {
2120
- status: "resolvedInNextRelease"
2121
- });
2122
- }
2123
- /**
2124
- * Delete an issue
2125
- */
2126
- async delete(projectId, issueId) {
2127
- return this.requestVoid(
2128
- () => this.http.delete(`api/projects/${projectId}/issues/${issueId}`)
2129
- );
2130
- }
2131
- /**
2132
- * Bulk-mutate issues (status and/or priority).
2133
- */
2134
- async bulkUpdate(projectId, input) {
2135
- const validatedInput = this.validateInput(input, bulkUpdateIssuesSchema);
2136
- if (!validatedInput.success) {
2137
- return validatedInput;
2138
- }
2139
- return this.request(
2140
- () => this.http.put(`api/projects/${projectId}/issues`, {
2141
- json: validatedInput.data
2142
- }),
2143
- zod.z.object({ updated: zod.z.number().int() })
2144
- );
2145
- }
2146
- /**
2147
- * Bulk-delete issues.
2148
- */
2149
- async bulkDelete(projectId, input) {
2150
- const validatedInput = this.validateInput(input, bulkDeleteIssuesSchema);
2151
- if (!validatedInput.success) {
2152
- return validatedInput;
2153
- }
2154
- return this.request(
2155
- () => this.http.delete(`api/projects/${projectId}/issues`, {
2156
- json: validatedInput.data
2157
- }),
2158
- zod.z.object({ deleted: zod.z.number().int() })
2159
- );
2160
- }
2161
- /**
2162
- * List the grouping hashes that map to an issue.
2163
- */
2164
- async getHashes(projectId, issueId) {
2165
- return this.request(
2166
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/hashes`),
2167
- zod.z.array(issueHashSchema)
2168
- );
2169
- }
2170
- /**
2171
- * List the distinct values (with counts) for a tag key across the issue.
2172
- * Returns a bare list, one entry per value (Sentry-compatible shape).
2173
- */
2174
- async getTagValues(projectId, issueId, key) {
2175
- return this.request(
2176
- () => this.http.get(
2177
- `api/projects/${projectId}/issues/${issueId}/tags/${encodeURIComponent(key)}`
2178
- ),
2179
- zod.z.array(issueTagValueSchema)
2180
- );
2181
- }
2182
- /**
2183
- * Fetch per-issue aggregates (unique user count + top tags).
2184
- */
2185
- async getAggregates(projectId, issueId) {
2186
- return this.request(
2187
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/aggregates`),
2188
- issueAggregatesSchema
2189
- );
2190
- }
2191
- /**
2192
- * Fetch a zero-filled event-count timeseries (24h or 30d).
2193
- */
2194
- async getStats(projectId, issueId, window = "24h") {
2195
- return this.request(
2196
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/stats`, {
2197
- searchParams: { window }
2198
- }),
2199
- issueStatsSchema
2200
- );
2201
- }
2202
- /**
2203
- * List an issue's activity log (status changes, comments/notes, …).
2204
- */
2205
- async getActivity(projectId, issueId) {
2206
- return this.request(
2207
- () => this.http.get(`api/projects/${projectId}/issues/${issueId}/activity`),
2208
- zod.z.array(activityEntrySchema)
2209
- );
2210
- }
2211
- /**
2212
- * Add a comment (note) to an issue.
2213
- */
2214
- async addComment(projectId, issueId, input) {
2215
- const validatedInput = this.validateInput(input, createCommentSchema);
2216
- if (!validatedInput.success) {
2217
- return validatedInput;
2218
- }
2219
- return this.request(
2220
- () => this.http.post(`api/projects/${projectId}/issues/${issueId}/comments`, {
2221
- json: validatedInput.data
2222
- }),
2223
- activityEntrySchema
2224
- );
2225
- }
2226
- /**
2227
- * Set or clear the current user's bookmark on an issue.
2228
- */
2229
- async setBookmark(projectId, issueId, enabled) {
2230
- return this.request(
2231
- () => this.http.put(`api/projects/${projectId}/issues/${issueId}/bookmark`, {
2232
- json: { enabled }
2233
- }),
2234
- zod.z.object({ is_bookmarked: zod.z.boolean() })
2235
- );
2236
- }
2237
- /**
2238
- * Set or clear the current user's subscription to an issue.
2239
- */
2240
- async setSubscription(projectId, issueId, enabled) {
2241
- return this.request(
2242
- () => this.http.put(
2243
- `api/projects/${projectId}/issues/${issueId}/subscription`,
2244
- { json: { enabled } }
2245
- ),
2246
- zod.z.object({ is_subscribed: zod.z.boolean() })
2247
- );
2248
- }
2249
- /**
2250
- * Mark the issue as seen by the current user.
2251
- */
2252
- async markSeen(projectId, issueId) {
2253
- return this.request(
2254
- () => this.http.post(`api/projects/${projectId}/issues/${issueId}/seen`),
2255
- zod.z.object({ has_seen: zod.z.boolean() })
2256
- );
2257
- }
2258
- /**
2259
- * List user feedback reports for an issue.
2260
- */
2261
- async listUserReports(projectId, issueId) {
2262
- return this.request(
2263
- () => this.http.get(
2264
- `api/projects/${projectId}/issues/${issueId}/user-reports`
2265
- ),
2266
- zod.z.array(userReportSchema)
2267
- );
2268
- }
2269
- /**
2270
- * Attach a user feedback report to an issue.
2271
- */
2272
- async createUserReport(projectId, issueId, input) {
2273
- const validatedInput = this.validateInput(input, createUserReportSchema);
2274
- if (!validatedInput.success) {
2275
- return validatedInput;
2276
- }
2277
- return this.request(
2278
- () => this.http.post(
2279
- `api/projects/${projectId}/issues/${issueId}/user-reports`,
2280
- { json: validatedInput.data }
2281
- ),
2282
- userReportSchema
2283
- );
2284
- }
2285
- };
2286
-
2287
- // src/resources/logs.ts
2288
- var LogsResource = class extends BaseResource {
2289
- /**
2290
- * List logs for a project with offset-based pagination (newest first by log
2291
- * timestamp), optionally filtered by level/trace_id.
2292
- */
2293
- async list(projectId, options) {
2294
- const searchParams = {};
2295
- if (options?.page) {
2296
- searchParams.page = String(options.page);
2297
- }
2298
- if (options?.per_page) {
2299
- searchParams.per_page = String(options.per_page);
2300
- }
2301
- if (options?.level) {
2302
- searchParams.level = options.level;
2303
- }
2304
- if (options?.trace_id) {
2305
- searchParams.trace_id = options.trace_id;
2306
- }
2307
- return this.request(
2308
- () => this.http.get(`api/projects/${projectId}/logs`, { searchParams }),
2309
- offsetPaginatedResponseSchema(logSchema)
2310
- );
2311
- }
2312
- };
2313
-
2314
- // src/resources/members.ts
2315
- var MembersResource = class extends BaseResource {
2316
- /**
2317
- * List members of a project
2318
- * @param projectId - ID of the project
2319
- */
2320
- async list(projectId) {
2321
- return this.request(
2322
- () => this.http.get(`api/projects/${projectId}/members`),
2323
- projectMemberSchema.array()
2324
- );
2325
- }
2326
- /**
2327
- * Add or update a project member
2328
- * @param projectId - ID of the project
2329
- * @param input - User ID and per-project role
2330
- */
2331
- async upsert(projectId, input) {
2332
- const validatedInput = this.validateInput(input, upsertProjectMemberSchema);
2333
- if (!validatedInput.success) {
2334
- return validatedInput;
2335
- }
2336
- return this.requestVoid(
2337
- () => this.http.put(`api/projects/${projectId}/members`, {
2338
- json: validatedInput.data
2339
- })
2340
- );
2341
- }
2342
- /**
2343
- * Remove a member from a project
2344
- * @param projectId - ID of the project
2345
- * @param userId - ID of the user to remove
2346
- */
2347
- async remove(projectId, userId) {
2348
- return this.requestVoid(
2349
- () => this.http.delete(`api/projects/${projectId}/members/${userId}`)
2350
- );
2351
- }
2352
- };
2353
- var MonitorsResource = class extends BaseResource {
2354
- /** Every monitor of a project, with its environments and recent check-ins. */
2355
- async list(projectId) {
2356
- return this.request(
2357
- () => this.http.get(`api/projects/${projectId}/monitors`),
2358
- zod.z.array(monitorSchema)
2359
- );
2360
- }
2361
- async get(projectId, slug) {
2362
- return this.request(
2363
- () => this.http.get(
2364
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
2365
- ),
2366
- monitorSchema
2367
- );
2368
- }
2369
- async create(projectId, input) {
2370
- const validated = this.validateInput(input, createMonitorSchema);
2371
- if (!validated.success) {
2372
- return validated;
2373
- }
2374
- return this.request(
2375
- () => this.http.post(`api/projects/${projectId}/monitors`, {
2376
- json: validated.data
2377
- }),
2378
- monitorSchema
2379
- );
2380
- }
2381
- /** Fields left out keep their value, including each field of `config`. */
2382
- async update(projectId, slug, input) {
2383
- const validated = this.validateInput(input, updateMonitorSchema);
2384
- if (!validated.success) {
2385
- return validated;
2386
- }
2387
- return this.request(
2388
- () => this.http.put(
2389
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`,
2390
- { json: validated.data }
2391
- ),
2392
- monitorSchema
2393
- );
2394
- }
2395
- /** Deletes the monitor and its check-ins. Its issues stay. */
2396
- async delete(projectId, slug) {
2397
- return this.requestVoid(
2398
- () => this.http.delete(
2399
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}`
2400
- )
2401
- );
2402
- }
2403
- /** Check-ins of one monitor, newest first. */
2404
- async listCheckIns(projectId, slug, options) {
2405
- const searchParams = {};
2406
- if (options?.page) {
2407
- searchParams.page = String(options.page);
2408
- }
2409
- if (options?.per_page) {
2410
- searchParams.per_page = String(options.per_page);
2411
- }
2412
- if (options?.environment) {
2413
- searchParams.environment = options.environment;
2414
- }
2415
- return this.request(
2416
- () => this.http.get(
2417
- `api/projects/${projectId}/monitors/${encodeURIComponent(slug)}/checkins`,
2418
- { searchParams }
2419
- ),
2420
- offsetPaginatedResponseSchema(checkInSchema)
2421
- );
2422
- }
2423
- };
2424
-
2425
- // src/resources/projects.ts
2426
- var ProjectsResource = class extends BaseResource {
2427
- /**
2428
- * List projects with pagination
2429
- */
2430
- async list(options) {
2431
- const searchParams = new URLSearchParams();
2432
- if (options?.page !== void 0) {
2433
- searchParams.set("page", options.page.toString());
2434
- }
2435
- if (options?.per_page !== void 0) {
2436
- searchParams.set("per_page", options.per_page.toString());
2437
- }
2438
- if (options?.order) {
2439
- searchParams.set("order", options.order);
2440
- }
2441
- if (options?.stats_period) {
2442
- searchParams.set("stats_period", options.stats_period);
2443
- }
2444
- const query = searchParams.toString();
2445
- const url = query ? `api/projects?${query}` : "api/projects";
2446
- return this.request(
2447
- () => this.http.get(url),
2448
- offsetPaginatedResponseSchema(projectSchema)
2449
- );
2450
- }
2451
- /**
2452
- * The server's per-project limits, which a project without its own follows
2453
- */
2454
- async rateLimits() {
2455
- return this.request(
2456
- () => this.http.get("api/rate-limits"),
2457
- rateLimitsSchema
2458
- );
2459
- }
2460
- /**
2461
- * Get a single project by ID
2462
- */
2463
- async get(id) {
2464
- return this.request(
2465
- () => this.http.get(`api/projects/${id}`),
2466
- projectSchema
2467
- );
2468
- }
2469
- /**
2470
- * Create a new project
2471
- */
2472
- async create(input) {
2473
- const validatedInput = this.validateInput(input, createProjectSchema);
2474
- if (!validatedInput.success) {
2475
- return validatedInput;
2476
- }
2477
- return this.request(
2478
- () => this.http.post("api/projects", { json: validatedInput.data }),
2479
- projectSchema
2480
- );
2481
- }
2482
- /**
2483
- * Update an existing project
2484
- */
2485
- async update(id, input) {
2486
- const validatedInput = this.validateInput(input, updateProjectSchema);
2487
- if (!validatedInput.success) {
2488
- return validatedInput;
2489
- }
2490
- return this.request(
2491
- () => this.http.patch(`api/projects/${id}`, { json: validatedInput.data }),
2492
- projectSchema
2493
- );
2494
- }
2495
- /**
2496
- * Delete a project
2497
- */
2498
- async delete(id) {
2499
- return this.requestVoid(() => this.http.delete(`api/projects/${id}`));
2500
- }
2501
- };
2502
- var ReleasesResource = class extends BaseResource {
2503
- /**
2504
- * Get issues first seen in a given release, most recently introduced first.
2505
- *
2506
- * @param projectId - Project ID
2507
- * @param release - Release version
2508
- * @param limit - Max issues to return (default: 10, max: 50)
2509
- */
2510
- async newIssues(projectId, release, limit) {
2511
- const searchParams = {};
2512
- if (limit !== void 0) {
2513
- searchParams.limit = limit.toString();
2514
- }
2515
- return this.request(
2516
- () => this.http.get(
2517
- `api/projects/${projectId}/releases/${encodeURIComponent(release)}/new-issues`,
2518
- { searchParams }
2519
- ),
2520
- zod.z.array(issueSchema)
2521
- );
2522
- }
2523
- };
2524
-
2525
- // src/resources/schedules.ts
2526
- var SchedulesResource = class extends BaseResource {
2527
- /** Validates a schedule and lists its next five runs. */
2528
- async preview(input) {
2529
- const validated = this.validateInput(input, previewScheduleSchema);
2530
- if (!validated.success) {
2531
- return validated;
2532
- }
2533
- return this.request(
2534
- () => this.http.post("api/schedules/preview", { json: validated.data }),
2535
- schedulePreviewSchema
2536
- );
2537
- }
2538
- };
2539
-
2540
- // src/resources/sessions.ts
2541
- var SessionsResource = class extends BaseResource {
2542
- /**
2543
- * Get per-release health stats for a project, one offset-based page of
2544
- * (release, environment) rows at a time, ordered by session volume.
2545
- * @param projectId - Project ID
2546
- * @param options - Time window, release scoping and pagination.
2547
- */
2548
- async stats(projectId, options) {
2549
- const searchParams = {};
2550
- if (options?.period) {
2551
- searchParams.period = options.period;
2552
- }
2553
- if (options?.release) {
2554
- searchParams.release = options.release;
2555
- }
2556
- if (options?.page) {
2557
- searchParams.page = String(options.page);
2558
- }
2559
- if (options?.per_page) {
2560
- searchParams.per_page = String(options.per_page);
2561
- }
2562
- return this.request(
2563
- () => this.http.get(`api/projects/${projectId}/sessions/stats`, {
2564
- searchParams
2565
- }),
2566
- offsetPaginatedResponseSchema(releaseHealthRowSchema)
2567
- );
2568
- }
2569
- /**
2570
- * Get project-wide session health, aggregated across all releases and environments.
2571
- * @param projectId - Project ID
2572
- * @param period - Time window (e.g. '24h', '7d'). Defaults to '24h'.
2573
- */
2574
- async summary(projectId, period) {
2575
- const searchParams = {};
2576
- if (period) {
2577
- searchParams.period = period;
2578
- }
2579
- return this.request(
2580
- () => this.http.get(`api/projects/${projectId}/sessions/summary`, {
2581
- searchParams
2582
- }),
2583
- sessionSummarySchema
2584
- );
2585
- }
2586
- /**
2587
- * Get a time-bucketed session trend for a project, aggregated across all
2588
- * releases and environments.
2589
- * @param projectId - Project ID
2590
- * @param period - Time window (e.g. '24h', '7d'). Defaults to '24h'.
2591
- * @param interval - Bucket width in hours (default: 1, max: 24).
2592
- */
2593
- async timeseries(projectId, period, interval) {
2594
- const searchParams = {};
2595
- if (period) {
2596
- searchParams.period = period;
2597
- }
2598
- if (interval !== void 0) {
2599
- searchParams.interval = interval.toString();
2600
- }
2601
- return this.request(
2602
- () => this.http.get(`api/projects/${projectId}/sessions/timeseries`, {
2603
- searchParams
2604
- }),
2605
- sessionTimeseriesSchema
2606
- );
2607
- }
2608
- };
2609
-
2610
- // src/resources/sourcemaps.ts
2611
- var SourceMapsResource = class extends BaseResource {
2612
- /**
2613
- * Get chunk upload capabilities for an organization.
2614
- * Returns the upload URL, chunk size limits, and accepted artifact types.
2615
- */
2616
- async getChunkUploadCapability(orgSlug) {
2617
- return this.request(
2618
- () => this.http.get(`api/0/organizations/${orgSlug}/chunk-upload/`),
2619
- chunkUploadCapabilitySchema
2620
- );
2621
- }
2622
- /**
2623
- * Upload chunks as multipart/form-data, batching by `chunksPerRequest` (default 64).
2624
- * Each part's field name must be the pre-computed SHA-1 hash of its content — the server
2625
- * rejects mismatches with 400. Callers must supply the hash (also needed for assembleBundle).
2626
- */
2627
- async uploadChunks(orgSlug, chunks, chunksPerRequest = 64) {
2628
- if (!Number.isInteger(chunksPerRequest) || chunksPerRequest <= 0) {
2629
- return Err({
2630
- kind: "invalid_request",
2631
- message: "chunksPerRequest must be a positive integer."
2632
- });
2633
- }
2634
- for (let i = 0; i < chunks.length; i += chunksPerRequest) {
2635
- const batch = chunks.slice(i, i + chunksPerRequest);
2636
- const form = new FormData();
2637
- for (const chunk of batch) {
2638
- form.append(chunk.hash, chunk.data);
2639
- }
2640
- const uploaded = await this.requestVoid(
2641
- () => this.http.post(`api/0/organizations/${orgSlug}/chunk-upload/`, {
2642
- body: form
2643
- })
2644
- );
2645
- if (!uploaded.success) {
2646
- return uploaded;
2647
- }
2648
- }
2649
- return Ok(void 0);
2650
- }
2651
- /**
2652
- * Trigger assembly of a previously uploaded artifact bundle.
2653
- *
2654
- * @returns The assembly state. Poll until `state === "ok"` or `state === "error"`.
2655
- * When `state === "not_found"` the `missingChunks` array lists what
2656
- * still needs uploading via `uploadChunks`.
2657
- */
2658
- async assembleBundle(orgSlug, input) {
2659
- const validatedInput = this.validateInput(input, assembleInputSchema);
2660
- if (!validatedInput.success) {
2661
- return validatedInput;
2662
- }
2663
- return this.request(
2664
- () => this.http.post(
2665
- `api/0/organizations/${orgSlug}/artifactbundle/assemble/`,
2666
- { json: validatedInput.data }
2667
- ),
2668
- assembleResponseSchema
2669
- );
2670
- }
2671
- /**
2672
- * List all source map files uploaded for a project.
2673
- */
2674
- async list(orgSlug, projectSlug) {
2675
- return this.request(
2676
- () => this.http.get(
2677
- `api/0/projects/${orgSlug}/${projectSlug}/files/source-maps/`
2678
- ),
2679
- listSourceMapsResponseSchema
2680
- );
2681
- }
2682
- };
2683
-
2684
- // src/resources/spans.ts
2685
- var SpansResource = class extends BaseResource {
2686
- /**
2687
- * List spans for a project with offset-based pagination (newest first),
2688
- * optionally filtered by op/status/trace_id/operation_type.
2689
- */
2690
- async list(projectId, options) {
2691
- const searchParams = {};
2692
- if (options?.page) {
2693
- searchParams.page = String(options.page);
2694
- }
2695
- if (options?.per_page) {
2696
- searchParams.per_page = String(options.per_page);
2697
- }
2698
- if (options?.op) {
2699
- searchParams.op = options.op;
2700
- }
2701
- if (options?.status) {
2702
- searchParams.status = options.status;
2703
- }
2704
- if (options?.trace_id) {
2705
- searchParams.trace_id = options.trace_id;
2706
- }
2707
- if (options?.operation_type) {
2708
- searchParams.operation_type = options.operation_type;
2709
- }
2710
- return this.request(
2711
- () => this.http.get(`api/projects/${projectId}/spans`, { searchParams }),
2712
- offsetPaginatedResponseSchema(spanSchema)
2713
- );
2714
- }
2715
- /**
2716
- * Fetch one span together with its raw attribute bag — the `gen_ai.*`
2717
- * payload (prompts, responses, tool arguments and results) that `list()`
2718
- * omits so a trace's worth of spans stays cheap to load.
2719
- *
2720
- * `spanId` is the row id from a list item's `id`, not the SDK's 16-hex
2721
- * `span_id`.
2722
- */
2723
- async get(projectId, spanId) {
2724
- return this.request(
2725
- () => this.http.get(`api/projects/${projectId}/spans/${spanId}`),
2726
- spanDetailSchema
2727
- );
2728
- }
2729
- };
2730
-
2731
- // src/resources/stats.ts
2732
- var StatsResource = class extends BaseResource {
2733
- /**
2734
- * Get time-bucketed error-event volume for a project, split by severity.
2735
- *
2736
- * Buckets are zero-filled across the window, so a quiet hour comes back as a
2737
- * point with `total: 0` rather than being absent. All-time requests (no
2738
- * `period`) are sparse: there is no lower bound to fill from.
2739
- *
2740
- * @param projectId - Project ID
2741
- * @param period - Time window (e.g. '24h', '7d'). Omit for all time.
2742
- * @param interval - Bucket width in hours (default: 1, max: 24).
2743
- */
2744
- async timeseries(projectId, period, interval) {
2745
- const searchParams = {};
2746
- if (period) {
2747
- searchParams.period = period;
2748
- }
2749
- if (interval !== void 0) {
2750
- searchParams.interval = interval.toString();
2751
- }
2752
- return this.request(
2753
- () => this.http.get(`api/projects/${projectId}/events/stats`, {
2754
- searchParams
2755
- }),
2756
- eventTimeseriesSchema
2757
- );
2758
- }
2759
- /**
2760
- * Get project-wide counters for a window, each paired with the same counter
2761
- * over the window immediately before it.
2762
- *
2763
- * @param projectId - Project ID
2764
- * @param period - Time window (e.g. '24h', '7d'). Omit for all time, which
2765
- * leaves every `previous` null.
2766
- */
2767
- async summary(projectId, period) {
2768
- const searchParams = {};
2769
- if (period) {
2770
- searchParams.period = period;
2771
- }
2772
- return this.request(
2773
- () => this.http.get(`api/projects/${projectId}/stats/summary`, {
2774
- searchParams
2775
- }),
2776
- projectStatsSummarySchema
2777
- );
2778
- }
2779
- };
2780
- var StorageResource = class extends BaseResource {
2781
- /**
2782
- * Get the instance-wide storage summary: row counts per data category, the
2783
- * whole-DB size, and exact source-map weight.
2784
- */
2785
- async getSummary() {
2786
- return this.request(
2787
- () => this.http.get("api/storage/summary"),
2788
- storageSummarySchema
2789
- );
2790
- }
2791
- /**
2792
- * Get the per-project storage breakdown (one row per project, including
2793
- * empty ones).
2794
- */
2795
- async getProjects() {
2796
- return this.request(
2797
- () => this.http.get("api/storage/projects"),
2798
- zod.z.array(projectStorageSchema)
2799
- );
2800
- }
2801
- /**
2802
- * Dry-run: count the rows a cleanup would remove. Mutates nothing — use it to
2803
- * confirm impact before {@link executeCleanup}.
2804
- */
2805
- async previewCleanup(options) {
2806
- const validatedInput = this.validateInput(options, cleanupOptionsSchema);
2807
- if (!validatedInput.success) {
2808
- return validatedInput;
2809
- }
2810
- return this.request(
2811
- () => this.http.post("api/storage/cleanup/preview", {
2812
- json: validatedInput.data
2813
- }),
2814
- cleanupCountsSchema
2815
- );
2816
- }
2817
- /**
2818
- * Start a cleanup: delete data older than `older_than_days` (optionally
2819
- * scoped to one project) and remove the issues it leaves with zero events.
2820
- *
2821
- * Returns as soon as the server has started it, with the `running` status.
2822
- * The deletion runs in the background; follow it with
2823
- * {@link getCleanupStatus}. A second start while one is running fails with
2824
- * a `conflict`.
2825
- */
2826
- async executeCleanup(options) {
2827
- const validatedInput = this.validateInput(options, cleanupOptionsSchema);
2828
- if (!validatedInput.success) {
2829
- return validatedInput;
2830
- }
2831
- return this.request(
2832
- () => this.http.post("api/storage/cleanup", {
2833
- json: validatedInput.data,
2834
- // No retry: if the first attempt started the cleanup and only its
2835
- // response was lost, a retry would be refused as a second run and
2836
- // report a failure for a cleanup that is in fact running.
2837
- retry: 0
2838
- }),
2839
- cleanupStatusSchema
2840
- );
2841
- }
2842
- /**
2843
- * The running cleanup's progress, or the outcome of the last one.
2844
- */
2845
- async getCleanupStatus() {
2846
- return this.request(
2847
- () => this.http.get("api/storage/cleanup/status"),
2848
- cleanupStatusSchema
2849
- );
2850
- }
2851
- /**
2852
- * Dry-run for {@link gcSourceMaps}: count the orphaned source-map files and
2853
- * bytes a GC would reclaim. Mutates nothing.
2854
- */
2855
- async previewGcSourceMaps() {
2856
- return this.request(
2857
- () => this.http.post("api/storage/source-maps/gc/preview"),
2858
- sourceMapGcResultSchema
2859
- );
2860
- }
2861
- /**
2862
- * Garbage-collect orphaned source maps: files no longer referenced by any
2863
- * upload, removed from the DB and unlinked from disk. Safe — never touches
2864
- * referenced files.
2865
- */
2866
- async gcSourceMaps() {
2867
- return this.request(
2868
- () => this.http.post("api/storage/source-maps/gc"),
2869
- sourceMapGcResultSchema
2870
- );
2871
- }
2872
- /**
2873
- * Retention: how long each kind of data is kept, by default and per
2874
- * project, when its cleanup runs next and how the last one went.
2875
- */
2876
- async getRetention() {
2877
- return this.request(
2878
- () => this.http.get("api/storage/retention"),
2879
- retentionSchema
2880
- );
2881
- }
2882
- /** Replaces the retention settings. A new schedule applies within a minute. */
2883
- async updateRetention(settings) {
2884
- const validated = this.validateInput(settings, retentionSettingsSchema);
2885
- if (!validated.success) {
2886
- return validated;
2887
- }
2888
- return this.request(
2889
- () => this.http.put("api/storage/retention", { json: validated.data }),
2890
- retentionSchema
2891
- );
2892
- }
2893
- /**
2894
- * Enforces the saved retention now, without waiting for the schedule, and
2895
- * deletes unused source maps. Returns the started job; follow it with
2896
- * {@link getCleanupStatus}. A `validation` error while everything is kept
2897
- * forever, `conflict` while a cleanup runs.
2898
- */
2899
- async runRetention() {
2900
- return this.request(
2901
- () => this.http.post("api/storage/retention/run", {
2902
- // No retry, as for `executeCleanup`: a lost response after the
2903
- // cleanup started would be retried into a refused second run.
2904
- retry: 0
2905
- }),
2906
- cleanupStatusSchema
2907
- );
2908
- }
2909
- /** How long ago each project's data arrived, per kind, in age buckets. */
2910
- async getAge() {
2911
- return this.request(
2912
- () => this.http.get("api/storage/age"),
2913
- storageAgeSchema
2914
- );
2915
- }
2916
- /**
2917
- * Dry-run: what enforcing these retention settings now would delete, each
2918
- * project against its own windows. Saves and deletes nothing.
2919
- */
2920
- async previewRetention(settings) {
2921
- const validated = this.validateInput(settings, retentionSettingsSchema);
2922
- if (!validated.success) {
2923
- return validated;
2924
- }
2925
- return this.request(
2926
- () => this.http.post("api/storage/retention/preview", {
2927
- json: validated.data
2928
- }),
2929
- cleanupCountsSchema
2930
- );
2931
- }
2932
- };
2933
-
2934
- // src/resources/team.ts
2935
- var TeamResource = class extends BaseResource {
2936
- /**
2937
- * List all team members (users)
2938
- */
2939
- async list() {
2940
- return this.request(
2941
- () => this.http.get("api/team"),
2942
- teamMemberSchema.array()
2943
- );
2944
- }
2945
- /**
2946
- * Change a user's global role
2947
- * @param userId - ID of the user to update
2948
- * @param role - New global role to assign
2949
- */
2950
- async updateRole(userId, role) {
2951
- const body = this.validateInput({ role }, updateUserRoleSchema);
2952
- if (!body.success) {
2953
- return body;
2954
- }
2955
- return this.requestVoid(
2956
- () => this.http.patch(`api/team/${userId}/role`, { json: body.data })
2957
- );
2958
- }
2959
- /**
2960
- * Permanently remove a user from the instance.
2961
- * @param userId - ID of the user to delete
2962
- */
2963
- async remove(userId) {
2964
- return this.requestVoid(() => this.http.delete(`api/team/${userId}`));
2965
- }
2966
- };
2967
-
2968
- // src/resources/tokens.ts
2969
- var TokensResource = class extends BaseResource {
2970
- /**
2971
- * List all auth tokens (masked)
2972
- */
2973
- async list() {
2974
- return this.request(
2975
- () => this.http.get("api/tokens"),
2976
- authTokenSchema.array()
2977
- );
2978
- }
2979
- /**
2980
- * Get a single auth token by ID (full token value).
2981
- *
2982
- * Previously returned a masked version, but the server now returns the
2983
- * complete token for GET /api/tokens/{id}.
2984
- */
2985
- async get(id) {
2986
- return this.request(
2987
- () => this.http.get(`api/tokens/${id}`),
2988
- authTokenCreatedSchema
2989
- );
2990
- }
2991
- /**
2992
- * Create a new auth token
2993
- * Note: The full token is only returned once during creation
2994
- */
2995
- async create(input) {
2996
- const validatedInput = this.validateInput(input, createAuthTokenSchema);
2997
- if (!validatedInput.success) {
2998
- return validatedInput;
2999
- }
3000
- return this.request(
3001
- () => this.http.post("api/tokens", { json: validatedInput.data }),
3002
- authTokenCreatedSchema
3003
- );
3004
- }
3005
- /**
3006
- * Delete an auth token
3007
- */
3008
- async delete(id) {
3009
- return this.requestVoid(() => this.http.delete(`api/tokens/${id}`));
3010
- }
3011
- };
3012
- var TransactionsResource = class extends BaseResource {
3013
- /**
3014
- * List transactions for a project with offset-based pagination (newest first)
3015
- */
3016
- async list(projectId, options) {
3017
- const searchParams = {};
3018
- if (options?.page) {
3019
- searchParams.page = String(options.page);
3020
- }
3021
- if (options?.per_page) {
3022
- searchParams.per_page = String(options.per_page);
3023
- }
3024
- if (options?.name) {
3025
- searchParams.name = options.name;
3026
- }
3027
- if (options?.op) {
3028
- searchParams.op = options.op;
3029
- }
3030
- if (options?.status) {
3031
- searchParams.status = options.status;
3032
- }
3033
- if (options?.environment) {
3034
- searchParams.environment = options.environment;
3035
- }
3036
- if (options?.release) {
3037
- searchParams.release = options.release;
3038
- }
3039
- return this.request(
3040
- () => this.http.get(`api/projects/${projectId}/transactions`, {
3041
- searchParams
3042
- }),
3043
- offsetPaginatedResponseSchema(transactionSchema)
3044
- );
3045
- }
3046
- /**
3047
- * Get the indexed spans extracted from a transaction, in waterfall order.
3048
- */
3049
- async getSpans(projectId, transactionId) {
3050
- return this.request(
3051
- () => this.http.get(
3052
- `api/projects/${projectId}/transactions/${transactionId}/spans`
3053
- ),
3054
- zod.z.array(spanSchema)
3055
- );
3056
- }
3057
- /**
3058
- * Get aggregate performance stats (count, p50/p95/p99 latency, failure rate)
3059
- * grouped by transaction name + op, most frequent first, with offset-based
3060
- * pagination — same shape as the other list endpoints.
3061
- */
3062
- async getStats(projectId, options) {
3063
- const searchParams = {};
3064
- if (options?.page) {
3065
- searchParams.page = String(options.page);
3066
- }
3067
- if (options?.per_page) {
3068
- searchParams.per_page = String(options.per_page);
3069
- }
3070
- return this.request(
3071
- () => this.http.get(`api/projects/${projectId}/transactions/stats`, {
3072
- searchParams
3073
- }),
3074
- offsetPaginatedResponseSchema(transactionStatsSchema)
3075
- );
3076
- }
3077
- /**
3078
- * Get aggregate stats for a single (transaction name, op) group — a direct
3079
- * lookup that works regardless of how many groups the project has. Reports
3080
- * `not_found` when the group has no transactions.
3081
- */
3082
- async getStatForGroup(projectId, name, op) {
3083
- const searchParams = { name };
3084
- if (op) {
3085
- searchParams.op = op;
3086
- }
3087
- return this.request(
3088
- () => this.http.get(`api/projects/${projectId}/transactions/stats/group`, {
3089
- searchParams
3090
- }),
3091
- transactionStatsSchema
3092
- );
3093
- }
3094
- /**
3095
- * Get a single transaction by ID with its full Sentry payload (spans,
3096
- * contexts.trace, measurements, tags) for the performance detail view.
3097
- */
3098
- async get(projectId, transactionId) {
3099
- return this.request(
3100
- () => this.http.get(
3101
- `api/projects/${projectId}/transactions/${transactionId}`
3102
- ),
3103
- transactionDetailSchema
3104
- );
3105
- }
3106
- };
3107
-
3108
- // src/client.ts
3109
- var RustrakClient = class {
3110
- http;
3111
- /**
3112
- * Authentication API resource
3113
- */
3114
- auth;
3115
- /**
3116
- * Projects API resource
3117
- */
3118
- projects;
3119
- /**
3120
- * Issues API resource
3121
- */
3122
- issues;
3123
- /**
3124
- * Events API resource
3125
- */
3126
- events;
3127
- /**
3128
- * Auth Tokens API resource
3129
- */
3130
- tokens;
3131
- /**
3132
- * Alert Integrations API resource (global credential destinations)
3133
- */
3134
- alertIntegrations;
3135
- /**
3136
- * Alert Rules API resource (per-project alert configuration)
3137
- */
3138
- alertRules;
3139
- /**
3140
- * Source Maps API resource (sentry-cli artifact bundle upload protocol)
3141
- */
3142
- sourceMaps;
3143
- /**
3144
- * Team API resource (global user roster and roles)
3145
- */
3146
- team;
3147
- /**
3148
- * Invitations API resource (pending user invitations)
3149
- */
3150
- invitations;
3151
- /**
3152
- * Project Members API resource (per-project membership and roles)
3153
- */
3154
- members;
3155
- /**
3156
- * Sessions API resource (release health)
3157
- */
3158
- sessions;
3159
- /**
3160
- * Releases API resource (data scoped to a specific release)
3161
- */
3162
- releases;
3163
- /**
3164
- * Transactions API resource (performance monitoring)
3165
- */
3166
- transactions;
3167
- /**
3168
- * Logs API resource (standalone logs)
3169
- */
3170
- logs;
3171
- /**
3172
- * Cron monitors API resource (Sentry Crons)
3173
- */
3174
- monitors;
3175
- /**
3176
- * Schedules API resource (previews for crontab/interval schedules)
3177
- */
3178
- schedules;
3179
- /**
3180
- * Spans API resource (standalone + transaction-embedded spans, shared table)
3181
- */
3182
- spans;
3183
- /**
3184
- * AI Agent Monitoring dashboard API resource
3185
- */
3186
- agents;
3187
- /**
3188
- * Stats API resource (project-wide overview aggregates)
3189
- */
3190
- stats;
3191
- /**
3192
- * Storage API resource (usage + retention cleanup, admin only)
3193
- */
3194
- storage;
3195
- /**
3196
- * Health API resource (version info)
3197
- */
3198
- health;
3199
- /**
3200
- * GitHub integration resource
3201
- */
3202
- github;
3203
- /**
3204
- * Create a new Rustrak API client
3205
- *
3206
- * @param config - Client configuration
3207
- */
3208
- constructor(config) {
3209
- this.http = createKyInstance(config);
3210
- this.auth = new AuthResource(this.http);
3211
- this.projects = new ProjectsResource(this.http);
3212
- this.issues = new IssuesResource(this.http);
3213
- this.events = new EventsResource(this.http);
3214
- this.tokens = new TokensResource(this.http);
3215
- this.github = new GitHubResource(this.http);
3216
- this.alertIntegrations = new AlertIntegrationsResource(this.http);
3217
- this.alertRules = new AlertRulesResource(this.http);
3218
- this.sourceMaps = new SourceMapsResource(this.http);
3219
- this.team = new TeamResource(this.http);
3220
- this.invitations = new InvitationsResource(this.http);
3221
- this.members = new MembersResource(this.http);
3222
- this.sessions = new SessionsResource(this.http);
3223
- this.releases = new ReleasesResource(this.http);
3224
- this.transactions = new TransactionsResource(this.http);
3225
- this.logs = new LogsResource(this.http);
3226
- this.monitors = new MonitorsResource(this.http);
3227
- this.schedules = new SchedulesResource(this.http);
3228
- this.spans = new SpansResource(this.http);
3229
- this.agents = new AgentsResource(this.http);
3230
- this.stats = new StatsResource(this.http);
3231
- this.storage = new StorageResource(this.http);
3232
- this.health = new HealthResource(this.http);
3233
- }
3234
- };
3235
-
3236
- exports.Err = Err;
3237
- exports.FIELD_ERROR_CODES = FIELD_ERROR_CODES;
3238
- exports.NETWORK_ERROR_MESSAGE = NETWORK_ERROR_MESSAGE;
3239
- exports.Ok = Ok;
3240
- exports.RustrakClient = RustrakClient;
3241
- exports.SERVER_ERROR_MESSAGE = SERVER_ERROR_MESSAGE;
3242
- exports.TIMEOUT_ERROR_MESSAGE = TIMEOUT_ERROR_MESSAGE;
3243
- exports.isRetryable = isRetryable;
3244
- exports.mapResult = mapResult;
3245
- exports.unwrap = unwrap;
3246
- exports.unwrapOr = unwrapOr;
3247
- //# sourceMappingURL=index.cjs.map
3248
- //# sourceMappingURL=index.cjs.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_result = require("./result.cjs");
3
+ const require_errors = require("./errors.cjs");
4
+ const require_client = require("./client.cjs");
5
+ exports.Err = require_result.Err;
6
+ exports.FIELD_ERROR_CODES = require_errors.FIELD_ERROR_CODES;
7
+ exports.NETWORK_ERROR_MESSAGE = require_errors.NETWORK_ERROR_MESSAGE;
8
+ exports.Ok = require_result.Ok;
9
+ exports.RustrakClient = require_client.RustrakClient;
10
+ exports.SERVER_ERROR_MESSAGE = require_errors.SERVER_ERROR_MESSAGE;
11
+ exports.TIMEOUT_ERROR_MESSAGE = require_errors.TIMEOUT_ERROR_MESSAGE;
12
+ exports.isRetryable = require_errors.isRetryable;
13
+ exports.mapResult = require_result.mapResult;
14
+ exports.unwrap = require_result.unwrap;
15
+ exports.unwrapOr = require_result.unwrapOr;