codmir 0.3.2 → 0.4.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.
@@ -0,0 +1,15 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+ var __commonJS = (cb, mod) => function __require2() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+
12
+ export {
13
+ __require,
14
+ __commonJS
15
+ };
@@ -9,6 +9,7 @@ var CodmirClient = class {
9
9
  };
10
10
  this.tickets = new TicketsAPI(this.config);
11
11
  this.testCases = new TestCasesAPI(this.config);
12
+ this.testing = new TestingAPI(this.config);
12
13
  }
13
14
  /**
14
15
  * Make an HTTP request to the codmir API
@@ -267,6 +268,75 @@ var TestCasesAPI = class {
267
268
  );
268
269
  }
269
270
  };
271
+ var TestingAPI = class {
272
+ constructor(config) {
273
+ this.config = config;
274
+ }
275
+ async request(method, path, body) {
276
+ const url = `${this.config.baseUrl}${path}`;
277
+ const headers = {
278
+ "Content-Type": "application/json",
279
+ ...this.config.headers
280
+ };
281
+ if (this.config.apiKey) {
282
+ headers["X-API-Key"] = this.config.apiKey;
283
+ }
284
+ const controller = new AbortController();
285
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
286
+ try {
287
+ const response = await fetch(url, {
288
+ method,
289
+ headers,
290
+ body: body ? JSON.stringify(body) : void 0,
291
+ signal: controller.signal
292
+ });
293
+ clearTimeout(timeoutId);
294
+ if (!response.ok) {
295
+ const errorData = await response.json().catch(() => ({}));
296
+ const error = new Error(errorData.error || `HTTP ${response.status}`);
297
+ error.statusCode = response.status;
298
+ error.response = errorData;
299
+ throw error;
300
+ }
301
+ if (response.status === 204) {
302
+ return {};
303
+ }
304
+ return await response.json();
305
+ } catch (error) {
306
+ clearTimeout(timeoutId);
307
+ if (error.name === "AbortError") {
308
+ const timeoutError = new Error("Request timeout");
309
+ timeoutError.statusCode = 408;
310
+ throw timeoutError;
311
+ }
312
+ throw error;
313
+ }
314
+ }
315
+ async submitTestRun(payload) {
316
+ return this.request("POST", "/api/testing/test-runs", payload);
317
+ }
318
+ async listTestRuns(projectId, options) {
319
+ const params = new URLSearchParams({ projectId });
320
+ if (options?.limit) params.set("limit", String(options.limit));
321
+ if (options?.suite) params.set("suite", options.suite);
322
+ const response = await this.request(
323
+ "GET",
324
+ `/api/testing/test-runs?${params.toString()}`
325
+ );
326
+ return response.runs || [];
327
+ }
328
+ async requestCoverageInsight(payload) {
329
+ return this.request("POST", "/api/testing/coverage-insight", payload);
330
+ }
331
+ async listCoverageInsights(projectId, limit = 5) {
332
+ const params = new URLSearchParams({ projectId, limit: String(limit) });
333
+ const response = await this.request(
334
+ "GET",
335
+ `/api/testing/coverage-insight?${params.toString()}`
336
+ );
337
+ return response.reports || [];
338
+ }
339
+ };
270
340
 
271
341
  export {
272
342
  CodmirClient