@nathapp/koda-cli 0.2.4 → 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.
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +14 -20
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/comment.d.ts.map +1 -1
- package/dist/commands/comment.js +118 -6
- package/dist/commands/comment.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +9 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/kb.d.ts.map +1 -1
- package/dist/commands/kb.js +105 -9
- package/dist/commands/kb.js.map +1 -1
- package/dist/commands/label.d.ts.map +1 -1
- package/dist/commands/label.js +72 -29
- package/dist/commands/label.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +7 -5
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/project.d.ts.map +1 -1
- package/dist/commands/project.js +86 -26
- package/dist/commands/project.js.map +1 -1
- package/dist/commands/ticket.d.ts.map +1 -1
- package/dist/commands/ticket.js +199 -201
- package/dist/commands/ticket.js.map +1 -1
- package/dist/commands/vcs-messages.d.ts +22 -0
- package/dist/commands/vcs-messages.d.ts.map +1 -0
- package/dist/commands/vcs-messages.js +25 -0
- package/dist/commands/vcs-messages.js.map +1 -0
- package/dist/commands/vcs.d.ts +10 -0
- package/dist/commands/vcs.d.ts.map +1 -0
- package/dist/commands/vcs.js +376 -0
- package/dist/commands/vcs.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/generated/core/ApiError.d.ts +11 -0
- package/dist/generated/core/ApiError.d.ts.map +1 -0
- package/dist/generated/core/ApiError.js +21 -0
- package/dist/generated/core/ApiError.js.map +1 -0
- package/dist/generated/core/ApiRequestOptions.d.ts +14 -0
- package/dist/generated/core/ApiRequestOptions.d.ts.map +1 -0
- package/dist/generated/core/ApiRequestOptions.js +3 -0
- package/dist/generated/core/ApiRequestOptions.js.map +1 -0
- package/dist/generated/core/ApiResult.d.ts +8 -0
- package/dist/generated/core/ApiResult.d.ts.map +1 -0
- package/dist/generated/core/ApiResult.js +3 -0
- package/dist/generated/core/ApiResult.js.map +1 -0
- package/dist/generated/core/CancelablePromise.d.ts +27 -0
- package/dist/generated/core/CancelablePromise.d.ts.map +1 -0
- package/dist/generated/core/CancelablePromise.js +101 -0
- package/dist/generated/core/CancelablePromise.js.map +1 -0
- package/dist/generated/core/OpenAPI.d.ts +29 -0
- package/dist/generated/core/OpenAPI.d.ts.map +1 -0
- package/dist/generated/core/OpenAPI.js +35 -0
- package/dist/generated/core/OpenAPI.js.map +1 -0
- package/dist/generated/core/request.d.ts +33 -0
- package/dist/generated/core/request.d.ts.map +1 -0
- package/dist/generated/core/request.js +310 -0
- package/dist/generated/core/request.js.map +1 -0
- package/dist/generated/index.d.ts +7 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +29 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/schemas.gen.d.ts +895 -0
- package/dist/generated/schemas.gen.d.ts.map +1 -0
- package/dist/generated/schemas.gen.js +903 -0
- package/dist/generated/schemas.gen.js.map +1 -0
- package/dist/generated/services.gen.d.ts +546 -0
- package/dist/generated/services.gen.d.ts.map +1 -0
- package/dist/generated/services.gen.js +1393 -0
- package/dist/generated/services.gen.js.map +1 -0
- package/dist/generated/types.gen.d.ts +1790 -0
- package/dist/generated/types.gen.d.ts.map +1 -0
- package/dist/generated/types.gen.js +4 -0
- package/dist/generated/types.gen.js.map +1 -0
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +1 -9
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +5 -4
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/error.d.ts +5 -3
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +31 -16
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/output.d.ts +1 -1
- package/dist/utils/output.js +2 -2
- package/dist/utils/output.js.map +1 -1
- package/dist/vcs-client.stub.d.ts +74 -0
- package/dist/vcs-client.stub.d.ts.map +1 -0
- package/dist/vcs-client.stub.js +40 -0
- package/dist/vcs-client.stub.js.map +1 -0
- package/package.json +10 -5
- package/dist/client.d.ts +0 -9
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -23
- package/dist/client.js.map +0 -1
- package/dist/generated.d.ts +0 -200
- package/dist/generated.d.ts.map +0 -1
- package/dist/generated.js +0 -131
- package/dist/generated.js.map +0 -1
package/dist/commands/ticket.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ticketCommand = ticketCommand;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
|
-
const
|
|
5
|
+
const OpenAPI_1 = require("../generated/core/OpenAPI");
|
|
6
6
|
const generated_1 = require("../generated");
|
|
7
7
|
const output_1 = require("../utils/output");
|
|
8
8
|
const api_1 = require("../utils/api");
|
|
@@ -23,38 +23,32 @@ function ticketCommand(program) {
|
|
|
23
23
|
try {
|
|
24
24
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
25
25
|
if (!ctx.projectSlug) {
|
|
26
|
-
(0,
|
|
27
|
-
process.exit(2);
|
|
28
|
-
return;
|
|
26
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
29
27
|
}
|
|
30
28
|
if (!ctx.apiKey) {
|
|
31
|
-
(0,
|
|
32
|
-
process.exit(2);
|
|
33
|
-
return;
|
|
29
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
34
30
|
}
|
|
35
|
-
// Validate required options
|
|
36
31
|
if (!options.type || !options.title) {
|
|
37
|
-
(0,
|
|
38
|
-
process.exit(3);
|
|
32
|
+
(0, error_1.handleApiError)(new Error('Missing required options: --type and --title are required'), { validationError: true });
|
|
39
33
|
}
|
|
40
34
|
const validTypes = ['BUG', 'ENHANCEMENT', 'TASK', 'QUESTION'];
|
|
41
35
|
if (!validTypes.includes(options.type)) {
|
|
42
|
-
(0,
|
|
43
|
-
process.exit(3);
|
|
44
|
-
return;
|
|
36
|
+
(0, error_1.handleApiError)(new Error(`Invalid type ${options.type}. Valid values: ${validTypes.join(', ')}`), { validationError: true });
|
|
45
37
|
}
|
|
46
38
|
const validPriorities = ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL'];
|
|
47
39
|
if (options.priority && !validPriorities.includes(options.priority)) {
|
|
48
|
-
(0,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
(0, error_1.handleApiError)(new Error(`Invalid priority ${options.priority}. Valid values: ${validPriorities.join(', ')}`), { validationError: true });
|
|
41
|
+
}
|
|
42
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
43
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
44
|
+
const response = await (0, generated_1.ticketsControllerCreate)({
|
|
45
|
+
slug: ctx.projectSlug,
|
|
46
|
+
requestBody: {
|
|
47
|
+
type: options.type,
|
|
48
|
+
title: options.title,
|
|
49
|
+
description: options.desc,
|
|
50
|
+
priority: options.priority,
|
|
51
|
+
},
|
|
58
52
|
});
|
|
59
53
|
const ticketData = (0, api_1.unwrap)(response);
|
|
60
54
|
if (options.json) {
|
|
@@ -86,18 +80,15 @@ function ticketCommand(program) {
|
|
|
86
80
|
try {
|
|
87
81
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
88
82
|
if (!ctx.projectSlug) {
|
|
89
|
-
(0,
|
|
90
|
-
process.exit(2);
|
|
91
|
-
return;
|
|
83
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
92
84
|
}
|
|
93
85
|
if (!ctx.apiKey) {
|
|
94
|
-
(0,
|
|
95
|
-
process.exit(2);
|
|
96
|
-
return;
|
|
86
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
97
87
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
89
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
90
|
+
const response = await (0, generated_1.ticketsControllerFindAll)({
|
|
91
|
+
slug: ctx.projectSlug,
|
|
101
92
|
status: options.status,
|
|
102
93
|
type: options.type,
|
|
103
94
|
priority: options.priority,
|
|
@@ -107,13 +98,13 @@ function ticketCommand(program) {
|
|
|
107
98
|
page: parseInt(options.page, 10),
|
|
108
99
|
});
|
|
109
100
|
const data = (0, api_1.unwrap)(response);
|
|
110
|
-
const items = Array.isArray(data) ? data : data.items
|
|
101
|
+
const items = Array.isArray(data) ? data : (data.items ?? []);
|
|
111
102
|
if (options.json) {
|
|
112
103
|
console.log(JSON.stringify(items, null, 2));
|
|
113
104
|
}
|
|
114
105
|
else {
|
|
115
106
|
const rows = items.map((t) => [
|
|
116
|
-
`KODA-${t.number}
|
|
107
|
+
String(t.ref ?? `KODA-${t.number}`),
|
|
117
108
|
String(t.type),
|
|
118
109
|
String(t.priority || ''),
|
|
119
110
|
String(t.status),
|
|
@@ -138,29 +129,26 @@ function ticketCommand(program) {
|
|
|
138
129
|
try {
|
|
139
130
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
140
131
|
if (!ctx.projectSlug) {
|
|
141
|
-
(0,
|
|
142
|
-
process.exit(2);
|
|
143
|
-
return;
|
|
132
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
144
133
|
}
|
|
145
134
|
if (!ctx.apiKey) {
|
|
146
|
-
(0,
|
|
147
|
-
process.exit(2);
|
|
148
|
-
return;
|
|
135
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
149
136
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
138
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
139
|
+
const response = await (0, generated_1.ticketsControllerFindAll)({
|
|
140
|
+
slug: ctx.projectSlug,
|
|
153
141
|
status: options.status,
|
|
154
142
|
assignedTo: 'self',
|
|
155
143
|
});
|
|
156
144
|
const data = (0, api_1.unwrap)(response);
|
|
157
|
-
const items = Array.isArray(data) ? data : data.items
|
|
145
|
+
const items = Array.isArray(data) ? data : (data.items ?? []);
|
|
158
146
|
if (options.json) {
|
|
159
147
|
console.log(JSON.stringify(items, null, 2));
|
|
160
148
|
}
|
|
161
149
|
else {
|
|
162
150
|
const rows = items.map((t) => [
|
|
163
|
-
`KODA-${t.number}
|
|
151
|
+
String(t.ref ?? `KODA-${t.number}`),
|
|
164
152
|
String(t.type),
|
|
165
153
|
String(t.priority || ''),
|
|
166
154
|
String(t.status),
|
|
@@ -184,17 +172,14 @@ function ticketCommand(program) {
|
|
|
184
172
|
try {
|
|
185
173
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
186
174
|
if (!ctx.projectSlug) {
|
|
187
|
-
(0,
|
|
188
|
-
process.exit(2);
|
|
189
|
-
return;
|
|
175
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
190
176
|
}
|
|
191
177
|
if (!ctx.apiKey) {
|
|
192
|
-
(0,
|
|
193
|
-
process.exit(2);
|
|
194
|
-
return;
|
|
178
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
195
179
|
}
|
|
196
|
-
|
|
197
|
-
|
|
180
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
181
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
182
|
+
const response = await (0, generated_1.ticketsControllerFindByRef)({ slug: ctx.projectSlug, ref });
|
|
198
183
|
const ticketData = (0, api_1.unwrap)(response);
|
|
199
184
|
if (options.json) {
|
|
200
185
|
console.log(JSON.stringify(ticketData, null, 2));
|
|
@@ -220,6 +205,39 @@ function ticketCommand(program) {
|
|
|
220
205
|
console.log(` - ${author} (${comment.type}): ${comment.body}`);
|
|
221
206
|
}
|
|
222
207
|
}
|
|
208
|
+
if (ticketData.links && ticketData.links.length > 0) {
|
|
209
|
+
// Group links by linkType
|
|
210
|
+
const branches = ticketData.links.filter(l => l.linkType === 'branch');
|
|
211
|
+
const commits = ticketData.links.filter(l => l.linkType === 'commit');
|
|
212
|
+
const pullRequests = ticketData.links.filter(l => l.linkType === 'pr' || (!l.linkType && l.prNumber));
|
|
213
|
+
if (branches.length > 0) {
|
|
214
|
+
console.log(`\nBranches:`);
|
|
215
|
+
for (const link of branches) {
|
|
216
|
+
console.log(` - ${link.externalRef || link.url}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (commits.length > 0) {
|
|
220
|
+
console.log(`\nCommits:`);
|
|
221
|
+
for (const link of commits) {
|
|
222
|
+
const sha = link.url.split('/').pop()?.slice(0, 7) || link.url;
|
|
223
|
+
const summary = link.title || link.externalRef || link.url;
|
|
224
|
+
console.log(` - ${sha} - ${summary}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (pullRequests.length > 0) {
|
|
228
|
+
console.log(`\nPull Requests:`);
|
|
229
|
+
for (const link of pullRequests) {
|
|
230
|
+
let linkStr = ` - ${link.url} (${link.provider})`;
|
|
231
|
+
if (link.externalRef) {
|
|
232
|
+
linkStr += ` [${link.externalRef}]`;
|
|
233
|
+
}
|
|
234
|
+
if (link.prState) {
|
|
235
|
+
linkStr += ` [${link.prState}]`;
|
|
236
|
+
}
|
|
237
|
+
console.log(linkStr);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
223
241
|
}
|
|
224
242
|
process.exit(0);
|
|
225
243
|
}
|
|
@@ -232,28 +250,25 @@ function ticketCommand(program) {
|
|
|
232
250
|
.description('Verify a ticket (CREATED → VERIFIED)')
|
|
233
251
|
.option('--project <slug>', 'Project slug')
|
|
234
252
|
.option('--comment <text>', 'Verification comment')
|
|
253
|
+
.option('--json', 'Output as JSON')
|
|
235
254
|
.action(async (ref, options) => {
|
|
236
255
|
try {
|
|
237
256
|
if (!options.comment) {
|
|
238
|
-
(0,
|
|
239
|
-
process.exit(3);
|
|
240
|
-
return;
|
|
257
|
+
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
241
258
|
}
|
|
242
259
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
243
260
|
if (!ctx.projectSlug) {
|
|
244
|
-
(0,
|
|
245
|
-
process.exit(2);
|
|
246
|
-
return;
|
|
261
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
247
262
|
}
|
|
248
263
|
if (!ctx.apiKey) {
|
|
249
|
-
(0,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
264
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
265
|
+
}
|
|
266
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
267
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
268
|
+
await (0, generated_1.ticketsControllerVerify)({
|
|
269
|
+
slug: ctx.projectSlug,
|
|
270
|
+
ref,
|
|
271
|
+
requestBody: { body: options.comment },
|
|
257
272
|
});
|
|
258
273
|
console.log(`✓ Ticket verified successfully`);
|
|
259
274
|
process.exit(0);
|
|
@@ -273,18 +288,14 @@ function ticketCommand(program) {
|
|
|
273
288
|
try {
|
|
274
289
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
275
290
|
if (!ctx.projectSlug) {
|
|
276
|
-
(0,
|
|
277
|
-
process.exit(2);
|
|
278
|
-
return;
|
|
291
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
279
292
|
}
|
|
280
293
|
if (!ctx.apiKey) {
|
|
281
|
-
(0,
|
|
282
|
-
process.exit(2);
|
|
283
|
-
return;
|
|
294
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
284
295
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const response = await generated_1.
|
|
296
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
297
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
298
|
+
const response = await (0, generated_1.ticketsControllerAssign)({ slug: ctx.projectSlug, ref });
|
|
288
299
|
const ticketData = (0, api_1.unwrap)(response);
|
|
289
300
|
if (options.json) {
|
|
290
301
|
console.log(JSON.stringify(ticketData, null, 2));
|
|
@@ -302,21 +313,19 @@ function ticketCommand(program) {
|
|
|
302
313
|
.command('start <ref>')
|
|
303
314
|
.description('Start a ticket (CREATED or VERIFIED → IN_PROGRESS)')
|
|
304
315
|
.option('--project <slug>', 'Project slug')
|
|
316
|
+
.option('--json', 'Output as JSON')
|
|
305
317
|
.action(async (ref, options) => {
|
|
306
318
|
try {
|
|
307
319
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
308
320
|
if (!ctx.projectSlug) {
|
|
309
|
-
(0,
|
|
310
|
-
process.exit(2);
|
|
311
|
-
return;
|
|
321
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
312
322
|
}
|
|
313
323
|
if (!ctx.apiKey) {
|
|
314
|
-
(0,
|
|
315
|
-
process.exit(2);
|
|
316
|
-
return;
|
|
324
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
317
325
|
}
|
|
318
|
-
|
|
319
|
-
|
|
326
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
327
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
328
|
+
await (0, generated_1.ticketsControllerStart)({ slug: ctx.projectSlug, ref });
|
|
320
329
|
console.log(`✓ Ticket started successfully`);
|
|
321
330
|
process.exit(0);
|
|
322
331
|
}
|
|
@@ -330,33 +339,26 @@ function ticketCommand(program) {
|
|
|
330
339
|
.option('--project <slug>', 'Project slug')
|
|
331
340
|
.option('--comment <text>', 'Fix report comment')
|
|
332
341
|
.option('--git-ref <ref>', 'Git reference (e.g. branch or commit)')
|
|
342
|
+
.option('--json', 'Output as JSON')
|
|
333
343
|
.action(async (ref, options) => {
|
|
334
344
|
try {
|
|
335
345
|
if (!options.comment) {
|
|
336
|
-
(0,
|
|
337
|
-
process.exit(3);
|
|
338
|
-
return;
|
|
346
|
+
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
339
347
|
}
|
|
340
348
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
341
349
|
if (!ctx.projectSlug) {
|
|
342
|
-
(0,
|
|
343
|
-
process.exit(2);
|
|
344
|
-
return;
|
|
350
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
345
351
|
}
|
|
346
352
|
if (!ctx.apiKey) {
|
|
347
|
-
(0,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
};
|
|
356
|
-
if (options.gitRef) {
|
|
357
|
-
payload.gitRef = options.gitRef;
|
|
358
|
-
}
|
|
359
|
-
await generated_1.TicketsService.fix(client, ctx.projectSlug, ref, payload);
|
|
353
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
354
|
+
}
|
|
355
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
356
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
357
|
+
await (0, generated_1.ticketsControllerFix)({
|
|
358
|
+
slug: ctx.projectSlug,
|
|
359
|
+
ref,
|
|
360
|
+
requestBody: { body: options.comment },
|
|
361
|
+
});
|
|
360
362
|
console.log(`✓ Fix submitted successfully`);
|
|
361
363
|
process.exit(0);
|
|
362
364
|
}
|
|
@@ -371,32 +373,41 @@ function ticketCommand(program) {
|
|
|
371
373
|
.option('--comment <text>', 'Review comment')
|
|
372
374
|
.option('--pass', 'Mark fix as passing (closes ticket)')
|
|
373
375
|
.option('--fail', 'Mark fix as failing (returns to IN_PROGRESS)')
|
|
376
|
+
.option('--json', 'Output as JSON')
|
|
374
377
|
.action(async (ref, options) => {
|
|
375
378
|
try {
|
|
376
379
|
if (!options.comment) {
|
|
377
|
-
(0,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
+
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
381
|
+
}
|
|
382
|
+
if (!options.pass && !options.fail) {
|
|
383
|
+
(0, error_1.handleApiError)(new Error('Specify exactly one of --pass or --fail'), { validationError: true });
|
|
384
|
+
}
|
|
385
|
+
if (options.pass && options.fail) {
|
|
386
|
+
(0, error_1.handleApiError)(new Error('Specify only one of --pass or --fail'), { validationError: true });
|
|
380
387
|
}
|
|
381
388
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
382
389
|
if (!ctx.projectSlug) {
|
|
383
|
-
(0,
|
|
384
|
-
process.exit(2);
|
|
385
|
-
return;
|
|
390
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
386
391
|
}
|
|
387
392
|
if (!ctx.apiKey) {
|
|
388
|
-
(0,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
body: options.comment,
|
|
396
|
-
type: 'REVIEW',
|
|
397
|
-
status,
|
|
393
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
394
|
+
}
|
|
395
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
396
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
397
|
+
await (0, generated_1.ticketsControllerVerifyFix)({
|
|
398
|
+
slug: ctx.projectSlug,
|
|
399
|
+
ref,
|
|
400
|
+
requestBody: { body: options.comment },
|
|
398
401
|
});
|
|
399
|
-
|
|
402
|
+
// The generated client currently does not expose the approve query param.
|
|
403
|
+
// Preserve expected CLI semantics: --pass should conclude with CLOSED.
|
|
404
|
+
if (options.pass) {
|
|
405
|
+
await (0, generated_1.ticketsControllerClose)({ slug: ctx.projectSlug, ref });
|
|
406
|
+
console.log(`✓ Fix verified and ticket closed successfully`);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
console.log(`✓ Fix verification submitted successfully`);
|
|
410
|
+
}
|
|
400
411
|
process.exit(0);
|
|
401
412
|
}
|
|
402
413
|
catch (err) {
|
|
@@ -407,21 +418,19 @@ function ticketCommand(program) {
|
|
|
407
418
|
.command('close <ref>')
|
|
408
419
|
.description('Close a ticket')
|
|
409
420
|
.option('--project <slug>', 'Project slug')
|
|
421
|
+
.option('--json', 'Output as JSON')
|
|
410
422
|
.action(async (ref, options) => {
|
|
411
423
|
try {
|
|
412
424
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
413
425
|
if (!ctx.projectSlug) {
|
|
414
|
-
(0,
|
|
415
|
-
process.exit(2);
|
|
416
|
-
return;
|
|
426
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
417
427
|
}
|
|
418
428
|
if (!ctx.apiKey) {
|
|
419
|
-
(0,
|
|
420
|
-
process.exit(2);
|
|
421
|
-
return;
|
|
429
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
422
430
|
}
|
|
423
|
-
|
|
424
|
-
|
|
431
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
432
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
433
|
+
await (0, generated_1.ticketsControllerClose)({ slug: ctx.projectSlug, ref });
|
|
425
434
|
console.log(`✓ Ticket closed successfully`);
|
|
426
435
|
process.exit(0);
|
|
427
436
|
}
|
|
@@ -434,28 +443,25 @@ function ticketCommand(program) {
|
|
|
434
443
|
.description('Reject a ticket')
|
|
435
444
|
.option('--project <slug>', 'Project slug')
|
|
436
445
|
.option('--comment <text>', 'Rejection reason')
|
|
446
|
+
.option('--json', 'Output as JSON')
|
|
437
447
|
.action(async (ref, options) => {
|
|
438
448
|
try {
|
|
439
449
|
if (!options.comment) {
|
|
440
|
-
(0,
|
|
441
|
-
process.exit(3);
|
|
442
|
-
return;
|
|
450
|
+
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
443
451
|
}
|
|
444
452
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
445
453
|
if (!ctx.projectSlug) {
|
|
446
|
-
(0,
|
|
447
|
-
process.exit(2);
|
|
448
|
-
return;
|
|
454
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
449
455
|
}
|
|
450
456
|
if (!ctx.apiKey) {
|
|
451
|
-
(0,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
458
|
+
}
|
|
459
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
460
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
461
|
+
await (0, generated_1.ticketsControllerReject)({
|
|
462
|
+
slug: ctx.projectSlug,
|
|
463
|
+
ref,
|
|
464
|
+
requestBody: { body: options.comment },
|
|
459
465
|
});
|
|
460
466
|
console.log(`✓ Ticket rejected successfully`);
|
|
461
467
|
process.exit(0);
|
|
@@ -476,24 +482,21 @@ function ticketCommand(program) {
|
|
|
476
482
|
try {
|
|
477
483
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
478
484
|
if (!ctx.projectSlug) {
|
|
479
|
-
(0,
|
|
480
|
-
process.exit(2);
|
|
481
|
-
return;
|
|
485
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
482
486
|
}
|
|
483
487
|
if (!ctx.apiKey) {
|
|
484
|
-
(0,
|
|
485
|
-
process.exit(2);
|
|
486
|
-
return;
|
|
488
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
487
489
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
491
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
492
|
+
const requestBody = {};
|
|
490
493
|
if (options.title)
|
|
491
|
-
|
|
494
|
+
requestBody.title = options.title;
|
|
492
495
|
if (options.desc)
|
|
493
|
-
|
|
496
|
+
requestBody.description = options.desc;
|
|
494
497
|
if (options.priority)
|
|
495
|
-
|
|
496
|
-
const response = await generated_1.
|
|
498
|
+
requestBody.priority = options.priority;
|
|
499
|
+
const response = await (0, generated_1.ticketsControllerUpdate)({ slug: ctx.projectSlug, ref, requestBody });
|
|
497
500
|
const ticketData = (0, api_1.unwrap)(response);
|
|
498
501
|
if (options.json) {
|
|
499
502
|
console.log(JSON.stringify(ticketData, null, 2));
|
|
@@ -515,22 +518,18 @@ function ticketCommand(program) {
|
|
|
515
518
|
.action(async (ref, options) => {
|
|
516
519
|
try {
|
|
517
520
|
if (!options.force) {
|
|
518
|
-
(0,
|
|
519
|
-
process.exit(1);
|
|
521
|
+
(0, error_1.handleApiError)(new Error('Deletion requires --force flag.'), { validationError: true });
|
|
520
522
|
}
|
|
521
523
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
522
524
|
if (!ctx.projectSlug) {
|
|
523
|
-
(0,
|
|
524
|
-
process.exit(2);
|
|
525
|
-
return;
|
|
525
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
526
526
|
}
|
|
527
527
|
if (!ctx.apiKey) {
|
|
528
|
-
(0,
|
|
529
|
-
process.exit(2);
|
|
530
|
-
return;
|
|
528
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
531
529
|
}
|
|
532
|
-
|
|
533
|
-
|
|
530
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
531
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
532
|
+
await (0, generated_1.ticketsControllerSoftDelete)({ slug: ctx.projectSlug, ref });
|
|
534
533
|
console.log(`✓ Ticket deleted successfully`);
|
|
535
534
|
process.exit(0);
|
|
536
535
|
}
|
|
@@ -548,17 +547,18 @@ function ticketCommand(program) {
|
|
|
548
547
|
try {
|
|
549
548
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
550
549
|
if (!ctx.projectSlug) {
|
|
551
|
-
(0,
|
|
552
|
-
process.exit(2);
|
|
553
|
-
return;
|
|
550
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
554
551
|
}
|
|
555
552
|
if (!ctx.apiKey) {
|
|
556
|
-
(0,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
|
|
553
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
554
|
+
}
|
|
555
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
556
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
557
|
+
const response = await (0, generated_1.ticketLinksControllerCreate)({
|
|
558
|
+
slug: ctx.projectSlug,
|
|
559
|
+
ref,
|
|
560
|
+
requestBody: { url: options.url },
|
|
561
|
+
});
|
|
562
562
|
const linkData = (0, api_1.unwrap)(response);
|
|
563
563
|
if (options.json) {
|
|
564
564
|
console.log(JSON.stringify(linkData, null, 2));
|
|
@@ -582,25 +582,21 @@ function ticketCommand(program) {
|
|
|
582
582
|
try {
|
|
583
583
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
584
584
|
if (!ctx.projectSlug) {
|
|
585
|
-
(0,
|
|
586
|
-
process.exit(2);
|
|
587
|
-
return;
|
|
585
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
588
586
|
}
|
|
589
587
|
if (!ctx.apiKey) {
|
|
590
|
-
(0,
|
|
591
|
-
process.exit(2);
|
|
592
|
-
return;
|
|
588
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
593
589
|
}
|
|
594
|
-
|
|
595
|
-
|
|
590
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
591
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
592
|
+
const listResponse = await (0, generated_1.ticketLinksControllerFindAll)({ slug: ctx.projectSlug, ref });
|
|
596
593
|
const links = (0, api_1.unwrap)(listResponse);
|
|
597
594
|
const match = links.find((l) => l.url === options.url);
|
|
598
595
|
if (!match) {
|
|
599
596
|
console.log(`No link found for ${options.url}`);
|
|
600
597
|
process.exit(1);
|
|
601
|
-
return;
|
|
602
598
|
}
|
|
603
|
-
await generated_1.
|
|
599
|
+
await (0, generated_1.ticketLinksControllerRemove)({ slug: ctx.projectSlug, ref, linkId: match.id });
|
|
604
600
|
process.exit(0);
|
|
605
601
|
}
|
|
606
602
|
catch (err) {
|
|
@@ -617,17 +613,18 @@ function ticketCommand(program) {
|
|
|
617
613
|
try {
|
|
618
614
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
619
615
|
if (!ctx.projectSlug) {
|
|
620
|
-
(0,
|
|
621
|
-
process.exit(2);
|
|
622
|
-
return;
|
|
616
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
623
617
|
}
|
|
624
618
|
if (!ctx.apiKey) {
|
|
625
|
-
(0,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
619
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
620
|
+
}
|
|
621
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
622
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
623
|
+
await (0, generated_1.labelsControllerAssignLabelFromHttp)({
|
|
624
|
+
slug: ctx.projectSlug,
|
|
625
|
+
ref,
|
|
626
|
+
requestBody: { labelId: options.label },
|
|
627
|
+
});
|
|
631
628
|
console.log(`✓ Label attached to ticket ${ref}`);
|
|
632
629
|
process.exit(0);
|
|
633
630
|
}
|
|
@@ -645,17 +642,18 @@ function ticketCommand(program) {
|
|
|
645
642
|
try {
|
|
646
643
|
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
647
644
|
if (!ctx.projectSlug) {
|
|
648
|
-
(0,
|
|
649
|
-
process.exit(2);
|
|
650
|
-
return;
|
|
645
|
+
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
651
646
|
}
|
|
652
647
|
if (!ctx.apiKey) {
|
|
653
|
-
(0,
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
648
|
+
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
649
|
+
}
|
|
650
|
+
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
651
|
+
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
652
|
+
await (0, generated_1.labelsControllerRemoveLabelFromHttp)({
|
|
653
|
+
slug: ctx.projectSlug,
|
|
654
|
+
ref,
|
|
655
|
+
labelId: options.label,
|
|
656
|
+
});
|
|
659
657
|
console.log(`✓ Label detached from ticket ${ref}`);
|
|
660
658
|
process.exit(0);
|
|
661
659
|
}
|