@clickraft/cli 0.7.0 → 0.7.2
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/CHANGELOG.md +3 -5
- package/dist/cli.js +34 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2902,16 +2902,17 @@ async function listTokens(options) {
|
|
|
2902
2902
|
// src/schemas/workflows.ts
|
|
2903
2903
|
import { z as z12 } from "zod";
|
|
2904
2904
|
var WorkflowDeclaredParamSchema = z12.object({
|
|
2905
|
+
name: z12.string(),
|
|
2905
2906
|
type: z12.string(),
|
|
2906
2907
|
required: z12.boolean().optional(),
|
|
2907
|
-
|
|
2908
|
-
description: z12.
|
|
2909
|
-
}).
|
|
2908
|
+
defaultValue: z12.unknown().optional(),
|
|
2909
|
+
description: z12.unknown().optional()
|
|
2910
|
+
}).passthrough();
|
|
2910
2911
|
var WorkflowSummarySchema = z12.object({
|
|
2911
2912
|
id: z12.string().uuid(),
|
|
2912
2913
|
name: z12.string(),
|
|
2913
2914
|
tags: z12.array(z12.string()),
|
|
2914
|
-
declared_params: z12.
|
|
2915
|
+
declared_params: z12.array(WorkflowDeclaredParamSchema).nullable().default([]),
|
|
2915
2916
|
canvas_rev: z12.number().int().nonnegative(),
|
|
2916
2917
|
updated_at: z12.string()
|
|
2917
2918
|
}).strict();
|
|
@@ -2924,7 +2925,7 @@ var WorkflowDetailSchema = z12.object({
|
|
|
2924
2925
|
name: z12.string(),
|
|
2925
2926
|
description: z12.string().nullable(),
|
|
2926
2927
|
tags: z12.array(z12.string()),
|
|
2927
|
-
declared_params: z12.
|
|
2928
|
+
declared_params: z12.array(WorkflowDeclaredParamSchema).nullable().default([]),
|
|
2928
2929
|
canvas_rev: z12.number().int().nonnegative(),
|
|
2929
2930
|
nodes: z12.array(z12.unknown()),
|
|
2930
2931
|
edges: z12.array(z12.unknown()),
|
|
@@ -2936,7 +2937,7 @@ var WorkflowCreateResponseSchema = z12.object({
|
|
|
2936
2937
|
name: z12.string(),
|
|
2937
2938
|
description: z12.string().nullable(),
|
|
2938
2939
|
tags: z12.array(z12.string()),
|
|
2939
|
-
declared_params: z12.
|
|
2940
|
+
declared_params: z12.array(WorkflowDeclaredParamSchema).nullable().default([]),
|
|
2940
2941
|
canvas_rev: z12.number().int().nonnegative(),
|
|
2941
2942
|
created_at: z12.string(),
|
|
2942
2943
|
updated_at: z12.string()
|
|
@@ -3013,12 +3014,24 @@ async function patchWorkflow(client, opts) {
|
|
|
3013
3014
|
}
|
|
3014
3015
|
|
|
3015
3016
|
// src/commands/workflow/create.ts
|
|
3017
|
+
function toParamArray(input) {
|
|
3018
|
+
if (Array.isArray(input)) return input;
|
|
3019
|
+
return Object.entries(input).map(([key, val]) => {
|
|
3020
|
+
const def = typeof val === "object" && val !== null ? val : {};
|
|
3021
|
+
if (def.name !== void 0 && def.name !== key) {
|
|
3022
|
+
throw new ArgError(
|
|
3023
|
+
`declared_params key '${key}' conflicts with inner name '${String(def.name)}'.`
|
|
3024
|
+
);
|
|
3025
|
+
}
|
|
3026
|
+
return { name: key, ...def };
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3016
3029
|
async function createWorkflow(opts) {
|
|
3017
3030
|
const client = opts.client ?? await buildWorkflowClient(opts);
|
|
3018
3031
|
const body = { name: opts.name };
|
|
3019
3032
|
if (opts.description !== void 0) body.description = opts.description;
|
|
3020
3033
|
if (opts.tags !== void 0 && opts.tags.length > 0) body.tags = opts.tags;
|
|
3021
|
-
if (opts.declaredParams !== void 0) body.declared_params = opts.declaredParams;
|
|
3034
|
+
if (opts.declaredParams !== void 0) body.declared_params = toParamArray(opts.declaredParams);
|
|
3022
3035
|
return client.request({
|
|
3023
3036
|
method: "POST",
|
|
3024
3037
|
path: "/workflows",
|
|
@@ -3554,13 +3567,13 @@ function renderWorkflowDetail(detail, out) {
|
|
|
3554
3567
|
}
|
|
3555
3568
|
const params = detail.declared_params;
|
|
3556
3569
|
lines.push("", "Declared parameters:");
|
|
3557
|
-
if (!params ||
|
|
3570
|
+
if (!params || params.length === 0) {
|
|
3558
3571
|
lines.push(" (none)");
|
|
3559
3572
|
} else {
|
|
3560
|
-
for (const
|
|
3573
|
+
for (const p of params) {
|
|
3561
3574
|
const req = p.required ? "required" : "optional";
|
|
3562
3575
|
const desc = p.description ? `: ${p.description}` : "";
|
|
3563
|
-
lines.push(` - ${name} (${p.type}, ${req})${desc}`);
|
|
3576
|
+
lines.push(` - ${p.name} (${p.type}, ${req})${desc}`);
|
|
3564
3577
|
}
|
|
3565
3578
|
}
|
|
3566
3579
|
out.write(lines.join("\n") + "\n");
|
|
@@ -4500,6 +4513,13 @@ function exitCodeForResult(result) {
|
|
|
4500
4513
|
}
|
|
4501
4514
|
return 0;
|
|
4502
4515
|
}
|
|
4516
|
+
function splitCsvArray(values) {
|
|
4517
|
+
if (!values || values.length === 0) return void 0;
|
|
4518
|
+
const result = values.flatMap(
|
|
4519
|
+
(v) => v.split(",").map((s) => s.trim()).filter(Boolean)
|
|
4520
|
+
);
|
|
4521
|
+
return result.length > 0 ? result : void 0;
|
|
4522
|
+
}
|
|
4503
4523
|
async function runTemplateList(argv, ctx, rc) {
|
|
4504
4524
|
const parsed = parseArgs(argv, {
|
|
4505
4525
|
string: [...COMMON_RICH_STRING_FLAGS, "scope", "q", "cursor", "limit"],
|
|
@@ -4508,7 +4528,7 @@ async function runTemplateList(argv, ctx, rc) {
|
|
|
4508
4528
|
});
|
|
4509
4529
|
const result = await listTemplates({
|
|
4510
4530
|
q: parsed.string.q,
|
|
4511
|
-
tags: parsed.array.tags,
|
|
4531
|
+
tags: splitCsvArray(parsed.array.tags),
|
|
4512
4532
|
scope: parsed.string.scope,
|
|
4513
4533
|
cursor: parsed.string.cursor,
|
|
4514
4534
|
limit: optionalInt(parsed.string.limit, "limit"),
|
|
@@ -4548,7 +4568,7 @@ async function runTemplateFind(argv, ctx, rc) {
|
|
|
4548
4568
|
if (!query) throw new ArgError("Missing required <query> argument.");
|
|
4549
4569
|
const result = await findTemplates({
|
|
4550
4570
|
query,
|
|
4551
|
-
tags: parsed.array.tags,
|
|
4571
|
+
tags: splitCsvArray(parsed.array.tags),
|
|
4552
4572
|
scope: parsed.string.scope,
|
|
4553
4573
|
cursor: parsed.string.cursor,
|
|
4554
4574
|
limit: optionalInt(parsed.string.limit, "limit"),
|
|
@@ -4679,7 +4699,7 @@ async function runWorkflowCreate(argv, ctx, rc) {
|
|
|
4679
4699
|
});
|
|
4680
4700
|
let name = parsed.string.name;
|
|
4681
4701
|
let description = parsed.string.description;
|
|
4682
|
-
let tags = parsed.array.tags;
|
|
4702
|
+
let tags = splitCsvArray(parsed.array.tags);
|
|
4683
4703
|
let declaredParams;
|
|
4684
4704
|
if (parsed.string["from-file"]) {
|
|
4685
4705
|
const raw = await readJsonFile(parsed.string["from-file"]);
|
|
@@ -4688,7 +4708,7 @@ async function runWorkflowCreate(argv, ctx, rc) {
|
|
|
4688
4708
|
name = name ?? (typeof obj.name === "string" ? obj.name : void 0);
|
|
4689
4709
|
description = description ?? (typeof obj.description === "string" ? obj.description : void 0);
|
|
4690
4710
|
if (!tags && Array.isArray(obj.tags)) tags = obj.tags;
|
|
4691
|
-
if (obj.declared_params && typeof obj.declared_params === "object") {
|
|
4711
|
+
if (obj.declared_params != null && typeof obj.declared_params === "object") {
|
|
4692
4712
|
declaredParams = obj.declared_params;
|
|
4693
4713
|
}
|
|
4694
4714
|
}
|