@codmir/sdk 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +206 -0
- package/dist/browser/index.cjs +409 -0
- package/dist/browser/index.d.cts +47 -0
- package/dist/browser/index.d.ts +47 -0
- package/dist/browser/index.js +186 -0
- package/dist/chunk-233XBWQD.js +43 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-T7OAAOG2.js +235 -0
- package/dist/chunk-X6Y5XEK5.js +255 -0
- package/dist/client.cjs +315 -0
- package/dist/client.d.cts +52 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.js +10 -0
- package/dist/index-BlgYnCLd.d.cts +171 -0
- package/dist/index-BlgYnCLd.d.ts +171 -0
- package/dist/index.cjs +540 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/nextjs/index.cjs +371 -0
- package/dist/nextjs/index.d.cts +77 -0
- package/dist/nextjs/index.d.ts +77 -0
- package/dist/nextjs/index.js +142 -0
- package/dist/overseer/index.cjs +250 -0
- package/dist/overseer/index.d.cts +1 -0
- package/dist/overseer/index.d.ts +1 -0
- package/dist/overseer/index.js +27 -0
- package/dist/react-native/index.cjs +356 -0
- package/dist/react-native/index.d.cts +95 -0
- package/dist/react-native/index.d.ts +95 -0
- package/dist/react-native/index.js +128 -0
- package/dist/replay/index.cjs +284 -0
- package/dist/replay/index.d.cts +206 -0
- package/dist/replay/index.d.ts +206 -0
- package/dist/replay/index.js +258 -0
- package/dist/types.cjs +69 -0
- package/dist/types.d.cts +281 -0
- package/dist/types.d.ts +281 -0
- package/dist/types.js +11 -0
- package/package.json +116 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
CodmirApiError: () => CodmirApiError,
|
|
24
|
+
CodmirClient: () => CodmirClient,
|
|
25
|
+
CreateAgentTaskSchema: () => CreateAgentTaskSchema,
|
|
26
|
+
CreateTicketSchema: () => CreateTicketSchema,
|
|
27
|
+
Overseer: () => overseer_exports,
|
|
28
|
+
default: () => client_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
|
+
|
|
32
|
+
// src/types.ts
|
|
33
|
+
var import_zod = require("zod");
|
|
34
|
+
var CodmirApiError = class extends Error {
|
|
35
|
+
constructor(code, message, statusCode, details) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.statusCode = statusCode;
|
|
39
|
+
this.details = details;
|
|
40
|
+
this.name = "CodmirApiError";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var CreateTicketSchema = import_zod.z.object({
|
|
44
|
+
title: import_zod.z.string().min(1).max(200),
|
|
45
|
+
description: import_zod.z.string().optional(),
|
|
46
|
+
status: import_zod.z.enum(["open", "in_progress", "review", "done", "closed"]).optional(),
|
|
47
|
+
priority: import_zod.z.enum(["low", "medium", "high", "critical"]).optional(),
|
|
48
|
+
type: import_zod.z.enum(["bug", "feature", "task", "improvement", "epic"]).optional(),
|
|
49
|
+
projectId: import_zod.z.string().uuid(),
|
|
50
|
+
assigneeId: import_zod.z.string().uuid().optional(),
|
|
51
|
+
labels: import_zod.z.array(import_zod.z.string()).optional(),
|
|
52
|
+
dueDate: import_zod.z.string().datetime().optional()
|
|
53
|
+
});
|
|
54
|
+
var CreateAgentTaskSchema = import_zod.z.object({
|
|
55
|
+
type: import_zod.z.enum([
|
|
56
|
+
"code_review",
|
|
57
|
+
"bug_fix",
|
|
58
|
+
"feature_implementation",
|
|
59
|
+
"refactor",
|
|
60
|
+
"documentation",
|
|
61
|
+
"test_generation",
|
|
62
|
+
"analysis",
|
|
63
|
+
"custom"
|
|
64
|
+
]),
|
|
65
|
+
prompt: import_zod.z.string().min(1),
|
|
66
|
+
context: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
67
|
+
projectId: import_zod.z.string().uuid().optional()
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// src/client.ts
|
|
71
|
+
var DEFAULT_BASE_URL = "https://codmir.com/api";
|
|
72
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
73
|
+
var CodmirClient = class {
|
|
74
|
+
baseUrl;
|
|
75
|
+
apiKey;
|
|
76
|
+
timeout;
|
|
77
|
+
headers;
|
|
78
|
+
constructor(config = {}) {
|
|
79
|
+
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
80
|
+
this.apiKey = config.apiKey || process.env.CODMIR_API_KEY;
|
|
81
|
+
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
82
|
+
this.headers = {
|
|
83
|
+
"Content-Type": "application/json",
|
|
84
|
+
...config.headers
|
|
85
|
+
};
|
|
86
|
+
if (this.apiKey) {
|
|
87
|
+
this.headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// ============================================
|
|
91
|
+
// HTTP Methods
|
|
92
|
+
// ============================================
|
|
93
|
+
async request(method, path, body) {
|
|
94
|
+
const url = `${this.baseUrl}${path}`;
|
|
95
|
+
const controller = new AbortController();
|
|
96
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
97
|
+
try {
|
|
98
|
+
const response = await fetch(url, {
|
|
99
|
+
method,
|
|
100
|
+
headers: this.headers,
|
|
101
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
102
|
+
signal: controller.signal
|
|
103
|
+
});
|
|
104
|
+
clearTimeout(timeoutId);
|
|
105
|
+
if (!response.ok) {
|
|
106
|
+
const errorData = await response.json().catch(() => ({}));
|
|
107
|
+
throw new CodmirApiError(
|
|
108
|
+
errorData.code || "API_ERROR",
|
|
109
|
+
errorData.message || `HTTP ${response.status}`,
|
|
110
|
+
response.status,
|
|
111
|
+
errorData.details
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return response.json();
|
|
115
|
+
} catch (error) {
|
|
116
|
+
clearTimeout(timeoutId);
|
|
117
|
+
if (error instanceof CodmirApiError) {
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
121
|
+
throw new CodmirApiError("TIMEOUT", "Request timed out", 408);
|
|
122
|
+
}
|
|
123
|
+
throw new CodmirApiError(
|
|
124
|
+
"NETWORK_ERROR",
|
|
125
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
get(path) {
|
|
130
|
+
return this.request("GET", path);
|
|
131
|
+
}
|
|
132
|
+
post(path, body) {
|
|
133
|
+
return this.request("POST", path, body);
|
|
134
|
+
}
|
|
135
|
+
patch(path, body) {
|
|
136
|
+
return this.request("PATCH", path, body);
|
|
137
|
+
}
|
|
138
|
+
delete(path) {
|
|
139
|
+
return this.request("DELETE", path);
|
|
140
|
+
}
|
|
141
|
+
// ============================================
|
|
142
|
+
// Auth
|
|
143
|
+
// ============================================
|
|
144
|
+
async whoami() {
|
|
145
|
+
const response = await this.get("/auth/me");
|
|
146
|
+
return response.data;
|
|
147
|
+
}
|
|
148
|
+
// ============================================
|
|
149
|
+
// Projects
|
|
150
|
+
// ============================================
|
|
151
|
+
async listProjects() {
|
|
152
|
+
const response = await this.get("/projects");
|
|
153
|
+
return response.data;
|
|
154
|
+
}
|
|
155
|
+
async getProject(projectId) {
|
|
156
|
+
const response = await this.get(`/projects/${projectId}`);
|
|
157
|
+
return response.data;
|
|
158
|
+
}
|
|
159
|
+
async createProject(input) {
|
|
160
|
+
const response = await this.post("/projects", input);
|
|
161
|
+
return response.data;
|
|
162
|
+
}
|
|
163
|
+
// ============================================
|
|
164
|
+
// Tickets
|
|
165
|
+
// ============================================
|
|
166
|
+
async listTickets(projectId, options) {
|
|
167
|
+
const params = new URLSearchParams();
|
|
168
|
+
if (options?.page) params.set("page", String(options.page));
|
|
169
|
+
if (options?.pageSize) params.set("pageSize", String(options.pageSize));
|
|
170
|
+
if (options?.status) params.set("status", options.status);
|
|
171
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
172
|
+
return this.get(`/projects/${projectId}/tickets${query}`);
|
|
173
|
+
}
|
|
174
|
+
async getTicket(projectId, ticketId) {
|
|
175
|
+
const response = await this.get(
|
|
176
|
+
`/projects/${projectId}/tickets/${ticketId}`
|
|
177
|
+
);
|
|
178
|
+
return response.data;
|
|
179
|
+
}
|
|
180
|
+
async createTicket(input) {
|
|
181
|
+
const response = await this.post(
|
|
182
|
+
`/projects/${input.projectId}/tickets`,
|
|
183
|
+
input
|
|
184
|
+
);
|
|
185
|
+
return response.data;
|
|
186
|
+
}
|
|
187
|
+
async updateTicket(projectId, ticketId, input) {
|
|
188
|
+
const response = await this.patch(
|
|
189
|
+
`/projects/${projectId}/tickets/${ticketId}`,
|
|
190
|
+
input
|
|
191
|
+
);
|
|
192
|
+
return response.data;
|
|
193
|
+
}
|
|
194
|
+
async deleteTicket(projectId, ticketId) {
|
|
195
|
+
await this.delete(`/projects/${projectId}/tickets/${ticketId}`);
|
|
196
|
+
}
|
|
197
|
+
// ============================================
|
|
198
|
+
// Test Cases
|
|
199
|
+
// ============================================
|
|
200
|
+
async listTestCases(projectId) {
|
|
201
|
+
const response = await this.get(
|
|
202
|
+
`/projects/${projectId}/test-cases`
|
|
203
|
+
);
|
|
204
|
+
return response.data;
|
|
205
|
+
}
|
|
206
|
+
async getTestCase(projectId, testCaseId) {
|
|
207
|
+
const response = await this.get(
|
|
208
|
+
`/projects/${projectId}/test-cases/${testCaseId}`
|
|
209
|
+
);
|
|
210
|
+
return response.data;
|
|
211
|
+
}
|
|
212
|
+
async createTestCase(input) {
|
|
213
|
+
const response = await this.post(
|
|
214
|
+
`/projects/${input.projectId}/test-cases`,
|
|
215
|
+
input
|
|
216
|
+
);
|
|
217
|
+
return response.data;
|
|
218
|
+
}
|
|
219
|
+
async updateTestCase(projectId, testCaseId, input) {
|
|
220
|
+
const response = await this.patch(
|
|
221
|
+
`/projects/${projectId}/test-cases/${testCaseId}`,
|
|
222
|
+
input
|
|
223
|
+
);
|
|
224
|
+
return response.data;
|
|
225
|
+
}
|
|
226
|
+
// ============================================
|
|
227
|
+
// Test Insights
|
|
228
|
+
// ============================================
|
|
229
|
+
async submitTestRunSummary(input) {
|
|
230
|
+
await this.post(`/projects/${input.projectId}/test-runs`, input);
|
|
231
|
+
}
|
|
232
|
+
async getCoverageInsights(request) {
|
|
233
|
+
const response = await this.post(
|
|
234
|
+
`/projects/${request.projectId}/coverage/insights`,
|
|
235
|
+
request
|
|
236
|
+
);
|
|
237
|
+
return response.data;
|
|
238
|
+
}
|
|
239
|
+
// ============================================
|
|
240
|
+
// Agent Tasks
|
|
241
|
+
// ============================================
|
|
242
|
+
async listAgentTasks(projectId) {
|
|
243
|
+
const path = projectId ? `/projects/${projectId}/agent/tasks` : "/agent/tasks";
|
|
244
|
+
const response = await this.get(path);
|
|
245
|
+
return response.data;
|
|
246
|
+
}
|
|
247
|
+
async getAgentTask(taskId) {
|
|
248
|
+
const response = await this.get(
|
|
249
|
+
`/agent/tasks/${taskId}`
|
|
250
|
+
);
|
|
251
|
+
return response.data;
|
|
252
|
+
}
|
|
253
|
+
async createAgentTask(input) {
|
|
254
|
+
const path = input.projectId ? `/projects/${input.projectId}/agent/tasks` : "/agent/tasks";
|
|
255
|
+
const response = await this.post(path, input);
|
|
256
|
+
return response.data;
|
|
257
|
+
}
|
|
258
|
+
async runAgentTask(input) {
|
|
259
|
+
const response = await this.post(
|
|
260
|
+
`/agent/tasks/${input.taskId}/run`,
|
|
261
|
+
input.options
|
|
262
|
+
);
|
|
263
|
+
return response.data;
|
|
264
|
+
}
|
|
265
|
+
async cancelAgentTask(taskId) {
|
|
266
|
+
const response = await this.post(
|
|
267
|
+
`/agent/tasks/${taskId}/cancel`
|
|
268
|
+
);
|
|
269
|
+
return response.data;
|
|
270
|
+
}
|
|
271
|
+
// ============================================
|
|
272
|
+
// AI Chat
|
|
273
|
+
// ============================================
|
|
274
|
+
async chat(message, options) {
|
|
275
|
+
const response = await this.post(
|
|
276
|
+
"/ai/chat",
|
|
277
|
+
{
|
|
278
|
+
message,
|
|
279
|
+
...options
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
return response.data.response;
|
|
283
|
+
}
|
|
284
|
+
async streamChat(message, options) {
|
|
285
|
+
const url = `${this.baseUrl}/ai/chat/stream`;
|
|
286
|
+
const response = await fetch(url, {
|
|
287
|
+
method: "POST",
|
|
288
|
+
headers: this.headers,
|
|
289
|
+
body: JSON.stringify({
|
|
290
|
+
message,
|
|
291
|
+
projectId: options?.projectId,
|
|
292
|
+
context: options?.context,
|
|
293
|
+
model: options?.model
|
|
294
|
+
})
|
|
295
|
+
});
|
|
296
|
+
if (!response.ok) {
|
|
297
|
+
throw new CodmirApiError("STREAM_ERROR", "Failed to start stream", response.status);
|
|
298
|
+
}
|
|
299
|
+
const reader = response.body?.getReader();
|
|
300
|
+
if (!reader) {
|
|
301
|
+
throw new CodmirApiError("STREAM_ERROR", "No response body");
|
|
302
|
+
}
|
|
303
|
+
const decoder = new TextDecoder();
|
|
304
|
+
let fullResponse = "";
|
|
305
|
+
while (true) {
|
|
306
|
+
const { done, value } = await reader.read();
|
|
307
|
+
if (done) break;
|
|
308
|
+
const chunk = decoder.decode(value);
|
|
309
|
+
fullResponse += chunk;
|
|
310
|
+
options?.onChunk?.(chunk);
|
|
311
|
+
}
|
|
312
|
+
return fullResponse;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
var client_default = CodmirClient;
|
|
316
|
+
|
|
317
|
+
// src/overseer/index.ts
|
|
318
|
+
var overseer_exports = {};
|
|
319
|
+
__export(overseer_exports, {
|
|
320
|
+
OverseerClient: () => OverseerClient,
|
|
321
|
+
addBreadcrumb: () => addBreadcrumb,
|
|
322
|
+
captureException: () => captureException,
|
|
323
|
+
captureMessage: () => captureMessage,
|
|
324
|
+
close: () => close,
|
|
325
|
+
flush: () => flush,
|
|
326
|
+
getClient: () => getClient,
|
|
327
|
+
init: () => init,
|
|
328
|
+
setTag: () => setTag,
|
|
329
|
+
setTags: () => setTags,
|
|
330
|
+
setUser: () => setUser
|
|
331
|
+
});
|
|
332
|
+
var import_nanoid = require("nanoid");
|
|
333
|
+
var OverseerClient = class {
|
|
334
|
+
config;
|
|
335
|
+
user = null;
|
|
336
|
+
tags = {};
|
|
337
|
+
breadcrumbs = [];
|
|
338
|
+
eventQueue = [];
|
|
339
|
+
flushTimer = null;
|
|
340
|
+
isInitialized = false;
|
|
341
|
+
constructor(config = {}) {
|
|
342
|
+
this.config = {
|
|
343
|
+
dsn: config.dsn || "",
|
|
344
|
+
environment: config.environment || "development",
|
|
345
|
+
release: config.release || "unknown",
|
|
346
|
+
enabled: config.enabled ?? true,
|
|
347
|
+
debug: config.debug ?? false,
|
|
348
|
+
sampleRate: config.sampleRate ?? 1,
|
|
349
|
+
tracesSampleRate: config.tracesSampleRate ?? 0,
|
|
350
|
+
replaysSessionSampleRate: config.replaysSessionSampleRate ?? 0,
|
|
351
|
+
replaysOnErrorSampleRate: config.replaysOnErrorSampleRate ?? 1,
|
|
352
|
+
beforeSend: config.beforeSend || ((e) => e),
|
|
353
|
+
initialUser: config.initialUser,
|
|
354
|
+
initialTags: config.initialTags || {}
|
|
355
|
+
};
|
|
356
|
+
if (this.config.initialUser) {
|
|
357
|
+
this.user = this.config.initialUser;
|
|
358
|
+
}
|
|
359
|
+
if (this.config.initialTags) {
|
|
360
|
+
this.tags = { ...this.config.initialTags };
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
init() {
|
|
364
|
+
if (this.isInitialized) return;
|
|
365
|
+
this.isInitialized = true;
|
|
366
|
+
if (this.config.debug) {
|
|
367
|
+
console.log("[Overseer] Initialized", {
|
|
368
|
+
dsn: this.config.dsn,
|
|
369
|
+
environment: this.config.environment
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
captureException(error, context) {
|
|
374
|
+
if (!this.config.enabled) return "";
|
|
375
|
+
if (!this.shouldSample(this.config.sampleRate)) return "";
|
|
376
|
+
const eventId = (0, import_nanoid.nanoid)();
|
|
377
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
378
|
+
const event = {
|
|
379
|
+
id: eventId,
|
|
380
|
+
type: "error",
|
|
381
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
382
|
+
level: "error",
|
|
383
|
+
message: err.message,
|
|
384
|
+
exception: {
|
|
385
|
+
type: err.name,
|
|
386
|
+
value: err.message,
|
|
387
|
+
stacktrace: this.parseStackTrace(err.stack),
|
|
388
|
+
mechanism: { type: "generic", handled: true }
|
|
389
|
+
},
|
|
390
|
+
user: this.user || void 0,
|
|
391
|
+
tags: { ...this.tags },
|
|
392
|
+
extra: context,
|
|
393
|
+
breadcrumbs: [...this.breadcrumbs],
|
|
394
|
+
environment: this.config.environment,
|
|
395
|
+
release: this.config.release,
|
|
396
|
+
sdk: { name: "@codmir/sdk", version: "1.0.0" }
|
|
397
|
+
};
|
|
398
|
+
this.sendEvent(event);
|
|
399
|
+
return eventId;
|
|
400
|
+
}
|
|
401
|
+
captureMessage(message, level = "info") {
|
|
402
|
+
if (!this.config.enabled) return "";
|
|
403
|
+
if (!this.shouldSample(this.config.sampleRate)) return "";
|
|
404
|
+
const eventId = (0, import_nanoid.nanoid)();
|
|
405
|
+
const event = {
|
|
406
|
+
id: eventId,
|
|
407
|
+
type: "message",
|
|
408
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
409
|
+
level,
|
|
410
|
+
message,
|
|
411
|
+
user: this.user || void 0,
|
|
412
|
+
tags: { ...this.tags },
|
|
413
|
+
breadcrumbs: [...this.breadcrumbs],
|
|
414
|
+
environment: this.config.environment,
|
|
415
|
+
release: this.config.release,
|
|
416
|
+
sdk: { name: "@codmir/sdk", version: "1.0.0" }
|
|
417
|
+
};
|
|
418
|
+
this.sendEvent(event);
|
|
419
|
+
return eventId;
|
|
420
|
+
}
|
|
421
|
+
setUser(user) {
|
|
422
|
+
this.user = user;
|
|
423
|
+
}
|
|
424
|
+
setTag(key, value) {
|
|
425
|
+
this.tags[key] = value;
|
|
426
|
+
}
|
|
427
|
+
setTags(tags) {
|
|
428
|
+
this.tags = { ...this.tags, ...tags };
|
|
429
|
+
}
|
|
430
|
+
setExtra(key, value) {
|
|
431
|
+
}
|
|
432
|
+
addBreadcrumb(breadcrumb) {
|
|
433
|
+
this.breadcrumbs.push({
|
|
434
|
+
...breadcrumb,
|
|
435
|
+
timestamp: breadcrumb.timestamp || (/* @__PURE__ */ new Date()).toISOString()
|
|
436
|
+
});
|
|
437
|
+
if (this.breadcrumbs.length > 100) {
|
|
438
|
+
this.breadcrumbs = this.breadcrumbs.slice(-100);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
async flush(timeout) {
|
|
442
|
+
if (this.eventQueue.length === 0) return true;
|
|
443
|
+
const events = [...this.eventQueue];
|
|
444
|
+
this.eventQueue = [];
|
|
445
|
+
try {
|
|
446
|
+
await this.sendBatch(events);
|
|
447
|
+
return true;
|
|
448
|
+
} catch {
|
|
449
|
+
this.eventQueue.unshift(...events);
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
close() {
|
|
454
|
+
if (this.flushTimer) {
|
|
455
|
+
clearTimeout(this.flushTimer);
|
|
456
|
+
}
|
|
457
|
+
this.flush();
|
|
458
|
+
}
|
|
459
|
+
// Private methods
|
|
460
|
+
shouldSample(rate) {
|
|
461
|
+
return Math.random() < rate;
|
|
462
|
+
}
|
|
463
|
+
parseStackTrace(stack) {
|
|
464
|
+
if (!stack) return [];
|
|
465
|
+
return stack.split("\n").slice(1).map((line) => {
|
|
466
|
+
const match = line.match(/at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)/);
|
|
467
|
+
if (match) {
|
|
468
|
+
return {
|
|
469
|
+
function: match[1],
|
|
470
|
+
filename: match[2],
|
|
471
|
+
lineno: parseInt(match[3], 10),
|
|
472
|
+
colno: parseInt(match[4], 10),
|
|
473
|
+
in_app: !match[2].includes("node_modules")
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
return { function: line.trim() };
|
|
477
|
+
}).filter((f) => f.function);
|
|
478
|
+
}
|
|
479
|
+
sendEvent(event) {
|
|
480
|
+
const processed = this.config.beforeSend(event);
|
|
481
|
+
if (!processed) return;
|
|
482
|
+
this.eventQueue.push(processed);
|
|
483
|
+
if (this.flushTimer) clearTimeout(this.flushTimer);
|
|
484
|
+
this.flushTimer = setTimeout(() => this.flush(), 1e3);
|
|
485
|
+
}
|
|
486
|
+
async sendBatch(events) {
|
|
487
|
+
if (!this.config.dsn) {
|
|
488
|
+
if (this.config.debug) {
|
|
489
|
+
console.log("[Overseer] No DSN configured, events:", events);
|
|
490
|
+
}
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const endpoint = this.config.dsn.endsWith("/ingest") ? this.config.dsn : `${this.config.dsn}/ingest`;
|
|
494
|
+
await fetch(endpoint, {
|
|
495
|
+
method: "POST",
|
|
496
|
+
headers: { "Content-Type": "application/json" },
|
|
497
|
+
body: JSON.stringify({ events })
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
var client = null;
|
|
502
|
+
function init(config = {}) {
|
|
503
|
+
client = new OverseerClient(config);
|
|
504
|
+
client.init();
|
|
505
|
+
}
|
|
506
|
+
function getClient() {
|
|
507
|
+
return client;
|
|
508
|
+
}
|
|
509
|
+
function captureException(error, context) {
|
|
510
|
+
return client?.captureException(error, context) || "";
|
|
511
|
+
}
|
|
512
|
+
function captureMessage(message, level) {
|
|
513
|
+
return client?.captureMessage(message, level) || "";
|
|
514
|
+
}
|
|
515
|
+
function setUser(user) {
|
|
516
|
+
client?.setUser(user);
|
|
517
|
+
}
|
|
518
|
+
function setTag(key, value) {
|
|
519
|
+
client?.setTag(key, value);
|
|
520
|
+
}
|
|
521
|
+
function setTags(tags) {
|
|
522
|
+
client?.setTags(tags);
|
|
523
|
+
}
|
|
524
|
+
function addBreadcrumb(breadcrumb) {
|
|
525
|
+
client?.addBreadcrumb(breadcrumb);
|
|
526
|
+
}
|
|
527
|
+
function flush(timeout) {
|
|
528
|
+
return client?.flush(timeout) || Promise.resolve(true);
|
|
529
|
+
}
|
|
530
|
+
function close() {
|
|
531
|
+
client?.close();
|
|
532
|
+
}
|
|
533
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
534
|
+
0 && (module.exports = {
|
|
535
|
+
CodmirApiError,
|
|
536
|
+
CodmirClient,
|
|
537
|
+
CreateAgentTaskSchema,
|
|
538
|
+
CreateTicketSchema,
|
|
539
|
+
Overseer
|
|
540
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as CodmirClient, default } from './client.cjs';
|
|
2
|
+
export { i as Overseer } from './index-BlgYnCLd.cjs';
|
|
3
|
+
export { AgentTask, AgentTaskResult, AgentTaskStatus, AgentTaskType, ApiResponse, CodmirApiError, CodmirClientConfig, CodmirError, CoverageFeatureBreakdown, CoverageInsight, CoverageInsightRequest, CoverageSuggestedTest, CreateAgentTaskInput, CreateAgentTaskSchema, CreateProjectInput, CreateTestCaseInput, CreateTicketInput, CreateTicketSchema, PaginatedResponse, Project, RunTaskInput, TaskExecution, TestCase, TestCasePriority, TestCaseStatus, TestCaseStep, TestCaseTemplate, TestRunArtifact, TestRunRecord, TestRunSummaryInput, Ticket, TicketPriority, TicketStatus, TicketType, UpdateTestCaseInput, UpdateTicketInput, User } from './types.cjs';
|
|
4
|
+
import 'zod';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as CodmirClient, default } from './client.js';
|
|
2
|
+
export { i as Overseer } from './index-BlgYnCLd.js';
|
|
3
|
+
export { AgentTask, AgentTaskResult, AgentTaskStatus, AgentTaskType, ApiResponse, CodmirApiError, CodmirClientConfig, CodmirError, CoverageFeatureBreakdown, CoverageInsight, CoverageInsightRequest, CoverageSuggestedTest, CreateAgentTaskInput, CreateAgentTaskSchema, CreateProjectInput, CreateTestCaseInput, CreateTicketInput, CreateTicketSchema, PaginatedResponse, Project, RunTaskInput, TaskExecution, TestCase, TestCasePriority, TestCaseStatus, TestCaseStep, TestCaseTemplate, TestRunArtifact, TestRunRecord, TestRunSummaryInput, Ticket, TicketPriority, TicketStatus, TicketType, UpdateTestCaseInput, UpdateTicketInput, User } from './types.js';
|
|
4
|
+
import 'zod';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodmirClient,
|
|
3
|
+
client_default
|
|
4
|
+
} from "./chunk-X6Y5XEK5.js";
|
|
5
|
+
import {
|
|
6
|
+
CodmirApiError,
|
|
7
|
+
CreateAgentTaskSchema,
|
|
8
|
+
CreateTicketSchema
|
|
9
|
+
} from "./chunk-233XBWQD.js";
|
|
10
|
+
import {
|
|
11
|
+
overseer_exports
|
|
12
|
+
} from "./chunk-T7OAAOG2.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
export {
|
|
15
|
+
CodmirApiError,
|
|
16
|
+
CodmirClient,
|
|
17
|
+
CreateAgentTaskSchema,
|
|
18
|
+
CreateTicketSchema,
|
|
19
|
+
overseer_exports as Overseer,
|
|
20
|
+
client_default as default
|
|
21
|
+
};
|