@outputai/cli 0.8.1 → 0.8.2-next.c12766f.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/assets/docker/docker-compose-dev.yml +1 -1
- package/dist/commands/workflow/cost.d.ts +3 -2
- package/dist/commands/workflow/cost.js +4 -11
- package/dist/commands/workflow/cost.spec.js +1 -3
- package/dist/commands/workflow/dataset/list.d.ts +3 -1
- package/dist/commands/workflow/dataset/list.js +10 -14
- package/dist/commands/workflow/debug.d.ts +2 -6
- package/dist/commands/workflow/debug.js +10 -29
- package/dist/commands/workflow/debug.spec.js +2 -5
- package/dist/commands/workflow/list.d.ts +4 -1
- package/dist/commands/workflow/list.js +15 -19
- package/dist/commands/workflow/list.spec.js +2 -1
- package/dist/commands/workflow/result.d.ts +3 -4
- package/dist/commands/workflow/result.js +6 -15
- package/dist/commands/workflow/result.spec.js +2 -4
- package/dist/commands/workflow/run.d.ts +3 -2
- package/dist/commands/workflow/run.js +4 -11
- package/dist/commands/workflow/run.spec.js +1 -3
- package/dist/commands/workflow/runs/list.d.ts +3 -1
- package/dist/commands/workflow/runs/list.js +11 -15
- package/dist/commands/workflow/status.d.ts +3 -4
- package/dist/commands/workflow/status.js +20 -30
- package/dist/commands/workflow/status.spec.js +2 -4
- package/dist/commands/workflow/test_eval.d.ts +3 -2
- package/dist/commands/workflow/test_eval.js +5 -15
- package/dist/commands/workflow/test_eval.spec.d.ts +1 -0
- package/dist/commands/workflow/test_eval.spec.js +84 -0
- package/dist/generated/framework_version.json +1 -1
- package/dist/hooks/init.d.ts +1 -0
- package/dist/hooks/init.js +40 -30
- package/dist/hooks/init.spec.js +28 -4
- package/dist/utils/format_workflow_result.spec.js +0 -13
- package/dist/utils/trace_formatter.js +1 -2
- package/oclif.manifest.json +82 -101
- package/package.json +4 -4
- package/dist/utils/constants.d.ts +0 -5
- package/dist/utils/constants.js +0 -4
- package/dist/utils/output_formatter.d.ts +0 -2
- package/dist/utils/output_formatter.js +0 -11
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { CostReport } from '#types/cost.js';
|
|
2
3
|
export default class WorkflowCost extends Command {
|
|
3
4
|
static description: string;
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
static args: {
|
|
6
8
|
workflowId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
9
|
tracePath: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
10
|
};
|
|
9
11
|
static flags: {
|
|
10
|
-
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
13
|
};
|
|
13
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<CostReport>;
|
|
14
15
|
private loadLocalTrace;
|
|
15
16
|
catch(error: Error): Promise<void>;
|
|
16
17
|
}
|
|
@@ -2,18 +2,17 @@ import { Args, Command, Flags } from '@oclif/core';
|
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { calculateCost, loadPricingConfig } from '#services/cost_calculator.js';
|
|
4
4
|
import { getTrace } from '#services/trace_reader.js';
|
|
5
|
-
import { OUTPUT_FORMAT } from '#utils/constants.js';
|
|
6
5
|
import { formatCostReport } from '#utils/cost_formatter.js';
|
|
7
6
|
import { getErrorCode } from '#utils/error_utils.js';
|
|
8
7
|
import { handleApiError } from '#utils/error_handler.js';
|
|
9
|
-
import { formatOutput } from '#utils/output_formatter.js';
|
|
10
8
|
export default class WorkflowCost extends Command {
|
|
11
9
|
static description = 'Calculate the cost of a workflow execution';
|
|
10
|
+
static enableJsonFlag = true;
|
|
12
11
|
static examples = [
|
|
13
12
|
'<%= config.bin %> <%= command.id %> my_workflow_id',
|
|
14
13
|
'<%= config.bin %> <%= command.id %> my_workflow_id --verbose',
|
|
15
14
|
'<%= config.bin %> <%= command.id %> my_workflow_id path/to/trace.json',
|
|
16
|
-
'<%= config.bin %> <%= command.id %> my_workflow_id --
|
|
15
|
+
'<%= config.bin %> <%= command.id %> my_workflow_id --json'
|
|
17
16
|
];
|
|
18
17
|
static args = {
|
|
19
18
|
workflowId: Args.string({
|
|
@@ -26,12 +25,6 @@ export default class WorkflowCost extends Command {
|
|
|
26
25
|
})
|
|
27
26
|
};
|
|
28
27
|
static flags = {
|
|
29
|
-
format: Flags.string({
|
|
30
|
-
char: 'f',
|
|
31
|
-
description: 'Output format',
|
|
32
|
-
options: [OUTPUT_FORMAT.JSON, OUTPUT_FORMAT.TEXT],
|
|
33
|
-
default: OUTPUT_FORMAT.TEXT
|
|
34
|
-
}),
|
|
35
28
|
verbose: Flags.boolean({
|
|
36
29
|
description: 'Show detailed per-call breakdown',
|
|
37
30
|
default: false
|
|
@@ -45,8 +38,8 @@ export default class WorkflowCost extends Command {
|
|
|
45
38
|
const config = loadPricingConfig();
|
|
46
39
|
const traceNode = traceData;
|
|
47
40
|
const report = calculateCost(traceNode, config, traceFile);
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
this.log(formatCostReport(report, { verbose: flags.verbose }));
|
|
42
|
+
return report;
|
|
50
43
|
}
|
|
51
44
|
async loadLocalTrace(tracePath) {
|
|
52
45
|
try {
|
|
@@ -20,7 +20,6 @@ describe('workflow cost command', () => {
|
|
|
20
20
|
expect(WorkflowCost).toBeDefined();
|
|
21
21
|
expect(WorkflowCost.description).toBeDefined();
|
|
22
22
|
expect(WorkflowCost.args).toHaveProperty('workflowId');
|
|
23
|
-
expect(WorkflowCost.flags).toHaveProperty('format');
|
|
24
23
|
expect(WorkflowCost.flags).toHaveProperty('verbose');
|
|
25
24
|
});
|
|
26
25
|
it('should have workflowId as required arg', async () => {
|
|
@@ -34,8 +33,7 @@ describe('workflow cost command', () => {
|
|
|
34
33
|
});
|
|
35
34
|
it('should have correct flag configuration', async () => {
|
|
36
35
|
const WorkflowCost = (await import('./cost.js')).default;
|
|
37
|
-
expect(WorkflowCost.
|
|
38
|
-
expect(WorkflowCost.flags.format.default).toBe('text');
|
|
36
|
+
expect(WorkflowCost.enableJsonFlag).toBe(true);
|
|
39
37
|
expect(WorkflowCost.flags.verbose.default).toBe(false);
|
|
40
38
|
});
|
|
41
39
|
it('should have correct examples', async () => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import type { DatasetInfo } from '#services/datasets.js';
|
|
2
3
|
export default class DatasetList extends Command {
|
|
3
4
|
static description: string;
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
static args: {
|
|
6
8
|
workflowName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -8,5 +10,5 @@ export default class DatasetList extends Command {
|
|
|
8
10
|
static flags: {
|
|
9
11
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
};
|
|
11
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<DatasetInfo[]>;
|
|
12
14
|
}
|
|
@@ -3,7 +3,6 @@ import Table from 'cli-table3';
|
|
|
3
3
|
import { listDatasets } from '#services/datasets.js';
|
|
4
4
|
const OutputFormat = {
|
|
5
5
|
TABLE: 'table',
|
|
6
|
-
JSON: 'json',
|
|
7
6
|
TEXT: 'text'
|
|
8
7
|
};
|
|
9
8
|
function createDatasetsTable(datasets) {
|
|
@@ -37,13 +36,7 @@ function formatDatasetsAsText(datasets) {
|
|
|
37
36
|
return `${dataset.name} ${cached}${outputDate}${evalDate}`;
|
|
38
37
|
}).join('\n');
|
|
39
38
|
}
|
|
40
|
-
function formatDatasetsAsJson(datasets) {
|
|
41
|
-
return JSON.stringify(datasets, null, 2);
|
|
42
|
-
}
|
|
43
39
|
function formatDatasets(datasets, format) {
|
|
44
|
-
if (format === OutputFormat.JSON) {
|
|
45
|
-
return formatDatasetsAsJson(datasets);
|
|
46
|
-
}
|
|
47
40
|
if (format === OutputFormat.TABLE) {
|
|
48
41
|
return createDatasetsTable(datasets);
|
|
49
42
|
}
|
|
@@ -51,9 +44,10 @@ function formatDatasets(datasets, format) {
|
|
|
51
44
|
}
|
|
52
45
|
export default class DatasetList extends Command {
|
|
53
46
|
static description = 'List datasets for a workflow';
|
|
47
|
+
static enableJsonFlag = true;
|
|
54
48
|
static examples = [
|
|
55
49
|
'<%= config.bin %> <%= command.id %> simple',
|
|
56
|
-
'<%= config.bin %> <%= command.id %> simple --
|
|
50
|
+
'<%= config.bin %> <%= command.id %> simple --json',
|
|
57
51
|
'<%= config.bin %> <%= command.id %> simple --format table'
|
|
58
52
|
];
|
|
59
53
|
static args = {
|
|
@@ -65,23 +59,25 @@ export default class DatasetList extends Command {
|
|
|
65
59
|
static flags = {
|
|
66
60
|
format: Flags.string({
|
|
67
61
|
char: 'f',
|
|
68
|
-
description: 'Output format',
|
|
69
|
-
options: [OutputFormat.TABLE, OutputFormat.
|
|
62
|
+
description: 'Output format (use --json for JSON output)',
|
|
63
|
+
options: [OutputFormat.TABLE, OutputFormat.TEXT],
|
|
70
64
|
default: OutputFormat.TABLE
|
|
71
65
|
})
|
|
72
66
|
};
|
|
73
67
|
async run() {
|
|
74
68
|
const { args, flags } = await this.parse(DatasetList);
|
|
75
69
|
const datasets = await listDatasets(args.workflowName);
|
|
70
|
+
if (this.jsonEnabled()) {
|
|
71
|
+
return datasets;
|
|
72
|
+
}
|
|
76
73
|
if (datasets.length === 0) {
|
|
77
74
|
this.log(`No datasets found for workflow "${args.workflowName}".`);
|
|
78
75
|
this.log('Generate datasets with: output workflow dataset generate');
|
|
79
|
-
return;
|
|
76
|
+
return datasets;
|
|
80
77
|
}
|
|
81
78
|
const output = formatDatasets(datasets, flags.format);
|
|
82
79
|
this.log(output);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
80
|
+
this.log(`\nFound ${datasets.length} dataset(s) for "${args.workflowName}"`);
|
|
81
|
+
return datasets;
|
|
86
82
|
}
|
|
87
83
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export default class WorkflowDebug extends Command {
|
|
3
3
|
static description: string;
|
|
4
|
+
static enableJsonFlag: boolean;
|
|
4
5
|
static examples: string[];
|
|
5
6
|
static args: {
|
|
6
7
|
workflowId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
private conditionalLog;
|
|
13
|
-
private outputJson;
|
|
9
|
+
run(): Promise<unknown>;
|
|
14
10
|
private displayTextTrace;
|
|
15
11
|
catch(error: Error): Promise<void>;
|
|
16
12
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Args, Command
|
|
2
|
-
import { OUTPUT_FORMAT } from '#utils/constants.js';
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
3
2
|
import { displayDebugTree } from '#utils/trace_formatter.js';
|
|
4
3
|
import { getTrace } from '#services/trace_reader.js';
|
|
5
4
|
import { handleApiError } from '#utils/error_handler.js';
|
|
6
5
|
export default class WorkflowDebug extends Command {
|
|
7
6
|
static description = 'Get and display workflow execution trace for debugging';
|
|
7
|
+
static enableJsonFlag = true;
|
|
8
8
|
static examples = [
|
|
9
9
|
'<%= config.bin %> <%= command.id %> wf-12345',
|
|
10
|
-
'<%= config.bin %> <%= command.id %> wf-12345 --
|
|
11
|
-
'<%= config.bin %> <%= command.id %> wf-12345 --format text'
|
|
10
|
+
'<%= config.bin %> <%= command.id %> wf-12345 --json'
|
|
12
11
|
];
|
|
13
12
|
static args = {
|
|
14
13
|
workflowId: Args.string({
|
|
@@ -16,41 +15,23 @@ export default class WorkflowDebug extends Command {
|
|
|
16
15
|
required: true
|
|
17
16
|
})
|
|
18
17
|
};
|
|
19
|
-
static flags = {
|
|
20
|
-
format: Flags.string({
|
|
21
|
-
char: 'f',
|
|
22
|
-
description: 'Output format',
|
|
23
|
-
options: [OUTPUT_FORMAT.JSON, OUTPUT_FORMAT.TEXT],
|
|
24
|
-
default: OUTPUT_FORMAT.TEXT
|
|
25
|
-
})
|
|
26
|
-
};
|
|
27
18
|
async run() {
|
|
28
|
-
const { args
|
|
29
|
-
|
|
30
|
-
this.conditionalLog(`Fetching debug information for workflow: ${args.workflowId}...`, isJsonFormat);
|
|
19
|
+
const { args } = await this.parse(WorkflowDebug);
|
|
20
|
+
this.log(`Fetching debug information for workflow: ${args.workflowId}...`);
|
|
31
21
|
const { data: traceData, location } = await getTrace(args.workflowId);
|
|
32
22
|
const source = location.isRemote ? 'remote' : 'local';
|
|
33
|
-
this.
|
|
34
|
-
if (
|
|
35
|
-
this.
|
|
36
|
-
return;
|
|
23
|
+
this.log(`Trace source: ${source}${!location.isRemote ? ` (${location.path})` : ''}`);
|
|
24
|
+
if (!this.jsonEnabled()) {
|
|
25
|
+
this.displayTextTrace(traceData);
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
conditionalLog(message, disabled) {
|
|
41
|
-
if (!disabled) {
|
|
42
|
-
this.log(message);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
outputJson(data) {
|
|
46
|
-
this.log(JSON.stringify(data, null, 2));
|
|
27
|
+
return traceData;
|
|
47
28
|
}
|
|
48
29
|
displayTextTrace(traceData) {
|
|
49
30
|
this.log('\nTrace Log:');
|
|
50
31
|
this.log('─'.repeat(80));
|
|
51
32
|
this.log(displayDebugTree(traceData));
|
|
52
33
|
this.log('\n' + '─'.repeat(80));
|
|
53
|
-
this.log('Tip: Use --
|
|
34
|
+
this.log('Tip: Use --json for the full untruncated trace');
|
|
54
35
|
}
|
|
55
36
|
async catch(error) {
|
|
56
37
|
return handleApiError(error, (...args) => this.error(...args), {
|
|
@@ -17,13 +17,10 @@ describe('workflow debug command', () => {
|
|
|
17
17
|
expect(WorkflowDebug).toBeDefined();
|
|
18
18
|
expect(WorkflowDebug.description).toContain('Get and display workflow execution trace for debugging');
|
|
19
19
|
expect(WorkflowDebug.args).toHaveProperty('workflowId');
|
|
20
|
-
expect(WorkflowDebug.flags).toHaveProperty('format');
|
|
21
20
|
});
|
|
22
|
-
it('
|
|
21
|
+
it('enables the built-in --json flag', async () => {
|
|
23
22
|
const WorkflowDebug = (await import('./debug.js')).default;
|
|
24
|
-
|
|
25
|
-
expect(WorkflowDebug.flags.format.options).toEqual(['json', 'text']);
|
|
26
|
-
expect(WorkflowDebug.flags.format.default).toBe('text');
|
|
23
|
+
expect(WorkflowDebug.enableJsonFlag).toBe(true);
|
|
27
24
|
});
|
|
28
25
|
it('should have correct examples', async () => {
|
|
29
26
|
const WorkflowDebug = (await import('./debug.js')).default;
|
|
@@ -12,6 +12,7 @@ export declare function parseWorkflowForDisplay(workflow: Workflow): WorkflowDis
|
|
|
12
12
|
export declare function formatWorkflowsAsList(workflows: Workflow[]): string;
|
|
13
13
|
export default class WorkflowList extends Command {
|
|
14
14
|
static description: string;
|
|
15
|
+
static enableJsonFlag: boolean;
|
|
15
16
|
static examples: string[];
|
|
16
17
|
static flags: {
|
|
17
18
|
catalog: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -19,7 +20,9 @@ export default class WorkflowList extends Command {
|
|
|
19
20
|
detailed: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
21
|
filter: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
22
|
};
|
|
22
|
-
run(): Promise<
|
|
23
|
+
run(): Promise<{
|
|
24
|
+
workflows: unknown[];
|
|
25
|
+
}>;
|
|
23
26
|
catch(error: Error): Promise<void>;
|
|
24
27
|
}
|
|
25
28
|
export {};
|
|
@@ -6,8 +6,7 @@ import { handleApiError } from '#utils/error_handler.js';
|
|
|
6
6
|
import { listScenariosForWorkflow } from '#utils/scenario_resolver.js';
|
|
7
7
|
const OUTPUT_FORMAT = {
|
|
8
8
|
LIST: 'list',
|
|
9
|
-
TABLE: 'table'
|
|
10
|
-
JSON: 'json'
|
|
9
|
+
TABLE: 'table'
|
|
11
10
|
};
|
|
12
11
|
export function parseWorkflowForDisplay(workflow) {
|
|
13
12
|
const parsed = parseWorkflowDefinition(workflow);
|
|
@@ -74,7 +73,7 @@ export function formatWorkflowsAsList(workflows) {
|
|
|
74
73
|
return `\nWorkflows:\n\n${lines.join('\n')}`;
|
|
75
74
|
}
|
|
76
75
|
function formatWorkflowsAsJson(workflows) {
|
|
77
|
-
|
|
76
|
+
return {
|
|
78
77
|
workflows: workflows.map(w => {
|
|
79
78
|
const display = parseWorkflowForDisplay(w);
|
|
80
79
|
return {
|
|
@@ -88,12 +87,8 @@ function formatWorkflowsAsJson(workflows) {
|
|
|
88
87
|
};
|
|
89
88
|
})
|
|
90
89
|
};
|
|
91
|
-
return JSON.stringify(output, null, 2);
|
|
92
90
|
}
|
|
93
91
|
function formatWorkflows(workflows, format, detailed) {
|
|
94
|
-
if (format === OUTPUT_FORMAT.JSON) {
|
|
95
|
-
return formatWorkflowsAsJson(workflows);
|
|
96
|
-
}
|
|
97
92
|
if (format === OUTPUT_FORMAT.TABLE) {
|
|
98
93
|
return createWorkflowTable(workflows, detailed);
|
|
99
94
|
}
|
|
@@ -101,10 +96,11 @@ function formatWorkflows(workflows, format, detailed) {
|
|
|
101
96
|
}
|
|
102
97
|
export default class WorkflowList extends Command {
|
|
103
98
|
static description = 'List available workflows from the catalog';
|
|
99
|
+
static enableJsonFlag = true;
|
|
104
100
|
static examples = [
|
|
105
101
|
'<%= config.bin %> <%= command.id %>',
|
|
106
102
|
'<%= config.bin %> <%= command.id %> --format table',
|
|
107
|
-
'<%= config.bin %> <%= command.id %> --
|
|
103
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
108
104
|
'<%= config.bin %> <%= command.id %> --detailed',
|
|
109
105
|
'<%= config.bin %> <%= command.id %> --filter simple',
|
|
110
106
|
'<%= config.bin %> <%= command.id %> --catalog my-catalog'
|
|
@@ -120,8 +116,8 @@ export default class WorkflowList extends Command {
|
|
|
120
116
|
}),
|
|
121
117
|
format: Flags.string({
|
|
122
118
|
char: 'f',
|
|
123
|
-
description: 'Output format',
|
|
124
|
-
options: [OUTPUT_FORMAT.LIST, OUTPUT_FORMAT.TABLE
|
|
119
|
+
description: 'Output format (use --json for JSON output)',
|
|
120
|
+
options: [OUTPUT_FORMAT.LIST, OUTPUT_FORMAT.TABLE],
|
|
125
121
|
default: OUTPUT_FORMAT.LIST
|
|
126
122
|
}),
|
|
127
123
|
detailed: Flags.boolean({
|
|
@@ -137,20 +133,20 @@ export default class WorkflowList extends Command {
|
|
|
137
133
|
const { flags } = await this.parse(WorkflowList);
|
|
138
134
|
this.log(flags.catalog ? `Fetching workflow catalog: ${flags.catalog}...` : 'Fetching workflow catalog...');
|
|
139
135
|
const catalogWorkflows = await fetchWorkflowCatalog(flags.catalog);
|
|
140
|
-
if (catalogWorkflows.length === 0) {
|
|
141
|
-
this.log('No workflows found in catalog.');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
136
|
const workflows = flags.filter ?
|
|
145
137
|
catalogWorkflows.filter(matchName(flags.filter)) :
|
|
146
138
|
catalogWorkflows;
|
|
147
|
-
if (
|
|
139
|
+
if (catalogWorkflows.length === 0) {
|
|
140
|
+
this.log('No workflows found in catalog.');
|
|
141
|
+
}
|
|
142
|
+
else if (workflows.length === 0 && flags.filter) {
|
|
148
143
|
this.log(`No workflows matching filter: ${flags.filter}`);
|
|
149
|
-
return;
|
|
150
144
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
else {
|
|
146
|
+
this.log(formatWorkflows(workflows, flags.format, flags.detailed));
|
|
147
|
+
this.log(`\nFound ${workflows.length} workflow(s)`);
|
|
148
|
+
}
|
|
149
|
+
return formatWorkflowsAsJson(workflows);
|
|
154
150
|
}
|
|
155
151
|
async catch(error) {
|
|
156
152
|
return handleApiError(error, (...args) => this.error(...args), {
|
|
@@ -28,7 +28,8 @@ describe('workflow list command', () => {
|
|
|
28
28
|
});
|
|
29
29
|
it('should have correct flag configuration', async () => {
|
|
30
30
|
const WorkflowList = (await import('./list.js')).default;
|
|
31
|
-
expect(WorkflowList.
|
|
31
|
+
expect(WorkflowList.enableJsonFlag).toBe(true);
|
|
32
|
+
expect(WorkflowList.flags.format.options).toEqual(['list', 'table']);
|
|
32
33
|
expect(WorkflowList.flags.format.default).toBe('list');
|
|
33
34
|
expect(WorkflowList.flags.detailed.default).toBe(false);
|
|
34
35
|
});
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import { type WorkflowResultResponse } from '#api/generated/api.js';
|
|
2
3
|
export default class WorkflowResult extends Command {
|
|
3
4
|
static description: string;
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
static args: {
|
|
6
8
|
workflowId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
10
|
+
run(): Promise<WorkflowResultResponse>;
|
|
12
11
|
catch(error: Error): Promise<void>;
|
|
13
12
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Args, Command
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { getWorkflowIdResult } from '#api/generated/api.js';
|
|
3
|
-
import { OUTPUT_FORMAT } from '#utils/constants.js';
|
|
4
|
-
import { formatOutput } from '#utils/output_formatter.js';
|
|
5
3
|
import { formatWorkflowResult, ERROR_STATUSES } from '#utils/format_workflow_result.js';
|
|
6
4
|
import { handleApiError } from '#utils/error_handler.js';
|
|
7
5
|
export default class WorkflowResult extends Command {
|
|
8
6
|
static description = 'Get workflow execution result';
|
|
7
|
+
static enableJsonFlag = true;
|
|
9
8
|
static examples = [
|
|
10
9
|
'<%= config.bin %> <%= command.id %> wf-12345',
|
|
11
|
-
'<%= config.bin %> <%= command.id %> wf-12345 --
|
|
10
|
+
'<%= config.bin %> <%= command.id %> wf-12345 --json'
|
|
12
11
|
];
|
|
13
12
|
static args = {
|
|
14
13
|
workflowId: Args.string({
|
|
@@ -16,27 +15,19 @@ export default class WorkflowResult extends Command {
|
|
|
16
15
|
required: true
|
|
17
16
|
})
|
|
18
17
|
};
|
|
19
|
-
static flags = {
|
|
20
|
-
format: Flags.string({
|
|
21
|
-
char: 'f',
|
|
22
|
-
description: 'Output format',
|
|
23
|
-
options: [OUTPUT_FORMAT.JSON, OUTPUT_FORMAT.TEXT],
|
|
24
|
-
default: OUTPUT_FORMAT.TEXT
|
|
25
|
-
})
|
|
26
|
-
};
|
|
27
18
|
async run() {
|
|
28
|
-
const { args
|
|
19
|
+
const { args } = await this.parse(WorkflowResult);
|
|
29
20
|
this.log(`Fetching result for workflow: ${args.workflowId}...`);
|
|
30
21
|
const response = await getWorkflowIdResult(args.workflowId);
|
|
31
22
|
if (!response || !response.data) {
|
|
32
23
|
this.error('API returned invalid response', { exit: 1 });
|
|
33
24
|
}
|
|
34
25
|
const data = response.data;
|
|
35
|
-
|
|
36
|
-
this.log(`\n${output}`);
|
|
26
|
+
this.log(`\n${formatWorkflowResult(data)}`);
|
|
37
27
|
if (ERROR_STATUSES.has(data.status)) {
|
|
38
28
|
process.exitCode = 1;
|
|
39
29
|
}
|
|
30
|
+
return data;
|
|
40
31
|
}
|
|
41
32
|
async catch(error) {
|
|
42
33
|
return handleApiError(error, (...args) => this.error(...args), {
|
|
@@ -12,12 +12,10 @@ describe('workflow result command', () => {
|
|
|
12
12
|
expect(WorkflowResult).toBeDefined();
|
|
13
13
|
expect(WorkflowResult.description).toContain('Get workflow execution result');
|
|
14
14
|
expect(WorkflowResult.args).toHaveProperty('workflowId');
|
|
15
|
-
expect(WorkflowResult.flags).toHaveProperty('format');
|
|
16
15
|
});
|
|
17
|
-
it('
|
|
16
|
+
it('enables the built-in --json flag', async () => {
|
|
18
17
|
const WorkflowResult = (await import('./result.js')).default;
|
|
19
|
-
expect(WorkflowResult.
|
|
20
|
-
expect(WorkflowResult.flags.format.default).toBe('text');
|
|
18
|
+
expect(WorkflowResult.enableJsonFlag).toBe(true);
|
|
21
19
|
});
|
|
22
20
|
});
|
|
23
21
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import { type WorkflowResultResponse } from '#api/generated/api.js';
|
|
2
3
|
export default class WorkflowRun extends Command {
|
|
3
4
|
static description: string;
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
static args: {
|
|
6
8
|
workflowName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -9,8 +11,7 @@ export default class WorkflowRun extends Command {
|
|
|
9
11
|
static flags: {
|
|
10
12
|
input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
catalog: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
};
|
|
14
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<WorkflowResultResponse>;
|
|
15
16
|
catch(error: Error): Promise<void>;
|
|
16
17
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { postWorkflowRun } from '#api/generated/api.js';
|
|
3
|
-
import { OUTPUT_FORMAT } from '#utils/constants.js';
|
|
4
|
-
import { formatOutput } from '#utils/output_formatter.js';
|
|
5
3
|
import { formatWorkflowResult, ERROR_STATUSES } from '#utils/format_workflow_result.js';
|
|
6
4
|
import { handleApiError } from '#utils/error_handler.js';
|
|
7
5
|
import { resolveInput } from '#utils/resolve_input.js';
|
|
@@ -30,9 +28,10 @@ async function executeWorkflow(args) {
|
|
|
30
28
|
}
|
|
31
29
|
export default class WorkflowRun extends Command {
|
|
32
30
|
static description = 'Execute a workflow synchronously and wait for completion';
|
|
31
|
+
static enableJsonFlag = true;
|
|
33
32
|
static examples = [
|
|
34
33
|
'<%= config.bin %> <%= command.id %> simple basic_input',
|
|
35
|
-
'<%= config.bin %> <%= command.id %> simple my_scenario --
|
|
34
|
+
'<%= config.bin %> <%= command.id %> simple my_scenario --json',
|
|
36
35
|
'<%= config.bin %> <%= command.id %> simple --input \'{"values":[1,2,3]}\'',
|
|
37
36
|
'<%= config.bin %> <%= command.id %> simple --input input.json',
|
|
38
37
|
'<%= config.bin %> <%= command.id %> simple --input \'{"key":"value"}\' --catalog my-catalog'
|
|
@@ -60,12 +59,6 @@ export default class WorkflowRun extends Command {
|
|
|
60
59
|
deprecateAliases: true,
|
|
61
60
|
description: 'Catalog name for workflow execution (defaults to OUTPUT_CATALOG_ID)',
|
|
62
61
|
env: 'OUTPUT_CATALOG_ID'
|
|
63
|
-
}),
|
|
64
|
-
format: Flags.string({
|
|
65
|
-
char: 'f',
|
|
66
|
-
description: 'Output format',
|
|
67
|
-
options: [OUTPUT_FORMAT.JSON, OUTPUT_FORMAT.TEXT],
|
|
68
|
-
default: OUTPUT_FORMAT.TEXT
|
|
69
62
|
})
|
|
70
63
|
};
|
|
71
64
|
async run() {
|
|
@@ -85,11 +78,11 @@ export default class WorkflowRun extends Command {
|
|
|
85
78
|
this.error('API returned invalid response', { exit: 1 });
|
|
86
79
|
}
|
|
87
80
|
const data = response.data;
|
|
88
|
-
|
|
89
|
-
this.log(`\n${output}`);
|
|
81
|
+
this.log(`\n${formatWorkflowResult(data)}`);
|
|
90
82
|
if (ERROR_STATUSES.has(data.status)) {
|
|
91
83
|
process.exitCode = 1;
|
|
92
84
|
}
|
|
85
|
+
return data;
|
|
93
86
|
}
|
|
94
87
|
async catch(error) {
|
|
95
88
|
return handleApiError(error, (...args) => this.error(...args), {
|
|
@@ -26,13 +26,11 @@ describe('workflow run command', () => {
|
|
|
26
26
|
expect(WorkflowRun.description).toContain('Execute a workflow');
|
|
27
27
|
expect(WorkflowRun.args).toHaveProperty('workflowName');
|
|
28
28
|
expect(WorkflowRun.flags).toHaveProperty('input');
|
|
29
|
-
expect(WorkflowRun.flags).toHaveProperty('format');
|
|
30
29
|
expect(WorkflowRun.flags).toHaveProperty('catalog');
|
|
31
30
|
});
|
|
32
31
|
it('should have correct flag configuration', async () => {
|
|
33
32
|
const WorkflowRun = (await import('./run.js')).default;
|
|
34
|
-
expect(WorkflowRun.
|
|
35
|
-
expect(WorkflowRun.flags.format.default).toBe('text');
|
|
33
|
+
expect(WorkflowRun.enableJsonFlag).toBe(true);
|
|
36
34
|
expect(WorkflowRun.flags.input.required).toBe(false);
|
|
37
35
|
});
|
|
38
36
|
it('should have optional scenario argument', async () => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
import { type WorkflowRun } from '#services/workflow_runs.js';
|
|
2
3
|
export default class WorkflowRunsList extends Command {
|
|
3
4
|
static description: string;
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
static args: {
|
|
6
8
|
workflowName: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
@@ -10,6 +12,6 @@ export default class WorkflowRunsList extends Command {
|
|
|
10
12
|
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
};
|
|
13
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<WorkflowRun[]>;
|
|
14
16
|
catch(error: Error): Promise<void>;
|
|
15
17
|
}
|
|
@@ -5,7 +5,6 @@ import { formatDate, formatDurationFromTimestamps } from '#utils/date_formatter.
|
|
|
5
5
|
import { handleApiError } from '#utils/error_handler.js';
|
|
6
6
|
const OUTPUT_FORMAT = {
|
|
7
7
|
TABLE: 'table',
|
|
8
|
-
JSON: 'json',
|
|
9
8
|
TEXT: 'text'
|
|
10
9
|
};
|
|
11
10
|
function createRunsTable(runs) {
|
|
@@ -37,13 +36,7 @@ function formatRunsAsText(runs) {
|
|
|
37
36
|
return `${run.workflowId} (${run.workflowType}) - ${run.status} [${duration}]`;
|
|
38
37
|
}).join('\n');
|
|
39
38
|
}
|
|
40
|
-
function formatRunsAsJson(runs) {
|
|
41
|
-
return JSON.stringify(runs, null, 2);
|
|
42
|
-
}
|
|
43
39
|
function formatRuns(runs, format) {
|
|
44
|
-
if (format === OUTPUT_FORMAT.JSON) {
|
|
45
|
-
return formatRunsAsJson(runs);
|
|
46
|
-
}
|
|
47
40
|
if (format === OUTPUT_FORMAT.TABLE) {
|
|
48
41
|
return createRunsTable(runs);
|
|
49
42
|
}
|
|
@@ -51,12 +44,13 @@ function formatRuns(runs, format) {
|
|
|
51
44
|
}
|
|
52
45
|
export default class WorkflowRunsList extends Command {
|
|
53
46
|
static description = 'List workflow runs with optional filtering by workflow type';
|
|
47
|
+
static enableJsonFlag = true;
|
|
54
48
|
static examples = [
|
|
55
49
|
'<%= config.bin %> <%= command.id %>',
|
|
56
50
|
'<%= config.bin %> <%= command.id %> simple',
|
|
57
51
|
'<%= config.bin %> <%= command.id %> simple --limit 10',
|
|
58
52
|
'<%= config.bin %> <%= command.id %> --catalog my-catalog',
|
|
59
|
-
'<%= config.bin %> <%= command.id %> --
|
|
53
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
60
54
|
'<%= config.bin %> <%= command.id %> --format table'
|
|
61
55
|
];
|
|
62
56
|
static args = {
|
|
@@ -78,8 +72,8 @@ export default class WorkflowRunsList extends Command {
|
|
|
78
72
|
}),
|
|
79
73
|
format: Flags.string({
|
|
80
74
|
char: 'f',
|
|
81
|
-
description: 'Output format',
|
|
82
|
-
options: [OUTPUT_FORMAT.TABLE, OUTPUT_FORMAT.
|
|
75
|
+
description: 'Output format (use --json for JSON output)',
|
|
76
|
+
options: [OUTPUT_FORMAT.TABLE, OUTPUT_FORMAT.TEXT],
|
|
83
77
|
default: OUTPUT_FORMAT.TABLE
|
|
84
78
|
})
|
|
85
79
|
};
|
|
@@ -90,17 +84,19 @@ export default class WorkflowRunsList extends Command {
|
|
|
90
84
|
catalog: flags.catalog,
|
|
91
85
|
limit: flags.limit
|
|
92
86
|
});
|
|
87
|
+
if (this.jsonEnabled()) {
|
|
88
|
+
return runs;
|
|
89
|
+
}
|
|
93
90
|
if (runs.length === 0) {
|
|
94
91
|
const filterMsg = args.workflowName ? ` for workflow type "${args.workflowName}"` : '';
|
|
95
92
|
this.log(`No workflow runs found${filterMsg}.`);
|
|
96
|
-
return;
|
|
93
|
+
return runs;
|
|
97
94
|
}
|
|
98
95
|
const output = formatRuns(runs, flags.format);
|
|
99
96
|
this.log(output);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
97
|
+
const filterMsg = args.workflowName ? ` of type "${args.workflowName}"` : '';
|
|
98
|
+
this.log(`\nFound ${count} run(s)${filterMsg}`);
|
|
99
|
+
return runs;
|
|
104
100
|
}
|
|
105
101
|
async catch(error) {
|
|
106
102
|
return handleApiError(error, (...args) => this.error(...args), {
|