@axiom-lattice/client-sdk 2.1.40 → 2.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/eval.d.ts +57 -0
- package/dist/eval.d.ts.map +1 -0
- package/dist/eval.js +110 -0
- package/dist/eval.js.map +1 -0
- package/dist/index.d.ts +58 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2749,6 +2749,109 @@ var AbstractClient = class {
|
|
|
2749
2749
|
}
|
|
2750
2750
|
};
|
|
2751
2751
|
|
|
2752
|
+
// src/eval.ts
|
|
2753
|
+
var EvalClient = class {
|
|
2754
|
+
constructor(baseUrl, headers) {
|
|
2755
|
+
this.projects = {
|
|
2756
|
+
create: (data) => this.request("/api/eval/projects", {
|
|
2757
|
+
method: "POST",
|
|
2758
|
+
body: JSON.stringify(data)
|
|
2759
|
+
}),
|
|
2760
|
+
list: () => this.request("/api/eval/projects"),
|
|
2761
|
+
get: (id) => this.request(`/api/eval/projects/${id}`),
|
|
2762
|
+
update: (id, patch) => this.request(`/api/eval/projects/${id}`, {
|
|
2763
|
+
method: "PUT",
|
|
2764
|
+
body: JSON.stringify(patch)
|
|
2765
|
+
}),
|
|
2766
|
+
delete: (id) => this.request(`/api/eval/projects/${id}`, { method: "DELETE" }),
|
|
2767
|
+
suites: {
|
|
2768
|
+
create: (projectId, data) => this.request(`/api/eval/projects/${projectId}/suites`, {
|
|
2769
|
+
method: "POST",
|
|
2770
|
+
body: JSON.stringify(data)
|
|
2771
|
+
}),
|
|
2772
|
+
update: (projectId, suiteId, patch) => this.request(`/api/eval/projects/${projectId}/suites/${suiteId}`, {
|
|
2773
|
+
method: "PUT",
|
|
2774
|
+
body: JSON.stringify(patch)
|
|
2775
|
+
}),
|
|
2776
|
+
delete: (projectId, suiteId) => this.request(`/api/eval/projects/${projectId}/suites/${suiteId}`, { method: "DELETE" }),
|
|
2777
|
+
cases: {
|
|
2778
|
+
list: (projectId, suiteId) => this.request(`/api/eval/projects/${projectId}/suites/${suiteId}/cases`),
|
|
2779
|
+
create: (projectId, suiteId, data) => this.request(`/api/eval/projects/${projectId}/suites/${suiteId}/cases`, {
|
|
2780
|
+
method: "POST",
|
|
2781
|
+
body: JSON.stringify(data)
|
|
2782
|
+
}),
|
|
2783
|
+
update: (projectId, suiteId, caseId, patch) => this.request(`/api/eval/projects/${projectId}/suites/${suiteId}/cases/${caseId}`, {
|
|
2784
|
+
method: "PUT",
|
|
2785
|
+
body: JSON.stringify(patch)
|
|
2786
|
+
}),
|
|
2787
|
+
delete: (projectId, suiteId, caseId) => this.request(`/api/eval/projects/${projectId}/suites/${suiteId}/cases/${caseId}`, { method: "DELETE" })
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
};
|
|
2791
|
+
this.runs = {
|
|
2792
|
+
start: (projectId) => this.request(`/api/eval/projects/${projectId}/runs`, { method: "POST" }),
|
|
2793
|
+
list: (opts) => {
|
|
2794
|
+
const params = new URLSearchParams();
|
|
2795
|
+
if (opts?.projectId)
|
|
2796
|
+
params.set("project_id", opts.projectId);
|
|
2797
|
+
if (opts?.status)
|
|
2798
|
+
params.set("status", opts.status);
|
|
2799
|
+
const qs = params.toString();
|
|
2800
|
+
return this.request(`/api/eval/runs${qs ? `?${qs}` : ""}`);
|
|
2801
|
+
},
|
|
2802
|
+
get: (id) => this.request(`/api/eval/runs/${id}`),
|
|
2803
|
+
abort: (id) => this.request(`/api/eval/runs/${id}/abort`, { method: "POST" }),
|
|
2804
|
+
delete: (id) => this.request(`/api/eval/runs/${id}`, { method: "DELETE" }),
|
|
2805
|
+
stream: (id) => this.streamRun(id)
|
|
2806
|
+
};
|
|
2807
|
+
this.reports = {
|
|
2808
|
+
project: (projectId) => this.request(`/api/eval/reports/projects/${projectId}`)
|
|
2809
|
+
};
|
|
2810
|
+
this.baseUrl = baseUrl;
|
|
2811
|
+
this.headers = headers;
|
|
2812
|
+
}
|
|
2813
|
+
async request(path, opts) {
|
|
2814
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
2815
|
+
...opts,
|
|
2816
|
+
headers: { ...this.headers, ...opts?.headers }
|
|
2817
|
+
});
|
|
2818
|
+
const json = await res.json();
|
|
2819
|
+
if (!json.success)
|
|
2820
|
+
throw new Error(json.message);
|
|
2821
|
+
return json.data;
|
|
2822
|
+
}
|
|
2823
|
+
async *streamRun(id) {
|
|
2824
|
+
const res = await fetch(`${this.baseUrl}/api/eval/runs/${id}/stream`, {
|
|
2825
|
+
headers: this.headers
|
|
2826
|
+
});
|
|
2827
|
+
if (!res.ok || !res.body)
|
|
2828
|
+
throw new Error("Stream connection failed");
|
|
2829
|
+
const reader = res.body.getReader();
|
|
2830
|
+
const decoder = new TextDecoder();
|
|
2831
|
+
let buffer = "";
|
|
2832
|
+
while (true) {
|
|
2833
|
+
const { done, value } = await reader.read();
|
|
2834
|
+
if (done)
|
|
2835
|
+
break;
|
|
2836
|
+
buffer += decoder.decode(value, { stream: true });
|
|
2837
|
+
const lines = buffer.split("\n");
|
|
2838
|
+
buffer = lines.pop() || "";
|
|
2839
|
+
let eventType = "";
|
|
2840
|
+
for (const line of lines) {
|
|
2841
|
+
if (line.startsWith("event: ")) {
|
|
2842
|
+
eventType = line.slice(7);
|
|
2843
|
+
} else if (line.startsWith("data: ")) {
|
|
2844
|
+
try {
|
|
2845
|
+
const data = JSON.parse(line.slice(6));
|
|
2846
|
+
yield { type: eventType, runId: id, data };
|
|
2847
|
+
} catch {
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
};
|
|
2854
|
+
|
|
2752
2855
|
// src/client.ts
|
|
2753
2856
|
var _Client = class extends AbstractClient {
|
|
2754
2857
|
/**
|
|
@@ -2762,6 +2865,7 @@ var _Client = class extends AbstractClient {
|
|
|
2762
2865
|
Authorization: `Bearer ${this.config.apiKey}`,
|
|
2763
2866
|
...this.config.headers
|
|
2764
2867
|
};
|
|
2868
|
+
this.eval = new EvalClient(this.config.baseURL, this.getAllHeaders());
|
|
2765
2869
|
}
|
|
2766
2870
|
/**
|
|
2767
2871
|
* Helper method to handle fetch responses and errors
|
|
@@ -3777,6 +3881,7 @@ export {
|
|
|
3777
3881
|
ApiError,
|
|
3778
3882
|
AuthenticationError,
|
|
3779
3883
|
Client,
|
|
3884
|
+
EvalClient,
|
|
3780
3885
|
NetworkError,
|
|
3781
3886
|
ScheduleExecutionType,
|
|
3782
3887
|
ScheduledTaskStatus,
|