UNPKG

tressi

Version:

Deterministic load testing for API performance validation.

2 lines (1 loc) 1.52 kB
import{a as n}from"./chunk-2IBU6HRE.js";import{Gc as a,R as i,W as s}from"./chunk-W6IDPYNF.js";var c=class r{_rpc=s(n);_logService=s(a);_testClient=this._rpc.client.tests;_metricsClient=this._rpc.client.metrics;async getTestsByConfigId(e){try{let t=await this._testClient.$get();if(!t.ok)throw new Error(`Failed to load tests: ${t.statusText}`);return(await t.json()).filter(o=>o.configId===e).sort((o,l)=>l.epochCreatedAt-o.epochCreatedAt)}catch(t){throw this._logService.error("Failed to load tests:",t),t}}async getTestById(e){try{let t=await this._testClient[":id"].$get({param:{id:e}});if(!t.ok)throw new Error(`Failed to load test: ${t.statusText}`);return await t.json()}catch(t){throw this._logService.error("Failed to load test:",t),t}}async deleteTest(e){try{let t=await this._testClient[":id"].$delete({param:{id:e}});if(!t.ok)throw new Error(`Failed to delete test: ${t.statusText}`);return await t.json()}catch(t){throw this._logService.error("Failed to delete test:",t),t}}async getTestMetrics(e){try{let t=await this._metricsClient[":testId"].$get({param:{testId:e}});if(!t.ok)throw new Error(`Failed to load metrics: ${t.statusText}`);return await t.json()}catch(t){throw this._logService.error("Failed to load test metrics:",t),t}}getTestDuration(e){return e.summary?.global.epochStartedAt?(e.summary?.global.epochEndedAt||Date.now())-e.summary.global.epochStartedAt:0}static \u0275fac=function(t){return new(t||r)};static \u0275prov=i({token:r,factory:r.\u0275fac,providedIn:"root"})};export{c as a};