@nathapp/koda-cli 0.4.2 → 0.5.0-canary.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/dist/commands/admin.d.ts +3 -0
- package/dist/commands/admin.d.ts.map +1 -0
- package/dist/commands/admin.js +98 -0
- package/dist/commands/admin.js.map +1 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +147 -22
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/approval.d.ts +3 -0
- package/dist/commands/approval.d.ts.map +1 -0
- package/dist/commands/approval.js +319 -0
- package/dist/commands/approval.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +97 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/ci-webhook.d.ts +3 -0
- package/dist/commands/ci-webhook.d.ts.map +1 -0
- package/dist/commands/ci-webhook.js +83 -0
- package/dist/commands/ci-webhook.js.map +1 -0
- package/dist/commands/code-intel.d.ts +3 -0
- package/dist/commands/code-intel.d.ts.map +1 -0
- package/dist/commands/code-intel.js +107 -0
- package/dist/commands/code-intel.js.map +1 -0
- package/dist/commands/comment.d.ts.map +1 -1
- package/dist/commands/comment.js +21 -63
- package/dist/commands/comment.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +2 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +64 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/evaluate.d.ts +3 -0
- package/dist/commands/evaluate.d.ts.map +1 -0
- package/dist/commands/evaluate.js +108 -0
- package/dist/commands/evaluate.js.map +1 -0
- package/dist/commands/fleet-analytics.d.ts +9 -0
- package/dist/commands/fleet-analytics.d.ts.map +1 -0
- package/dist/commands/fleet-analytics.js +235 -0
- package/dist/commands/fleet-analytics.js.map +1 -0
- package/dist/commands/fleet-budget.d.ts +27 -0
- package/dist/commands/fleet-budget.d.ts.map +1 -0
- package/dist/commands/fleet-budget.js +217 -0
- package/dist/commands/fleet-budget.js.map +1 -0
- package/dist/commands/fleet-config.d.ts +3 -0
- package/dist/commands/fleet-config.d.ts.map +1 -0
- package/dist/commands/fleet-config.js +62 -0
- package/dist/commands/fleet-config.js.map +1 -0
- package/dist/commands/fleet-dispatch.d.ts +9 -0
- package/dist/commands/fleet-dispatch.d.ts.map +1 -0
- package/dist/commands/fleet-dispatch.js +134 -0
- package/dist/commands/fleet-dispatch.js.map +1 -0
- package/dist/commands/fleet-ingest.d.ts +4 -0
- package/dist/commands/fleet-ingest.d.ts.map +1 -0
- package/dist/commands/fleet-ingest.js +93 -0
- package/dist/commands/fleet-ingest.js.map +1 -0
- package/dist/commands/fleet-job-logs.d.ts +46 -0
- package/dist/commands/fleet-job-logs.d.ts.map +1 -0
- package/dist/commands/fleet-job-logs.js +139 -0
- package/dist/commands/fleet-job-logs.js.map +1 -0
- package/dist/commands/fleet-job-rulings.d.ts +3 -0
- package/dist/commands/fleet-job-rulings.d.ts.map +1 -0
- package/dist/commands/fleet-job-rulings.js +60 -0
- package/dist/commands/fleet-job-rulings.js.map +1 -0
- package/dist/commands/fleet-job.d.ts +3 -0
- package/dist/commands/fleet-job.d.ts.map +1 -0
- package/dist/commands/fleet-job.js +201 -0
- package/dist/commands/fleet-job.js.map +1 -0
- package/dist/commands/fleet-repo.d.ts +3 -0
- package/dist/commands/fleet-repo.d.ts.map +1 -0
- package/dist/commands/fleet-repo.js +200 -0
- package/dist/commands/fleet-repo.js.map +1 -0
- package/dist/commands/fleet-runner.d.ts +3 -0
- package/dist/commands/fleet-runner.d.ts.map +1 -0
- package/dist/commands/fleet-runner.js +109 -0
- package/dist/commands/fleet-runner.js.map +1 -0
- package/dist/commands/fleet-schedule.d.ts +10 -0
- package/dist/commands/fleet-schedule.d.ts.map +1 -0
- package/dist/commands/fleet-schedule.js +291 -0
- package/dist/commands/fleet-schedule.js.map +1 -0
- package/dist/commands/fleet-shared.d.ts +43 -0
- package/dist/commands/fleet-shared.d.ts.map +1 -0
- package/dist/commands/fleet-shared.js +155 -0
- package/dist/commands/fleet-shared.js.map +1 -0
- package/dist/commands/fleet-status.d.ts +10 -0
- package/dist/commands/fleet-status.d.ts.map +1 -0
- package/dist/commands/fleet-status.js +101 -0
- package/dist/commands/fleet-status.js.map +1 -0
- package/dist/commands/fleet.d.ts +4 -0
- package/dist/commands/fleet.d.ts.map +1 -0
- package/dist/commands/fleet.js +30 -0
- package/dist/commands/fleet.js.map +1 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +35 -8
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/kb.d.ts.map +1 -1
- package/dist/commands/kb.js +109 -94
- package/dist/commands/kb.js.map +1 -1
- package/dist/commands/label.d.ts.map +1 -1
- package/dist/commands/label.js +15 -49
- package/dist/commands/label.js.map +1 -1
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +52 -7
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/member.d.ts +3 -0
- package/dist/commands/member.d.ts.map +1 -0
- package/dist/commands/member.js +221 -0
- package/dist/commands/member.js.map +1 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +282 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/notifications.d.ts +3 -0
- package/dist/commands/notifications.d.ts.map +1 -0
- package/dist/commands/notifications.js +72 -0
- package/dist/commands/notifications.js.map +1 -0
- package/dist/commands/project.d.ts.map +1 -1
- package/dist/commands/project.js +53 -35
- package/dist/commands/project.js.map +1 -1
- package/dist/commands/role-binding.d.ts +14 -0
- package/dist/commands/role-binding.d.ts.map +1 -0
- package/dist/commands/role-binding.js +136 -0
- package/dist/commands/role-binding.js.map +1 -0
- package/dist/commands/ticket-watch.d.ts +4 -0
- package/dist/commands/ticket-watch.d.ts.map +1 -0
- package/dist/commands/ticket-watch.js +36 -0
- package/dist/commands/ticket-watch.js.map +1 -0
- package/dist/commands/ticket.d.ts.map +1 -1
- package/dist/commands/ticket.js +174 -244
- package/dist/commands/ticket.js.map +1 -1
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +89 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/vcs-messages.d.ts +4 -3
- package/dist/commands/vcs-messages.d.ts.map +1 -1
- package/dist/commands/vcs-messages.js +4 -3
- package/dist/commands/vcs-messages.js.map +1 -1
- package/dist/commands/vcs.d.ts.map +1 -1
- package/dist/commands/vcs.js +99 -196
- package/dist/commands/vcs.js.map +1 -1
- package/dist/commands/webhook.d.ts +3 -0
- package/dist/commands/webhook.d.ts.map +1 -0
- package/dist/commands/webhook.js +98 -0
- package/dist/commands/webhook.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +111 -7
- package/dist/config.js.map +1 -1
- package/dist/generated/client/client.gen.d.ts +3 -0
- package/dist/generated/client/client.gen.d.ts.map +1 -0
- package/dist/generated/client/client.gen.js +221 -0
- package/dist/generated/client/client.gen.js.map +1 -0
- package/dist/generated/client/index.d.ts +11 -0
- package/dist/generated/client/index.d.ts.map +1 -0
- package/dist/generated/client/index.js +18 -0
- package/dist/generated/client/index.js.map +1 -0
- package/dist/generated/client/types.gen.d.ts +121 -0
- package/dist/generated/client/types.gen.d.ts.map +1 -0
- package/dist/generated/client/types.gen.js +4 -0
- package/dist/generated/client/types.gen.js.map +1 -0
- package/dist/generated/client/utils.gen.d.ts +38 -0
- package/dist/generated/client/utils.gen.d.ts.map +1 -0
- package/dist/generated/client/utils.gen.js +240 -0
- package/dist/generated/client/utils.gen.js.map +1 -0
- package/dist/generated/client.gen.d.ts +13 -0
- package/dist/generated/client.gen.d.ts.map +1 -0
- package/dist/generated/client.gen.js +7 -0
- package/dist/generated/client.gen.js.map +1 -0
- package/dist/generated/core/auth.gen.d.ts +26 -0
- package/dist/generated/core/auth.gen.d.ts.map +1 -0
- package/dist/generated/core/auth.gen.js +19 -0
- package/dist/generated/core/auth.gen.js.map +1 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +26 -0
- package/dist/generated/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/bodySerializer.gen.js +61 -0
- package/dist/generated/core/bodySerializer.gen.js.map +1 -0
- package/dist/generated/core/params.gen.d.ts +44 -0
- package/dist/generated/core/params.gen.d.ts.map +1 -0
- package/dist/generated/core/params.gen.js +113 -0
- package/dist/generated/core/params.gen.js.map +1 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +34 -0
- package/dist/generated/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/pathSerializer.gen.js +116 -0
- package/dist/generated/core/pathSerializer.gen.js.map +1 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/queryKeySerializer.gen.js +99 -0
- package/dist/generated/core/queryKeySerializer.gen.js.map +1 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/generated/core/serverSentEvents.gen.js +136 -0
- package/dist/generated/core/serverSentEvents.gen.js.map +1 -0
- package/dist/generated/core/types.gen.d.ts +84 -0
- package/dist/generated/core/types.gen.d.ts.map +1 -0
- package/dist/generated/core/types.gen.js +4 -0
- package/dist/generated/core/types.gen.js.map +1 -0
- package/dist/generated/core/utils.gen.d.ts +20 -0
- package/dist/generated/core/utils.gen.d.ts.map +1 -0
- package/dist/generated/core/utils.gen.js +94 -0
- package/dist/generated/core/utils.gen.js.map +1 -0
- package/dist/generated/index.d.ts +2 -6
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +288 -26
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/sdk.gen.d.ts +1136 -0
- package/dist/generated/sdk.gen.d.ts.map +1 -0
- package/dist/generated/sdk.gen.js +3200 -0
- package/dist/generated/sdk.gen.js.map +1 -0
- package/dist/generated/types.gen.d.ts +12034 -1280
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/index.js +118 -33
- package/dist/index.js.map +1 -1
- package/dist/utils/api-client.d.ts +9 -0
- package/dist/utils/api-client.d.ts.map +1 -0
- package/dist/utils/api-client.js +30 -0
- package/dist/utils/api-client.js.map +1 -0
- package/dist/utils/api-error-code.d.ts +6 -0
- package/dist/utils/api-error-code.d.ts.map +1 -0
- package/dist/utils/api-error-code.js +14 -0
- package/dist/utils/api-error-code.js.map +1 -0
- package/dist/utils/approval-pending.d.ts +12 -0
- package/dist/utils/approval-pending.d.ts.map +1 -0
- package/dist/utils/approval-pending.js +13 -0
- package/dist/utils/approval-pending.js.map +1 -0
- package/dist/utils/auth.d.ts +9 -1
- package/dist/utils/auth.d.ts.map +1 -1
- package/dist/utils/auth.js +13 -7
- package/dist/utils/auth.js.map +1 -1
- package/dist/utils/context.d.ts +29 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +22 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/error.d.ts +9 -1
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +91 -27
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/force.d.ts +7 -0
- package/dist/utils/force.d.ts.map +1 -0
- package/dist/utils/force.js +17 -0
- package/dist/utils/force.js.map +1 -0
- package/dist/utils/json-mode.d.ts +3 -0
- package/dist/utils/json-mode.d.ts.map +1 -0
- package/dist/utils/json-mode.js +25 -0
- package/dist/utils/json-mode.js.map +1 -0
- package/dist/utils/output.d.ts +4 -0
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +50 -0
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/parse-positive-int.d.ts +8 -0
- package/dist/utils/parse-positive-int.d.ts.map +1 -0
- package/dist/utils/parse-positive-int.js +19 -0
- package/dist/utils/parse-positive-int.js.map +1 -0
- package/dist/utils/parse-usd.d.ts +8 -0
- package/dist/utils/parse-usd.d.ts.map +1 -0
- package/dist/utils/parse-usd.js +27 -0
- package/dist/utils/parse-usd.js.map +1 -0
- package/dist/utils/secret-input.d.ts +32 -0
- package/dist/utils/secret-input.d.ts.map +1 -0
- package/dist/utils/secret-input.js +106 -0
- package/dist/utils/secret-input.js.map +1 -0
- package/dist/utils/signals.d.ts +14 -0
- package/dist/utils/signals.d.ts.map +1 -0
- package/dist/utils/signals.js +23 -0
- package/dist/utils/signals.js.map +1 -0
- package/package.json +4 -3
- package/dist/generated/core/ApiError.d.ts +0 -11
- package/dist/generated/core/ApiError.d.ts.map +0 -1
- package/dist/generated/core/ApiError.js +0 -21
- package/dist/generated/core/ApiError.js.map +0 -1
- package/dist/generated/core/ApiRequestOptions.d.ts +0 -14
- package/dist/generated/core/ApiRequestOptions.d.ts.map +0 -1
- package/dist/generated/core/ApiRequestOptions.js +0 -3
- package/dist/generated/core/ApiRequestOptions.js.map +0 -1
- package/dist/generated/core/ApiResult.d.ts +0 -8
- package/dist/generated/core/ApiResult.d.ts.map +0 -1
- package/dist/generated/core/ApiResult.js +0 -3
- package/dist/generated/core/ApiResult.js.map +0 -1
- package/dist/generated/core/CancelablePromise.d.ts +0 -27
- package/dist/generated/core/CancelablePromise.d.ts.map +0 -1
- package/dist/generated/core/CancelablePromise.js +0 -101
- package/dist/generated/core/CancelablePromise.js.map +0 -1
- package/dist/generated/core/OpenAPI.d.ts +0 -29
- package/dist/generated/core/OpenAPI.d.ts.map +0 -1
- package/dist/generated/core/OpenAPI.js +0 -35
- package/dist/generated/core/OpenAPI.js.map +0 -1
- package/dist/generated/core/request.d.ts +0 -33
- package/dist/generated/core/request.d.ts.map +0 -1
- package/dist/generated/core/request.js +0 -310
- package/dist/generated/core/request.js.map +0 -1
- package/dist/generated/schemas.gen.d.ts +0 -895
- package/dist/generated/schemas.gen.d.ts.map +0 -1
- package/dist/generated/schemas.gen.js +0 -903
- package/dist/generated/schemas.gen.js.map +0 -1
- package/dist/generated/services.gen.d.ts +0 -546
- package/dist/generated/services.gen.d.ts.map +0 -1
- package/dist/generated/services.gen.js +0 -1393
- package/dist/generated/services.gen.js.map +0 -1
- package/dist/vcs-client.stub.d.ts +0 -74
- package/dist/vcs-client.stub.d.ts.map +0 -1
- package/dist/vcs-client.stub.js +0 -40
- package/dist/vcs-client.stub.js.map +0 -1
package/dist/commands/ticket.js
CHANGED
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ticketCommand = ticketCommand;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
const OpenAPI_1 = require("../generated/core/OpenAPI");
|
|
6
4
|
const generated_1 = require("../generated");
|
|
7
5
|
const output_1 = require("../utils/output");
|
|
8
6
|
const api_1 = require("../utils/api");
|
|
9
7
|
const error_1 = require("../utils/error");
|
|
8
|
+
const force_1 = require("../utils/force");
|
|
9
|
+
const context_1 = require("../utils/context");
|
|
10
|
+
const parse_positive_int_1 = require("../utils/parse-positive-int");
|
|
11
|
+
const ticket_watch_1 = require("./ticket-watch");
|
|
12
|
+
const FAILED_STATES = new Set(['FAILED', 'ESCALATED', 'CRASHED']);
|
|
13
|
+
/**
|
|
14
|
+
* Render a supplied-but-invalid ticket field for a validation message. An empty
|
|
15
|
+
* string or a non-string JSON value (`false`, `0`) would otherwise print as
|
|
16
|
+
* nothing, so show its JSON form and let the message name what was rejected.
|
|
17
|
+
*/
|
|
18
|
+
function describeSuppliedValue(value) {
|
|
19
|
+
if (typeof value === 'string' && value !== '')
|
|
20
|
+
return value;
|
|
21
|
+
return JSON.stringify(value) ?? String(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fleet C9 §5: the ticket's fleet jobs. A courtesy section: any failure (an older API without the
|
|
25
|
+
* endpoint, a network error) shows the ticket without it rather than failing `ticket show`.
|
|
26
|
+
*/
|
|
27
|
+
async function fleetJobsOf(slug, ref) {
|
|
28
|
+
try {
|
|
29
|
+
return (0, api_1.unwrap)(await (0, generated_1.ticketFleetJobsControllerList)({ path: { slug, ref } })) ?? [];
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function printFleetRuns(jobs) {
|
|
36
|
+
if (jobs.length === 0)
|
|
37
|
+
return;
|
|
38
|
+
console.log(`\nFleet runs:`);
|
|
39
|
+
for (const job of jobs) {
|
|
40
|
+
console.log(` - ${job.command} ${job.feature} ${job.state} ${job.id} $${job.costUsd}`);
|
|
41
|
+
if (job.resultBranch)
|
|
42
|
+
console.log(` branch ${job.resultBranch}${job.resultSha ? ` @ ${job.resultSha.slice(0, 7)}` : ''}`);
|
|
43
|
+
if (job.resultPrUrl)
|
|
44
|
+
console.log(` PR ${job.resultPrUrl}`);
|
|
45
|
+
const reason = job.escalationReason ?? job.stateReason;
|
|
46
|
+
if (reason && FAILED_STATES.has(job.state))
|
|
47
|
+
console.log(` reason: ${reason}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
10
50
|
function ticketCommand(program) {
|
|
11
51
|
const ticket = program.command('ticket');
|
|
12
52
|
ticket.description('Manage tickets');
|
|
@@ -21,43 +61,44 @@ function ticketCommand(program) {
|
|
|
21
61
|
.option('--json', 'Output as JSON')
|
|
22
62
|
.action(async (options) => {
|
|
23
63
|
try {
|
|
24
|
-
const ctx = await (0,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
65
|
+
const effectiveType = options.type ?? ctx.defaults?.type;
|
|
66
|
+
// `unknown` on purpose: a project default is untrusted JSON, so a supplied
|
|
67
|
+
// value is validated even when it is falsy (`''`, `false`, `0`). Only an
|
|
68
|
+
// absent value (undefined/null) leaves the priority unspecified.
|
|
69
|
+
const effectivePriority = options.priority ?? ctx.defaults?.priority;
|
|
70
|
+
if (!options.title) {
|
|
71
|
+
return (0, error_1.handleApiError)(new Error('Missing required option: --title is required'), { validationError: true });
|
|
72
|
+
}
|
|
73
|
+
if (!effectiveType) {
|
|
74
|
+
return (0, error_1.handleApiError)(new Error('Missing required option: --type is required'), { validationError: true });
|
|
33
75
|
}
|
|
34
76
|
const validTypes = ['BUG', 'ENHANCEMENT', 'TASK', 'QUESTION'];
|
|
35
|
-
if (!validTypes.includes(
|
|
36
|
-
(0, error_1.handleApiError)(new Error(`Invalid type ${
|
|
77
|
+
if (!validTypes.includes(effectiveType)) {
|
|
78
|
+
return (0, error_1.handleApiError)(new Error(`Invalid type ${effectiveType}. Valid values: ${validTypes.join(', ')}`), { validationError: true });
|
|
37
79
|
}
|
|
38
80
|
const validPriorities = ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL'];
|
|
39
|
-
|
|
40
|
-
|
|
81
|
+
const prioritySupplied = effectivePriority !== undefined && effectivePriority !== null;
|
|
82
|
+
if (prioritySupplied && !validPriorities.includes(effectivePriority)) {
|
|
83
|
+
return (0, error_1.handleApiError)(new Error(`Invalid priority ${describeSuppliedValue(effectivePriority)}. Valid values: ${validPriorities.join(', ')}`), { validationError: true });
|
|
41
84
|
}
|
|
42
|
-
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
43
|
-
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
44
85
|
const response = await (0, generated_1.ticketsControllerCreate)({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
type: options.type,
|
|
86
|
+
body: {
|
|
87
|
+
type: effectiveType,
|
|
48
88
|
title: options.title,
|
|
49
89
|
description: options.desc,
|
|
50
|
-
priority:
|
|
90
|
+
priority: effectivePriority,
|
|
51
91
|
},
|
|
92
|
+
path: { slug: ctx.projectSlug },
|
|
52
93
|
});
|
|
53
94
|
const ticketData = (0, api_1.unwrap)(response);
|
|
54
95
|
if (options.json) {
|
|
55
96
|
console.log(JSON.stringify(ticketData, null, 2));
|
|
56
|
-
|
|
97
|
+
return (0, output_1.finishSuccess)();
|
|
57
98
|
}
|
|
58
99
|
else {
|
|
59
100
|
console.log(`✓ Ticket created successfully: ${ticketData.ref || `KODA-${ticketData.number}`}`);
|
|
60
|
-
|
|
101
|
+
return (0, output_1.finishSuccess)();
|
|
61
102
|
}
|
|
62
103
|
}
|
|
63
104
|
catch (err) {
|
|
@@ -73,32 +114,18 @@ function ticketCommand(program) {
|
|
|
73
114
|
.option('--priority <priority>', 'Filter by priority')
|
|
74
115
|
.option('--assigned-to <slug>', 'Filter by assignee')
|
|
75
116
|
.option('--unassigned', 'Show only unassigned tickets')
|
|
76
|
-
.option('--
|
|
77
|
-
.option('--
|
|
117
|
+
.option('--page <number>', 'Page number (1-based)', parse_positive_int_1.parsePositiveInt, 1)
|
|
118
|
+
.option('--size <number>', 'Tickets per page (1-100)', parse_positive_int_1.parsePositiveInt, 20)
|
|
78
119
|
.option('--json', 'Output as JSON')
|
|
79
120
|
.action(async (options) => {
|
|
80
121
|
try {
|
|
81
|
-
const ctx = await (0,
|
|
82
|
-
if (!ctx.projectSlug) {
|
|
83
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
84
|
-
}
|
|
85
|
-
if (!ctx.apiKey) {
|
|
86
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
87
|
-
}
|
|
88
|
-
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
89
|
-
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
122
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
90
123
|
const response = await (0, generated_1.ticketsControllerFindAll)({
|
|
91
|
-
slug: ctx.projectSlug,
|
|
92
|
-
status: options.status,
|
|
93
|
-
type: options.type,
|
|
94
|
-
priority: options.priority,
|
|
95
|
-
assignedTo: options.assignedTo,
|
|
96
|
-
unassigned: options.unassigned ? true : undefined,
|
|
97
|
-
limit: parseInt(options.limit, 10),
|
|
98
|
-
page: parseInt(options.page, 10),
|
|
124
|
+
path: { slug: ctx.projectSlug },
|
|
125
|
+
query: { status: options.status, type: options.type, priority: options.priority, assignedTo: options.assignedTo, unassigned: options.unassigned ? true : undefined, current: options.page, size: options.size }
|
|
99
126
|
});
|
|
100
|
-
const
|
|
101
|
-
const items =
|
|
127
|
+
const page = (0, api_1.unwrap)(response);
|
|
128
|
+
const items = page.records ?? [];
|
|
102
129
|
if (options.json) {
|
|
103
130
|
console.log(JSON.stringify(items, null, 2));
|
|
104
131
|
}
|
|
@@ -112,8 +139,11 @@ function ticketCommand(program) {
|
|
|
112
139
|
String(t.title),
|
|
113
140
|
]);
|
|
114
141
|
(0, output_1.table)(['#', 'Type', 'Priority', 'Status', 'Assignee', 'Title'], rows);
|
|
142
|
+
if (page.hasNext) {
|
|
143
|
+
console.log(`\nShowing page ${page.current} (${items.length} of ${page.total}). More: --page ${page.current + 1}`);
|
|
144
|
+
}
|
|
115
145
|
}
|
|
116
|
-
|
|
146
|
+
return (0, output_1.finishSuccess)();
|
|
117
147
|
}
|
|
118
148
|
catch (err) {
|
|
119
149
|
(0, error_1.handleApiError)(err);
|
|
@@ -127,22 +157,13 @@ function ticketCommand(program) {
|
|
|
127
157
|
.option('--json', 'Output as JSON')
|
|
128
158
|
.action(async (options) => {
|
|
129
159
|
try {
|
|
130
|
-
const ctx = await (0,
|
|
131
|
-
if (!ctx.projectSlug) {
|
|
132
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
133
|
-
}
|
|
134
|
-
if (!ctx.apiKey) {
|
|
135
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
136
|
-
}
|
|
137
|
-
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
138
|
-
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
160
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
139
161
|
const response = await (0, generated_1.ticketsControllerFindAll)({
|
|
140
|
-
slug: ctx.projectSlug,
|
|
141
|
-
status: options.status,
|
|
142
|
-
assignedTo: 'self',
|
|
162
|
+
path: { slug: ctx.projectSlug },
|
|
163
|
+
query: { status: options.status, assignedTo: 'self' }
|
|
143
164
|
});
|
|
144
|
-
const
|
|
145
|
-
const items =
|
|
165
|
+
const page = (0, api_1.unwrap)(response);
|
|
166
|
+
const items = page.records ?? [];
|
|
146
167
|
if (options.json) {
|
|
147
168
|
console.log(JSON.stringify(items, null, 2));
|
|
148
169
|
}
|
|
@@ -157,7 +178,7 @@ function ticketCommand(program) {
|
|
|
157
178
|
]);
|
|
158
179
|
(0, output_1.table)(['#', 'Type', 'Priority', 'Status', 'Assignee', 'Title'], rows);
|
|
159
180
|
}
|
|
160
|
-
|
|
181
|
+
return (0, output_1.finishSuccess)();
|
|
161
182
|
}
|
|
162
183
|
catch (err) {
|
|
163
184
|
(0, error_1.handleApiError)(err);
|
|
@@ -170,19 +191,12 @@ function ticketCommand(program) {
|
|
|
170
191
|
.option('--json', 'Output as JSON')
|
|
171
192
|
.action(async (ref, options) => {
|
|
172
193
|
try {
|
|
173
|
-
const ctx = await (0,
|
|
174
|
-
|
|
175
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
176
|
-
}
|
|
177
|
-
if (!ctx.apiKey) {
|
|
178
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
179
|
-
}
|
|
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 });
|
|
194
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
195
|
+
const response = await (0, generated_1.ticketsControllerFindByRef)({ path: { slug: ctx.projectSlug, ref } });
|
|
183
196
|
const ticketData = (0, api_1.unwrap)(response);
|
|
197
|
+
const fleetJobs = await fleetJobsOf(ctx.projectSlug, ref);
|
|
184
198
|
if (options.json) {
|
|
185
|
-
console.log(JSON.stringify(ticketData, null, 2));
|
|
199
|
+
console.log(JSON.stringify({ ...ticketData, fleetJobs }, null, 2));
|
|
186
200
|
}
|
|
187
201
|
else {
|
|
188
202
|
console.log(`\n${'Ticket Details'}:`);
|
|
@@ -238,8 +252,9 @@ function ticketCommand(program) {
|
|
|
238
252
|
}
|
|
239
253
|
}
|
|
240
254
|
}
|
|
255
|
+
printFleetRuns(fleetJobs);
|
|
241
256
|
}
|
|
242
|
-
|
|
257
|
+
return (0, output_1.finishSuccess)();
|
|
243
258
|
}
|
|
244
259
|
catch (err) {
|
|
245
260
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -256,22 +271,13 @@ function ticketCommand(program) {
|
|
|
256
271
|
if (!options.comment) {
|
|
257
272
|
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
258
273
|
}
|
|
259
|
-
const ctx = await (0,
|
|
260
|
-
if (!ctx.projectSlug) {
|
|
261
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
262
|
-
}
|
|
263
|
-
if (!ctx.apiKey) {
|
|
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;
|
|
274
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
268
275
|
await (0, generated_1.ticketsControllerVerify)({
|
|
269
|
-
|
|
270
|
-
ref
|
|
271
|
-
requestBody: { body: options.comment },
|
|
276
|
+
body: { body: options.comment },
|
|
277
|
+
path: { slug: ctx.projectSlug, ref }
|
|
272
278
|
});
|
|
273
279
|
console.log(`✓ Ticket verified successfully`);
|
|
274
|
-
|
|
280
|
+
return (0, output_1.finishSuccess)();
|
|
275
281
|
}
|
|
276
282
|
catch (err) {
|
|
277
283
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -279,31 +285,51 @@ function ticketCommand(program) {
|
|
|
279
285
|
});
|
|
280
286
|
ticket
|
|
281
287
|
.command('assign <ref>')
|
|
282
|
-
.description('Assign a ticket')
|
|
288
|
+
.description('Assign a ticket to an agent (--to/--agent) or user (--user), or unassign with --unassign')
|
|
283
289
|
.option('--project <slug>', 'Project slug')
|
|
284
|
-
.option('--
|
|
285
|
-
.option('--
|
|
290
|
+
.option('--to <agent-slug>', 'Assign to agent by slug')
|
|
291
|
+
.option('--agent <agent-slug>', 'Deprecated alias for --to')
|
|
292
|
+
.option('--user <user-id>', 'Assign to user by ID (CUID)')
|
|
293
|
+
.option('--unassign', 'Remove the current assignee')
|
|
286
294
|
.option('--json', 'Output as JSON')
|
|
287
295
|
.action(async (ref, options) => {
|
|
288
296
|
try {
|
|
289
|
-
const
|
|
290
|
-
if (
|
|
291
|
-
(0, error_1.handleApiError)(new Error('
|
|
297
|
+
const requestedTarget = options.to ?? options.agent;
|
|
298
|
+
if (requestedTarget && options.user) {
|
|
299
|
+
(0, error_1.handleApiError)(new Error('Specify only one of --to/--agent or --user'), { validationError: true });
|
|
300
|
+
}
|
|
301
|
+
if (options.unassign && (requestedTarget || options.user)) {
|
|
302
|
+
(0, error_1.handleApiError)(new Error('--unassign cannot be combined with --to/--agent/--user'), { validationError: true });
|
|
303
|
+
}
|
|
304
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
305
|
+
// BUG-10: resolve the agent slug to its ID so the runtime API
|
|
306
|
+
// (which only accepts agentId/userId) actually assigns the target.
|
|
307
|
+
const requestBody = {};
|
|
308
|
+
if (requestedTarget) {
|
|
309
|
+
const agent = (0, api_1.unwrap)(await (0, generated_1.agentsControllerFindBySlug)({ path: { slug: requestedTarget } }));
|
|
310
|
+
requestBody.agentId = agent.id;
|
|
292
311
|
}
|
|
293
|
-
if (
|
|
294
|
-
|
|
312
|
+
else if (options.user) {
|
|
313
|
+
requestBody.userId = options.user;
|
|
295
314
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
315
|
+
const response = await (0, generated_1.ticketsControllerAssign)({
|
|
316
|
+
body: requestBody,
|
|
317
|
+
path: { slug: ctx.projectSlug, ref }
|
|
318
|
+
});
|
|
299
319
|
const ticketData = (0, api_1.unwrap)(response);
|
|
300
320
|
if (options.json) {
|
|
301
321
|
console.log(JSON.stringify(ticketData, null, 2));
|
|
302
322
|
}
|
|
323
|
+
else if (requestedTarget) {
|
|
324
|
+
console.log(`✓ Ticket assigned to agent '${requestedTarget}'`);
|
|
325
|
+
}
|
|
326
|
+
else if (options.user) {
|
|
327
|
+
console.log(`✓ Ticket assigned to user '${options.user}'`);
|
|
328
|
+
}
|
|
303
329
|
else {
|
|
304
|
-
console.log(`✓ Ticket
|
|
330
|
+
console.log(`✓ Ticket unassigned`);
|
|
305
331
|
}
|
|
306
|
-
|
|
332
|
+
return (0, output_1.finishSuccess)();
|
|
307
333
|
}
|
|
308
334
|
catch (err) {
|
|
309
335
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Agent or ticket not found` });
|
|
@@ -316,18 +342,10 @@ function ticketCommand(program) {
|
|
|
316
342
|
.option('--json', 'Output as JSON')
|
|
317
343
|
.action(async (ref, options) => {
|
|
318
344
|
try {
|
|
319
|
-
const ctx = await (0,
|
|
320
|
-
|
|
321
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
322
|
-
}
|
|
323
|
-
if (!ctx.apiKey) {
|
|
324
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
325
|
-
}
|
|
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 });
|
|
345
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
346
|
+
await (0, generated_1.ticketsControllerStart)({ path: { slug: ctx.projectSlug, ref } });
|
|
329
347
|
console.log(`✓ Ticket started successfully`);
|
|
330
|
-
|
|
348
|
+
return (0, output_1.finishSuccess)();
|
|
331
349
|
}
|
|
332
350
|
catch (err) {
|
|
333
351
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -345,22 +363,13 @@ function ticketCommand(program) {
|
|
|
345
363
|
if (!options.comment) {
|
|
346
364
|
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
347
365
|
}
|
|
348
|
-
const ctx = await (0,
|
|
349
|
-
if (!ctx.projectSlug) {
|
|
350
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
351
|
-
}
|
|
352
|
-
if (!ctx.apiKey) {
|
|
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;
|
|
366
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
357
367
|
await (0, generated_1.ticketsControllerFix)({
|
|
358
|
-
|
|
359
|
-
ref
|
|
360
|
-
requestBody: { body: options.comment },
|
|
368
|
+
body: { body: options.comment },
|
|
369
|
+
path: { slug: ctx.projectSlug, ref }
|
|
361
370
|
});
|
|
362
371
|
console.log(`✓ Fix submitted successfully`);
|
|
363
|
-
|
|
372
|
+
return (0, output_1.finishSuccess)();
|
|
364
373
|
}
|
|
365
374
|
catch (err) {
|
|
366
375
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -385,30 +394,16 @@ function ticketCommand(program) {
|
|
|
385
394
|
if (options.pass && options.fail) {
|
|
386
395
|
(0, error_1.handleApiError)(new Error('Specify only one of --pass or --fail'), { validationError: true });
|
|
387
396
|
}
|
|
388
|
-
const ctx = await (0,
|
|
389
|
-
if (!ctx.projectSlug) {
|
|
390
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
391
|
-
}
|
|
392
|
-
if (!ctx.apiKey) {
|
|
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
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
397
398
|
await (0, generated_1.ticketsControllerVerifyFix)({
|
|
398
|
-
|
|
399
|
-
ref,
|
|
400
|
-
|
|
399
|
+
body: { body: options.comment },
|
|
400
|
+
path: { slug: ctx.projectSlug, ref },
|
|
401
|
+
query: { approve: Boolean(options.pass) },
|
|
401
402
|
});
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
console.log(`✓ Fix verified and ticket closed successfully`);
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
console.log(`✓ Fix verification submitted successfully`);
|
|
410
|
-
}
|
|
411
|
-
process.exit(0);
|
|
403
|
+
console.log(options.pass
|
|
404
|
+
? `✓ Fix verified and ticket closed successfully`
|
|
405
|
+
: `✓ Fix verification submitted successfully`);
|
|
406
|
+
return (0, output_1.finishSuccess)();
|
|
412
407
|
}
|
|
413
408
|
catch (err) {
|
|
414
409
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -416,23 +411,19 @@ function ticketCommand(program) {
|
|
|
416
411
|
});
|
|
417
412
|
ticket
|
|
418
413
|
.command('close <ref>')
|
|
419
|
-
.description('Close a ticket')
|
|
414
|
+
.description('Close a ticket (project or global ADMIN only; the reason is recorded as a comment)')
|
|
420
415
|
.option('--project <slug>', 'Project slug')
|
|
416
|
+
.option('--reason <text>', 'Why the ticket is being closed (required)')
|
|
421
417
|
.option('--json', 'Output as JSON')
|
|
422
418
|
.action(async (ref, options) => {
|
|
423
419
|
try {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
427
|
-
}
|
|
428
|
-
if (!ctx.apiKey) {
|
|
429
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
420
|
+
if (!options.reason || !String(options.reason).trim()) {
|
|
421
|
+
(0, error_1.handleApiError)(new Error('--reason is required'), { validationError: true });
|
|
430
422
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
await (0, generated_1.ticketsControllerClose)({ slug: ctx.projectSlug, ref });
|
|
423
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
424
|
+
await (0, generated_1.ticketsControllerClose)({ body: { body: options.reason }, path: { slug: ctx.projectSlug, ref } });
|
|
434
425
|
console.log(`✓ Ticket closed successfully`);
|
|
435
|
-
|
|
426
|
+
return (0, output_1.finishSuccess)();
|
|
436
427
|
}
|
|
437
428
|
catch (err) {
|
|
438
429
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -449,22 +440,13 @@ function ticketCommand(program) {
|
|
|
449
440
|
if (!options.comment) {
|
|
450
441
|
(0, error_1.handleApiError)(new Error('Comment is required'), { validationError: true });
|
|
451
442
|
}
|
|
452
|
-
const ctx = await (0,
|
|
453
|
-
if (!ctx.projectSlug) {
|
|
454
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
455
|
-
}
|
|
456
|
-
if (!ctx.apiKey) {
|
|
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;
|
|
443
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
461
444
|
await (0, generated_1.ticketsControllerReject)({
|
|
462
|
-
|
|
463
|
-
ref
|
|
464
|
-
requestBody: { body: options.comment },
|
|
445
|
+
body: { body: options.comment },
|
|
446
|
+
path: { slug: ctx.projectSlug, ref }
|
|
465
447
|
});
|
|
466
448
|
console.log(`✓ Ticket rejected successfully`);
|
|
467
|
-
|
|
449
|
+
return (0, output_1.finishSuccess)();
|
|
468
450
|
}
|
|
469
451
|
catch (err) {
|
|
470
452
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -480,15 +462,7 @@ function ticketCommand(program) {
|
|
|
480
462
|
.option('--json', 'Output as JSON')
|
|
481
463
|
.action(async (ref, options) => {
|
|
482
464
|
try {
|
|
483
|
-
const ctx = await (0,
|
|
484
|
-
if (!ctx.projectSlug) {
|
|
485
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
486
|
-
}
|
|
487
|
-
if (!ctx.apiKey) {
|
|
488
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
489
|
-
}
|
|
490
|
-
OpenAPI_1.OpenAPI.BASE = ctx.apiUrl.replace(/\/api\/?$/, '');
|
|
491
|
-
OpenAPI_1.OpenAPI.TOKEN = ctx.apiKey;
|
|
465
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
492
466
|
const requestBody = {};
|
|
493
467
|
if (options.title)
|
|
494
468
|
requestBody.title = options.title;
|
|
@@ -496,7 +470,7 @@ function ticketCommand(program) {
|
|
|
496
470
|
requestBody.description = options.desc;
|
|
497
471
|
if (options.priority)
|
|
498
472
|
requestBody.priority = options.priority;
|
|
499
|
-
const response = await (0, generated_1.ticketsControllerUpdate)({ slug: ctx.projectSlug, ref
|
|
473
|
+
const response = await (0, generated_1.ticketsControllerUpdate)({ body: requestBody, path: { slug: ctx.projectSlug, ref } });
|
|
500
474
|
const ticketData = (0, api_1.unwrap)(response);
|
|
501
475
|
if (options.json) {
|
|
502
476
|
console.log(JSON.stringify(ticketData, null, 2));
|
|
@@ -504,7 +478,7 @@ function ticketCommand(program) {
|
|
|
504
478
|
else {
|
|
505
479
|
console.log(`✓ Ticket updated successfully`);
|
|
506
480
|
}
|
|
507
|
-
|
|
481
|
+
return (0, output_1.finishSuccess)();
|
|
508
482
|
}
|
|
509
483
|
catch (err) {
|
|
510
484
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -516,22 +490,13 @@ function ticketCommand(program) {
|
|
|
516
490
|
.option('--project <slug>', 'Project slug')
|
|
517
491
|
.option('--force', 'Confirm deletion')
|
|
518
492
|
.action(async (ref, options) => {
|
|
493
|
+
if (!(0, force_1.requireForce)(options.force))
|
|
494
|
+
return;
|
|
519
495
|
try {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
const ctx = await (0, config_1.resolveContext)({ projectSlug: options.project });
|
|
524
|
-
if (!ctx.projectSlug) {
|
|
525
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
526
|
-
}
|
|
527
|
-
if (!ctx.apiKey) {
|
|
528
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
529
|
-
}
|
|
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 });
|
|
496
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
497
|
+
await (0, generated_1.ticketsControllerSoftDelete)({ path: { slug: ctx.projectSlug, ref } });
|
|
533
498
|
console.log(`✓ Ticket deleted successfully`);
|
|
534
|
-
|
|
499
|
+
return (0, output_1.finishSuccess)();
|
|
535
500
|
}
|
|
536
501
|
catch (err) {
|
|
537
502
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket not found: ${ref}` });
|
|
@@ -545,19 +510,10 @@ function ticketCommand(program) {
|
|
|
545
510
|
.option('--json', 'Output as JSON')
|
|
546
511
|
.action(async (ref, options) => {
|
|
547
512
|
try {
|
|
548
|
-
const ctx = await (0,
|
|
549
|
-
if (!ctx.projectSlug) {
|
|
550
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
551
|
-
}
|
|
552
|
-
if (!ctx.apiKey) {
|
|
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;
|
|
513
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
557
514
|
const response = await (0, generated_1.ticketLinksControllerCreate)({
|
|
558
|
-
|
|
559
|
-
ref
|
|
560
|
-
requestBody: { url: options.url },
|
|
515
|
+
body: { url: options.url },
|
|
516
|
+
path: { slug: ctx.projectSlug, ref }
|
|
561
517
|
});
|
|
562
518
|
const linkData = (0, api_1.unwrap)(response);
|
|
563
519
|
if (options.json) {
|
|
@@ -567,7 +523,7 @@ function ticketCommand(program) {
|
|
|
567
523
|
console.log(`provider: ${linkData.provider}`);
|
|
568
524
|
console.log(`externalRef: ${linkData.externalRef}`);
|
|
569
525
|
}
|
|
570
|
-
|
|
526
|
+
return (0, output_1.finishSuccess)();
|
|
571
527
|
}
|
|
572
528
|
catch (err) {
|
|
573
529
|
(0, error_1.handleApiError)(err);
|
|
@@ -580,24 +536,16 @@ function ticketCommand(program) {
|
|
|
580
536
|
.requiredOption('--url <url>', 'External URL to unlink')
|
|
581
537
|
.action(async (ref, options) => {
|
|
582
538
|
try {
|
|
583
|
-
const ctx = await (0,
|
|
584
|
-
|
|
585
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
586
|
-
}
|
|
587
|
-
if (!ctx.apiKey) {
|
|
588
|
-
(0, error_1.handleApiError)(new Error('API key or URL not configured. Run: koda login --api-key <key>'), { configError: true });
|
|
589
|
-
}
|
|
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 });
|
|
539
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
540
|
+
const listResponse = await (0, generated_1.ticketLinksControllerFindAll)({ path: { slug: ctx.projectSlug, ref } });
|
|
593
541
|
const links = (0, api_1.unwrap)(listResponse);
|
|
594
542
|
const match = links.find((l) => l.url === options.url);
|
|
595
543
|
if (!match) {
|
|
596
544
|
console.log(`No link found for ${options.url}`);
|
|
597
545
|
process.exit(1);
|
|
598
546
|
}
|
|
599
|
-
await (0, generated_1.ticketLinksControllerRemove)({ slug: ctx.projectSlug, ref, linkId: match.id });
|
|
600
|
-
|
|
547
|
+
await (0, generated_1.ticketLinksControllerRemove)({ path: { slug: ctx.projectSlug, ref, linkId: match.id } });
|
|
548
|
+
return (0, output_1.finishSuccess)();
|
|
601
549
|
}
|
|
602
550
|
catch (err) {
|
|
603
551
|
(0, error_1.handleApiError)(err);
|
|
@@ -611,22 +559,13 @@ function ticketCommand(program) {
|
|
|
611
559
|
.requiredOption('--label <id>', 'Label ID')
|
|
612
560
|
.action(async (ref, options) => {
|
|
613
561
|
try {
|
|
614
|
-
const ctx = await (0,
|
|
615
|
-
if (!ctx.projectSlug) {
|
|
616
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
617
|
-
}
|
|
618
|
-
if (!ctx.apiKey) {
|
|
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;
|
|
562
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
623
563
|
await (0, generated_1.labelsControllerAssignLabelFromHttp)({
|
|
624
|
-
|
|
625
|
-
ref
|
|
626
|
-
requestBody: { labelId: options.label },
|
|
564
|
+
body: { labelId: options.label },
|
|
565
|
+
path: { slug: ctx.projectSlug, ref }
|
|
627
566
|
});
|
|
628
567
|
console.log(`✓ Label attached to ticket ${ref}`);
|
|
629
|
-
|
|
568
|
+
return (0, output_1.finishSuccess)();
|
|
630
569
|
}
|
|
631
570
|
catch (err) {
|
|
632
571
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket or label not found` });
|
|
@@ -640,26 +579,17 @@ function ticketCommand(program) {
|
|
|
640
579
|
.option('--json', 'Output as JSON')
|
|
641
580
|
.action(async (ref, options) => {
|
|
642
581
|
try {
|
|
643
|
-
const ctx = await (0,
|
|
644
|
-
if (!ctx.projectSlug) {
|
|
645
|
-
(0, error_1.handleApiError)(new Error('Project not configured. Run: koda init'), { configError: true });
|
|
646
|
-
}
|
|
647
|
-
if (!ctx.apiKey) {
|
|
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;
|
|
582
|
+
const ctx = await (0, context_1.withContext)({ projectSlug: options.project });
|
|
652
583
|
await (0, generated_1.labelsControllerRemoveLabelFromHttp)({
|
|
653
|
-
slug: ctx.projectSlug,
|
|
654
|
-
ref,
|
|
655
|
-
labelId: options.label,
|
|
584
|
+
path: { slug: ctx.projectSlug, ref, labelId: options.label }
|
|
656
585
|
});
|
|
657
586
|
console.log(`✓ Label detached from ticket ${ref}`);
|
|
658
|
-
|
|
587
|
+
return (0, output_1.finishSuccess)();
|
|
659
588
|
}
|
|
660
589
|
catch (err) {
|
|
661
590
|
(0, error_1.handleApiError)(err, { notFoundMessage: `Ticket or label not found` });
|
|
662
591
|
}
|
|
663
592
|
});
|
|
593
|
+
(0, ticket_watch_1.registerTicketWatch)(ticket);
|
|
664
594
|
}
|
|
665
595
|
//# sourceMappingURL=ticket.js.map
|