@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
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodmirApiError
|
|
3
|
+
} from "./chunk-233XBWQD.js";
|
|
4
|
+
|
|
5
|
+
// src/client.ts
|
|
6
|
+
var DEFAULT_BASE_URL = "https://codmir.com/api";
|
|
7
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
8
|
+
var CodmirClient = class {
|
|
9
|
+
baseUrl;
|
|
10
|
+
apiKey;
|
|
11
|
+
timeout;
|
|
12
|
+
headers;
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
15
|
+
this.apiKey = config.apiKey || process.env.CODMIR_API_KEY;
|
|
16
|
+
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
17
|
+
this.headers = {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
...config.headers
|
|
20
|
+
};
|
|
21
|
+
if (this.apiKey) {
|
|
22
|
+
this.headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// ============================================
|
|
26
|
+
// HTTP Methods
|
|
27
|
+
// ============================================
|
|
28
|
+
async request(method, path, body) {
|
|
29
|
+
const url = `${this.baseUrl}${path}`;
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
32
|
+
try {
|
|
33
|
+
const response = await fetch(url, {
|
|
34
|
+
method,
|
|
35
|
+
headers: this.headers,
|
|
36
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
37
|
+
signal: controller.signal
|
|
38
|
+
});
|
|
39
|
+
clearTimeout(timeoutId);
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
const errorData = await response.json().catch(() => ({}));
|
|
42
|
+
throw new CodmirApiError(
|
|
43
|
+
errorData.code || "API_ERROR",
|
|
44
|
+
errorData.message || `HTTP ${response.status}`,
|
|
45
|
+
response.status,
|
|
46
|
+
errorData.details
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return response.json();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
clearTimeout(timeoutId);
|
|
52
|
+
if (error instanceof CodmirApiError) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
56
|
+
throw new CodmirApiError("TIMEOUT", "Request timed out", 408);
|
|
57
|
+
}
|
|
58
|
+
throw new CodmirApiError(
|
|
59
|
+
"NETWORK_ERROR",
|
|
60
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
get(path) {
|
|
65
|
+
return this.request("GET", path);
|
|
66
|
+
}
|
|
67
|
+
post(path, body) {
|
|
68
|
+
return this.request("POST", path, body);
|
|
69
|
+
}
|
|
70
|
+
patch(path, body) {
|
|
71
|
+
return this.request("PATCH", path, body);
|
|
72
|
+
}
|
|
73
|
+
delete(path) {
|
|
74
|
+
return this.request("DELETE", path);
|
|
75
|
+
}
|
|
76
|
+
// ============================================
|
|
77
|
+
// Auth
|
|
78
|
+
// ============================================
|
|
79
|
+
async whoami() {
|
|
80
|
+
const response = await this.get("/auth/me");
|
|
81
|
+
return response.data;
|
|
82
|
+
}
|
|
83
|
+
// ============================================
|
|
84
|
+
// Projects
|
|
85
|
+
// ============================================
|
|
86
|
+
async listProjects() {
|
|
87
|
+
const response = await this.get("/projects");
|
|
88
|
+
return response.data;
|
|
89
|
+
}
|
|
90
|
+
async getProject(projectId) {
|
|
91
|
+
const response = await this.get(`/projects/${projectId}`);
|
|
92
|
+
return response.data;
|
|
93
|
+
}
|
|
94
|
+
async createProject(input) {
|
|
95
|
+
const response = await this.post("/projects", input);
|
|
96
|
+
return response.data;
|
|
97
|
+
}
|
|
98
|
+
// ============================================
|
|
99
|
+
// Tickets
|
|
100
|
+
// ============================================
|
|
101
|
+
async listTickets(projectId, options) {
|
|
102
|
+
const params = new URLSearchParams();
|
|
103
|
+
if (options?.page) params.set("page", String(options.page));
|
|
104
|
+
if (options?.pageSize) params.set("pageSize", String(options.pageSize));
|
|
105
|
+
if (options?.status) params.set("status", options.status);
|
|
106
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
107
|
+
return this.get(`/projects/${projectId}/tickets${query}`);
|
|
108
|
+
}
|
|
109
|
+
async getTicket(projectId, ticketId) {
|
|
110
|
+
const response = await this.get(
|
|
111
|
+
`/projects/${projectId}/tickets/${ticketId}`
|
|
112
|
+
);
|
|
113
|
+
return response.data;
|
|
114
|
+
}
|
|
115
|
+
async createTicket(input) {
|
|
116
|
+
const response = await this.post(
|
|
117
|
+
`/projects/${input.projectId}/tickets`,
|
|
118
|
+
input
|
|
119
|
+
);
|
|
120
|
+
return response.data;
|
|
121
|
+
}
|
|
122
|
+
async updateTicket(projectId, ticketId, input) {
|
|
123
|
+
const response = await this.patch(
|
|
124
|
+
`/projects/${projectId}/tickets/${ticketId}`,
|
|
125
|
+
input
|
|
126
|
+
);
|
|
127
|
+
return response.data;
|
|
128
|
+
}
|
|
129
|
+
async deleteTicket(projectId, ticketId) {
|
|
130
|
+
await this.delete(`/projects/${projectId}/tickets/${ticketId}`);
|
|
131
|
+
}
|
|
132
|
+
// ============================================
|
|
133
|
+
// Test Cases
|
|
134
|
+
// ============================================
|
|
135
|
+
async listTestCases(projectId) {
|
|
136
|
+
const response = await this.get(
|
|
137
|
+
`/projects/${projectId}/test-cases`
|
|
138
|
+
);
|
|
139
|
+
return response.data;
|
|
140
|
+
}
|
|
141
|
+
async getTestCase(projectId, testCaseId) {
|
|
142
|
+
const response = await this.get(
|
|
143
|
+
`/projects/${projectId}/test-cases/${testCaseId}`
|
|
144
|
+
);
|
|
145
|
+
return response.data;
|
|
146
|
+
}
|
|
147
|
+
async createTestCase(input) {
|
|
148
|
+
const response = await this.post(
|
|
149
|
+
`/projects/${input.projectId}/test-cases`,
|
|
150
|
+
input
|
|
151
|
+
);
|
|
152
|
+
return response.data;
|
|
153
|
+
}
|
|
154
|
+
async updateTestCase(projectId, testCaseId, input) {
|
|
155
|
+
const response = await this.patch(
|
|
156
|
+
`/projects/${projectId}/test-cases/${testCaseId}`,
|
|
157
|
+
input
|
|
158
|
+
);
|
|
159
|
+
return response.data;
|
|
160
|
+
}
|
|
161
|
+
// ============================================
|
|
162
|
+
// Test Insights
|
|
163
|
+
// ============================================
|
|
164
|
+
async submitTestRunSummary(input) {
|
|
165
|
+
await this.post(`/projects/${input.projectId}/test-runs`, input);
|
|
166
|
+
}
|
|
167
|
+
async getCoverageInsights(request) {
|
|
168
|
+
const response = await this.post(
|
|
169
|
+
`/projects/${request.projectId}/coverage/insights`,
|
|
170
|
+
request
|
|
171
|
+
);
|
|
172
|
+
return response.data;
|
|
173
|
+
}
|
|
174
|
+
// ============================================
|
|
175
|
+
// Agent Tasks
|
|
176
|
+
// ============================================
|
|
177
|
+
async listAgentTasks(projectId) {
|
|
178
|
+
const path = projectId ? `/projects/${projectId}/agent/tasks` : "/agent/tasks";
|
|
179
|
+
const response = await this.get(path);
|
|
180
|
+
return response.data;
|
|
181
|
+
}
|
|
182
|
+
async getAgentTask(taskId) {
|
|
183
|
+
const response = await this.get(
|
|
184
|
+
`/agent/tasks/${taskId}`
|
|
185
|
+
);
|
|
186
|
+
return response.data;
|
|
187
|
+
}
|
|
188
|
+
async createAgentTask(input) {
|
|
189
|
+
const path = input.projectId ? `/projects/${input.projectId}/agent/tasks` : "/agent/tasks";
|
|
190
|
+
const response = await this.post(path, input);
|
|
191
|
+
return response.data;
|
|
192
|
+
}
|
|
193
|
+
async runAgentTask(input) {
|
|
194
|
+
const response = await this.post(
|
|
195
|
+
`/agent/tasks/${input.taskId}/run`,
|
|
196
|
+
input.options
|
|
197
|
+
);
|
|
198
|
+
return response.data;
|
|
199
|
+
}
|
|
200
|
+
async cancelAgentTask(taskId) {
|
|
201
|
+
const response = await this.post(
|
|
202
|
+
`/agent/tasks/${taskId}/cancel`
|
|
203
|
+
);
|
|
204
|
+
return response.data;
|
|
205
|
+
}
|
|
206
|
+
// ============================================
|
|
207
|
+
// AI Chat
|
|
208
|
+
// ============================================
|
|
209
|
+
async chat(message, options) {
|
|
210
|
+
const response = await this.post(
|
|
211
|
+
"/ai/chat",
|
|
212
|
+
{
|
|
213
|
+
message,
|
|
214
|
+
...options
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
return response.data.response;
|
|
218
|
+
}
|
|
219
|
+
async streamChat(message, options) {
|
|
220
|
+
const url = `${this.baseUrl}/ai/chat/stream`;
|
|
221
|
+
const response = await fetch(url, {
|
|
222
|
+
method: "POST",
|
|
223
|
+
headers: this.headers,
|
|
224
|
+
body: JSON.stringify({
|
|
225
|
+
message,
|
|
226
|
+
projectId: options?.projectId,
|
|
227
|
+
context: options?.context,
|
|
228
|
+
model: options?.model
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
if (!response.ok) {
|
|
232
|
+
throw new CodmirApiError("STREAM_ERROR", "Failed to start stream", response.status);
|
|
233
|
+
}
|
|
234
|
+
const reader = response.body?.getReader();
|
|
235
|
+
if (!reader) {
|
|
236
|
+
throw new CodmirApiError("STREAM_ERROR", "No response body");
|
|
237
|
+
}
|
|
238
|
+
const decoder = new TextDecoder();
|
|
239
|
+
let fullResponse = "";
|
|
240
|
+
while (true) {
|
|
241
|
+
const { done, value } = await reader.read();
|
|
242
|
+
if (done) break;
|
|
243
|
+
const chunk = decoder.decode(value);
|
|
244
|
+
fullResponse += chunk;
|
|
245
|
+
options?.onChunk?.(chunk);
|
|
246
|
+
}
|
|
247
|
+
return fullResponse;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var client_default = CodmirClient;
|
|
251
|
+
|
|
252
|
+
export {
|
|
253
|
+
CodmirClient,
|
|
254
|
+
client_default
|
|
255
|
+
};
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
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/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
CodmirClient: () => CodmirClient,
|
|
24
|
+
default: () => client_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(client_exports);
|
|
27
|
+
|
|
28
|
+
// src/types.ts
|
|
29
|
+
var import_zod = require("zod");
|
|
30
|
+
var CodmirApiError = class extends Error {
|
|
31
|
+
constructor(code, message, statusCode, details) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.statusCode = statusCode;
|
|
35
|
+
this.details = details;
|
|
36
|
+
this.name = "CodmirApiError";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var CreateTicketSchema = import_zod.z.object({
|
|
40
|
+
title: import_zod.z.string().min(1).max(200),
|
|
41
|
+
description: import_zod.z.string().optional(),
|
|
42
|
+
status: import_zod.z.enum(["open", "in_progress", "review", "done", "closed"]).optional(),
|
|
43
|
+
priority: import_zod.z.enum(["low", "medium", "high", "critical"]).optional(),
|
|
44
|
+
type: import_zod.z.enum(["bug", "feature", "task", "improvement", "epic"]).optional(),
|
|
45
|
+
projectId: import_zod.z.string().uuid(),
|
|
46
|
+
assigneeId: import_zod.z.string().uuid().optional(),
|
|
47
|
+
labels: import_zod.z.array(import_zod.z.string()).optional(),
|
|
48
|
+
dueDate: import_zod.z.string().datetime().optional()
|
|
49
|
+
});
|
|
50
|
+
var CreateAgentTaskSchema = import_zod.z.object({
|
|
51
|
+
type: import_zod.z.enum([
|
|
52
|
+
"code_review",
|
|
53
|
+
"bug_fix",
|
|
54
|
+
"feature_implementation",
|
|
55
|
+
"refactor",
|
|
56
|
+
"documentation",
|
|
57
|
+
"test_generation",
|
|
58
|
+
"analysis",
|
|
59
|
+
"custom"
|
|
60
|
+
]),
|
|
61
|
+
prompt: import_zod.z.string().min(1),
|
|
62
|
+
context: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
63
|
+
projectId: import_zod.z.string().uuid().optional()
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/client.ts
|
|
67
|
+
var DEFAULT_BASE_URL = "https://codmir.com/api";
|
|
68
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
69
|
+
var CodmirClient = class {
|
|
70
|
+
baseUrl;
|
|
71
|
+
apiKey;
|
|
72
|
+
timeout;
|
|
73
|
+
headers;
|
|
74
|
+
constructor(config = {}) {
|
|
75
|
+
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
76
|
+
this.apiKey = config.apiKey || process.env.CODMIR_API_KEY;
|
|
77
|
+
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
78
|
+
this.headers = {
|
|
79
|
+
"Content-Type": "application/json",
|
|
80
|
+
...config.headers
|
|
81
|
+
};
|
|
82
|
+
if (this.apiKey) {
|
|
83
|
+
this.headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// ============================================
|
|
87
|
+
// HTTP Methods
|
|
88
|
+
// ============================================
|
|
89
|
+
async request(method, path, body) {
|
|
90
|
+
const url = `${this.baseUrl}${path}`;
|
|
91
|
+
const controller = new AbortController();
|
|
92
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
93
|
+
try {
|
|
94
|
+
const response = await fetch(url, {
|
|
95
|
+
method,
|
|
96
|
+
headers: this.headers,
|
|
97
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
98
|
+
signal: controller.signal
|
|
99
|
+
});
|
|
100
|
+
clearTimeout(timeoutId);
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
const errorData = await response.json().catch(() => ({}));
|
|
103
|
+
throw new CodmirApiError(
|
|
104
|
+
errorData.code || "API_ERROR",
|
|
105
|
+
errorData.message || `HTTP ${response.status}`,
|
|
106
|
+
response.status,
|
|
107
|
+
errorData.details
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return response.json();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
clearTimeout(timeoutId);
|
|
113
|
+
if (error instanceof CodmirApiError) {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
117
|
+
throw new CodmirApiError("TIMEOUT", "Request timed out", 408);
|
|
118
|
+
}
|
|
119
|
+
throw new CodmirApiError(
|
|
120
|
+
"NETWORK_ERROR",
|
|
121
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
get(path) {
|
|
126
|
+
return this.request("GET", path);
|
|
127
|
+
}
|
|
128
|
+
post(path, body) {
|
|
129
|
+
return this.request("POST", path, body);
|
|
130
|
+
}
|
|
131
|
+
patch(path, body) {
|
|
132
|
+
return this.request("PATCH", path, body);
|
|
133
|
+
}
|
|
134
|
+
delete(path) {
|
|
135
|
+
return this.request("DELETE", path);
|
|
136
|
+
}
|
|
137
|
+
// ============================================
|
|
138
|
+
// Auth
|
|
139
|
+
// ============================================
|
|
140
|
+
async whoami() {
|
|
141
|
+
const response = await this.get("/auth/me");
|
|
142
|
+
return response.data;
|
|
143
|
+
}
|
|
144
|
+
// ============================================
|
|
145
|
+
// Projects
|
|
146
|
+
// ============================================
|
|
147
|
+
async listProjects() {
|
|
148
|
+
const response = await this.get("/projects");
|
|
149
|
+
return response.data;
|
|
150
|
+
}
|
|
151
|
+
async getProject(projectId) {
|
|
152
|
+
const response = await this.get(`/projects/${projectId}`);
|
|
153
|
+
return response.data;
|
|
154
|
+
}
|
|
155
|
+
async createProject(input) {
|
|
156
|
+
const response = await this.post("/projects", input);
|
|
157
|
+
return response.data;
|
|
158
|
+
}
|
|
159
|
+
// ============================================
|
|
160
|
+
// Tickets
|
|
161
|
+
// ============================================
|
|
162
|
+
async listTickets(projectId, options) {
|
|
163
|
+
const params = new URLSearchParams();
|
|
164
|
+
if (options?.page) params.set("page", String(options.page));
|
|
165
|
+
if (options?.pageSize) params.set("pageSize", String(options.pageSize));
|
|
166
|
+
if (options?.status) params.set("status", options.status);
|
|
167
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
168
|
+
return this.get(`/projects/${projectId}/tickets${query}`);
|
|
169
|
+
}
|
|
170
|
+
async getTicket(projectId, ticketId) {
|
|
171
|
+
const response = await this.get(
|
|
172
|
+
`/projects/${projectId}/tickets/${ticketId}`
|
|
173
|
+
);
|
|
174
|
+
return response.data;
|
|
175
|
+
}
|
|
176
|
+
async createTicket(input) {
|
|
177
|
+
const response = await this.post(
|
|
178
|
+
`/projects/${input.projectId}/tickets`,
|
|
179
|
+
input
|
|
180
|
+
);
|
|
181
|
+
return response.data;
|
|
182
|
+
}
|
|
183
|
+
async updateTicket(projectId, ticketId, input) {
|
|
184
|
+
const response = await this.patch(
|
|
185
|
+
`/projects/${projectId}/tickets/${ticketId}`,
|
|
186
|
+
input
|
|
187
|
+
);
|
|
188
|
+
return response.data;
|
|
189
|
+
}
|
|
190
|
+
async deleteTicket(projectId, ticketId) {
|
|
191
|
+
await this.delete(`/projects/${projectId}/tickets/${ticketId}`);
|
|
192
|
+
}
|
|
193
|
+
// ============================================
|
|
194
|
+
// Test Cases
|
|
195
|
+
// ============================================
|
|
196
|
+
async listTestCases(projectId) {
|
|
197
|
+
const response = await this.get(
|
|
198
|
+
`/projects/${projectId}/test-cases`
|
|
199
|
+
);
|
|
200
|
+
return response.data;
|
|
201
|
+
}
|
|
202
|
+
async getTestCase(projectId, testCaseId) {
|
|
203
|
+
const response = await this.get(
|
|
204
|
+
`/projects/${projectId}/test-cases/${testCaseId}`
|
|
205
|
+
);
|
|
206
|
+
return response.data;
|
|
207
|
+
}
|
|
208
|
+
async createTestCase(input) {
|
|
209
|
+
const response = await this.post(
|
|
210
|
+
`/projects/${input.projectId}/test-cases`,
|
|
211
|
+
input
|
|
212
|
+
);
|
|
213
|
+
return response.data;
|
|
214
|
+
}
|
|
215
|
+
async updateTestCase(projectId, testCaseId, input) {
|
|
216
|
+
const response = await this.patch(
|
|
217
|
+
`/projects/${projectId}/test-cases/${testCaseId}`,
|
|
218
|
+
input
|
|
219
|
+
);
|
|
220
|
+
return response.data;
|
|
221
|
+
}
|
|
222
|
+
// ============================================
|
|
223
|
+
// Test Insights
|
|
224
|
+
// ============================================
|
|
225
|
+
async submitTestRunSummary(input) {
|
|
226
|
+
await this.post(`/projects/${input.projectId}/test-runs`, input);
|
|
227
|
+
}
|
|
228
|
+
async getCoverageInsights(request) {
|
|
229
|
+
const response = await this.post(
|
|
230
|
+
`/projects/${request.projectId}/coverage/insights`,
|
|
231
|
+
request
|
|
232
|
+
);
|
|
233
|
+
return response.data;
|
|
234
|
+
}
|
|
235
|
+
// ============================================
|
|
236
|
+
// Agent Tasks
|
|
237
|
+
// ============================================
|
|
238
|
+
async listAgentTasks(projectId) {
|
|
239
|
+
const path = projectId ? `/projects/${projectId}/agent/tasks` : "/agent/tasks";
|
|
240
|
+
const response = await this.get(path);
|
|
241
|
+
return response.data;
|
|
242
|
+
}
|
|
243
|
+
async getAgentTask(taskId) {
|
|
244
|
+
const response = await this.get(
|
|
245
|
+
`/agent/tasks/${taskId}`
|
|
246
|
+
);
|
|
247
|
+
return response.data;
|
|
248
|
+
}
|
|
249
|
+
async createAgentTask(input) {
|
|
250
|
+
const path = input.projectId ? `/projects/${input.projectId}/agent/tasks` : "/agent/tasks";
|
|
251
|
+
const response = await this.post(path, input);
|
|
252
|
+
return response.data;
|
|
253
|
+
}
|
|
254
|
+
async runAgentTask(input) {
|
|
255
|
+
const response = await this.post(
|
|
256
|
+
`/agent/tasks/${input.taskId}/run`,
|
|
257
|
+
input.options
|
|
258
|
+
);
|
|
259
|
+
return response.data;
|
|
260
|
+
}
|
|
261
|
+
async cancelAgentTask(taskId) {
|
|
262
|
+
const response = await this.post(
|
|
263
|
+
`/agent/tasks/${taskId}/cancel`
|
|
264
|
+
);
|
|
265
|
+
return response.data;
|
|
266
|
+
}
|
|
267
|
+
// ============================================
|
|
268
|
+
// AI Chat
|
|
269
|
+
// ============================================
|
|
270
|
+
async chat(message, options) {
|
|
271
|
+
const response = await this.post(
|
|
272
|
+
"/ai/chat",
|
|
273
|
+
{
|
|
274
|
+
message,
|
|
275
|
+
...options
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
return response.data.response;
|
|
279
|
+
}
|
|
280
|
+
async streamChat(message, options) {
|
|
281
|
+
const url = `${this.baseUrl}/ai/chat/stream`;
|
|
282
|
+
const response = await fetch(url, {
|
|
283
|
+
method: "POST",
|
|
284
|
+
headers: this.headers,
|
|
285
|
+
body: JSON.stringify({
|
|
286
|
+
message,
|
|
287
|
+
projectId: options?.projectId,
|
|
288
|
+
context: options?.context,
|
|
289
|
+
model: options?.model
|
|
290
|
+
})
|
|
291
|
+
});
|
|
292
|
+
if (!response.ok) {
|
|
293
|
+
throw new CodmirApiError("STREAM_ERROR", "Failed to start stream", response.status);
|
|
294
|
+
}
|
|
295
|
+
const reader = response.body?.getReader();
|
|
296
|
+
if (!reader) {
|
|
297
|
+
throw new CodmirApiError("STREAM_ERROR", "No response body");
|
|
298
|
+
}
|
|
299
|
+
const decoder = new TextDecoder();
|
|
300
|
+
let fullResponse = "";
|
|
301
|
+
while (true) {
|
|
302
|
+
const { done, value } = await reader.read();
|
|
303
|
+
if (done) break;
|
|
304
|
+
const chunk = decoder.decode(value);
|
|
305
|
+
fullResponse += chunk;
|
|
306
|
+
options?.onChunk?.(chunk);
|
|
307
|
+
}
|
|
308
|
+
return fullResponse;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var client_default = CodmirClient;
|
|
312
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
313
|
+
0 && (module.exports = {
|
|
314
|
+
CodmirClient
|
|
315
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CodmirClientConfig, User, Project, CreateProjectInput, PaginatedResponse, Ticket, CreateTicketInput, UpdateTicketInput, TestCase, CreateTestCaseInput, UpdateTestCaseInput, TestRunSummaryInput, CoverageInsightRequest, CoverageInsight, AgentTask, CreateAgentTaskInput, RunTaskInput, TaskExecution } from './types.cjs';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
declare class CodmirClient {
|
|
5
|
+
private baseUrl;
|
|
6
|
+
private apiKey?;
|
|
7
|
+
private timeout;
|
|
8
|
+
private headers;
|
|
9
|
+
constructor(config?: CodmirClientConfig);
|
|
10
|
+
private request;
|
|
11
|
+
private get;
|
|
12
|
+
private post;
|
|
13
|
+
private patch;
|
|
14
|
+
private delete;
|
|
15
|
+
whoami(): Promise<User>;
|
|
16
|
+
listProjects(): Promise<Project[]>;
|
|
17
|
+
getProject(projectId: string): Promise<Project>;
|
|
18
|
+
createProject(input: CreateProjectInput): Promise<Project>;
|
|
19
|
+
listTickets(projectId: string, options?: {
|
|
20
|
+
page?: number;
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
status?: string;
|
|
23
|
+
}): Promise<PaginatedResponse<Ticket>>;
|
|
24
|
+
getTicket(projectId: string, ticketId: string): Promise<Ticket>;
|
|
25
|
+
createTicket(input: CreateTicketInput): Promise<Ticket>;
|
|
26
|
+
updateTicket(projectId: string, ticketId: string, input: UpdateTicketInput): Promise<Ticket>;
|
|
27
|
+
deleteTicket(projectId: string, ticketId: string): Promise<void>;
|
|
28
|
+
listTestCases(projectId: string): Promise<TestCase[]>;
|
|
29
|
+
getTestCase(projectId: string, testCaseId: string): Promise<TestCase>;
|
|
30
|
+
createTestCase(input: CreateTestCaseInput): Promise<TestCase>;
|
|
31
|
+
updateTestCase(projectId: string, testCaseId: string, input: UpdateTestCaseInput): Promise<TestCase>;
|
|
32
|
+
submitTestRunSummary(input: TestRunSummaryInput): Promise<void>;
|
|
33
|
+
getCoverageInsights(request: CoverageInsightRequest): Promise<CoverageInsight>;
|
|
34
|
+
listAgentTasks(projectId?: string): Promise<AgentTask[]>;
|
|
35
|
+
getAgentTask(taskId: string): Promise<AgentTask>;
|
|
36
|
+
createAgentTask(input: CreateAgentTaskInput): Promise<AgentTask>;
|
|
37
|
+
runAgentTask(input: RunTaskInput): Promise<TaskExecution>;
|
|
38
|
+
cancelAgentTask(taskId: string): Promise<AgentTask>;
|
|
39
|
+
chat(message: string, options?: {
|
|
40
|
+
projectId?: string;
|
|
41
|
+
context?: Record<string, unknown>;
|
|
42
|
+
model?: string;
|
|
43
|
+
}): Promise<string>;
|
|
44
|
+
streamChat(message: string, options?: {
|
|
45
|
+
projectId?: string;
|
|
46
|
+
context?: Record<string, unknown>;
|
|
47
|
+
model?: string;
|
|
48
|
+
onChunk?: (chunk: string) => void;
|
|
49
|
+
}): Promise<string>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { CodmirClient, CodmirClient as default };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CodmirClientConfig, User, Project, CreateProjectInput, PaginatedResponse, Ticket, CreateTicketInput, UpdateTicketInput, TestCase, CreateTestCaseInput, UpdateTestCaseInput, TestRunSummaryInput, CoverageInsightRequest, CoverageInsight, AgentTask, CreateAgentTaskInput, RunTaskInput, TaskExecution } from './types.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
declare class CodmirClient {
|
|
5
|
+
private baseUrl;
|
|
6
|
+
private apiKey?;
|
|
7
|
+
private timeout;
|
|
8
|
+
private headers;
|
|
9
|
+
constructor(config?: CodmirClientConfig);
|
|
10
|
+
private request;
|
|
11
|
+
private get;
|
|
12
|
+
private post;
|
|
13
|
+
private patch;
|
|
14
|
+
private delete;
|
|
15
|
+
whoami(): Promise<User>;
|
|
16
|
+
listProjects(): Promise<Project[]>;
|
|
17
|
+
getProject(projectId: string): Promise<Project>;
|
|
18
|
+
createProject(input: CreateProjectInput): Promise<Project>;
|
|
19
|
+
listTickets(projectId: string, options?: {
|
|
20
|
+
page?: number;
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
status?: string;
|
|
23
|
+
}): Promise<PaginatedResponse<Ticket>>;
|
|
24
|
+
getTicket(projectId: string, ticketId: string): Promise<Ticket>;
|
|
25
|
+
createTicket(input: CreateTicketInput): Promise<Ticket>;
|
|
26
|
+
updateTicket(projectId: string, ticketId: string, input: UpdateTicketInput): Promise<Ticket>;
|
|
27
|
+
deleteTicket(projectId: string, ticketId: string): Promise<void>;
|
|
28
|
+
listTestCases(projectId: string): Promise<TestCase[]>;
|
|
29
|
+
getTestCase(projectId: string, testCaseId: string): Promise<TestCase>;
|
|
30
|
+
createTestCase(input: CreateTestCaseInput): Promise<TestCase>;
|
|
31
|
+
updateTestCase(projectId: string, testCaseId: string, input: UpdateTestCaseInput): Promise<TestCase>;
|
|
32
|
+
submitTestRunSummary(input: TestRunSummaryInput): Promise<void>;
|
|
33
|
+
getCoverageInsights(request: CoverageInsightRequest): Promise<CoverageInsight>;
|
|
34
|
+
listAgentTasks(projectId?: string): Promise<AgentTask[]>;
|
|
35
|
+
getAgentTask(taskId: string): Promise<AgentTask>;
|
|
36
|
+
createAgentTask(input: CreateAgentTaskInput): Promise<AgentTask>;
|
|
37
|
+
runAgentTask(input: RunTaskInput): Promise<TaskExecution>;
|
|
38
|
+
cancelAgentTask(taskId: string): Promise<AgentTask>;
|
|
39
|
+
chat(message: string, options?: {
|
|
40
|
+
projectId?: string;
|
|
41
|
+
context?: Record<string, unknown>;
|
|
42
|
+
model?: string;
|
|
43
|
+
}): Promise<string>;
|
|
44
|
+
streamChat(message: string, options?: {
|
|
45
|
+
projectId?: string;
|
|
46
|
+
context?: Record<string, unknown>;
|
|
47
|
+
model?: string;
|
|
48
|
+
onChunk?: (chunk: string) => void;
|
|
49
|
+
}): Promise<string>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { CodmirClient, CodmirClient as default };
|