Support --wait in simulation create and positional code in rules get
This commit is contained in:
1 parent
a3cdfbadf3
commit
9d1c7052a6
4 files changed
+42
-21
No files matched your search
@@ -138,14 +138,16 @@ export async function handleRulesCommand(
|
||||
}
|
||||
|
||||
if (action === "get") {
|
||||
const rawCode = stringOption(args.options.code) ?? (maybeName && !maybeName.startsWith("-") ? maybeName : undefined);
|
||||
const code = rawCode ? (rawCode.startsWith("#") || rawCode.startsWith("rule-") ? rawCode : (rawCode.match(/^\d+$/) ? `#${rawCode.padStart(4, "0")}` : rawCode)) : undefined;
|
||||
await runTool(
|
||||
"seal_approval_rule_get",
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
...ruleVersionGetOptions(stringOption(args.options.version)),
|
||||
code: stringOption(args.options.code),
|
||||
runtimeId: stringOption(args.options.runtimeId) ?? stringOption(args.options["runtime-id"]),
|
||||
code,
|
||||
runtimeId: stringOption(args.options.runtimeId) ?? stringOption(args.options["runtime-id"]) ?? (maybeName?.startsWith("rule-") ? maybeName : undefined),
|
||||
recordId: stringOption(args.options.recordId) ?? stringOption(args.options["record-id"])
|
||||
},
|
||||
outputOptions(args.options)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { runTool } from "../helpers.js";
|
||||
import { runTool, runToolResult } from "../helpers.js";
|
||||
import {
|
||||
booleanOption,
|
||||
jsonObject,
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
splitOption,
|
||||
stringOption
|
||||
} from "../parser.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
import { outputOptions, printJson } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
|
||||
export async function handleSimulationCommand(
|
||||
@@ -62,9 +62,10 @@ export async function handleSimulationCommand(
|
||||
stringOption(args.options.signKey) ??
|
||||
stringOption(args.options["sign-key"]) ??
|
||||
stringOption(args.options.integration);
|
||||
const noWait = booleanOption(args.options.noWait) ?? booleanOption(args.options["no-wait"]);
|
||||
const wait = booleanOption(args.options.wait) === true;
|
||||
const noWait = booleanOption(args.options.noWait) ?? booleanOption(args.options["no-wait"]) ?? (wait ? false : true);
|
||||
|
||||
await runTool(
|
||||
const result = await runToolResult(
|
||||
"seal_simulation_batch_create",
|
||||
client,
|
||||
corp,
|
||||
@@ -94,9 +95,25 @@ export async function handleSimulationCommand(
|
||||
limit: numberOption(args.options.limit),
|
||||
noWait,
|
||||
rawParams: inputPayload
|
||||
},
|
||||
outputOptions(args.options)
|
||||
}
|
||||
);
|
||||
|
||||
if (wait && result && typeof result === "object" && "batchId" in result && typeof result.batchId === "string") {
|
||||
await runTool(
|
||||
"seal_simulation_batch_wait",
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
batchId: result.batchId,
|
||||
timeout: stringOption(args.options.timeout),
|
||||
pollInterval: stringOption(args.options.pollInterval) ?? stringOption(args.options["poll-interval"])
|
||||
},
|
||||
outputOptions(args.options)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
printJson(result, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -264,8 +264,9 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
},
|
||||
{
|
||||
name: "get",
|
||||
summary: "Get single rule by code or record ID",
|
||||
summary: "Get single rule by code, runtime ID, or record ID",
|
||||
usage: [
|
||||
"seal-use rules get <#0016|rule-16> [--version <number|latest>] [--corp <corpId>]",
|
||||
"seal-use rules get --corp <corpId> --version <number|latest> --code '#0038'",
|
||||
"seal-use rules get --corp <corpId> --record-id <recordId> --runtime-id rule-205"
|
||||
]
|
||||
@@ -548,7 +549,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
name: "create",
|
||||
summary: "Trigger a new simulation batch",
|
||||
usage: [
|
||||
"seal-use simulation create --mode hosecloud --flow-ids \"B26017701,B26022501\" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--no-wait] [--corp <corpId>]",
|
||||
"seal-use simulation create --mode hosecloud --flow-ids \"B26017701,B26022501\" [--wait] [--timeout 10m] [--poll-interval 2s] [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--no-wait] [--corp <corpId>]",
|
||||
"seal-use simulation create --mode material_pack --package-ids <materialPackageId> [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp <corpId>]",
|
||||
"seal-use simulation create --source-system weaver --request-ids \"req-01,req-02\" [--corp <corpId>]"
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user