bpmax-cli 0.1.35 → 0.1.36
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/bin.js +51 -14
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -706,7 +706,7 @@ async function parseJsonInput(input, label = "JSON input") {
|
|
|
706
706
|
// package.json
|
|
707
707
|
var package_default = {
|
|
708
708
|
name: "bpmax-cli",
|
|
709
|
-
version: "0.1.
|
|
709
|
+
version: "0.1.36",
|
|
710
710
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
711
711
|
type: "module",
|
|
712
712
|
bin: {
|
|
@@ -1723,13 +1723,42 @@ function registerEsCommands(program2) {
|
|
|
1723
1723
|
}
|
|
1724
1724
|
|
|
1725
1725
|
// src/commands/flow.ts
|
|
1726
|
+
function normalizeWorkspaceKey(workspace) {
|
|
1727
|
+
const nextWorkspace = workspace.trim().replace(/^\/+|\/+$/g, "");
|
|
1728
|
+
return nextWorkspace.startsWith("w:") ? nextWorkspace.slice(2) : nextWorkspace;
|
|
1729
|
+
}
|
|
1730
|
+
function flowBindingKey(flowType, flowKey) {
|
|
1731
|
+
return `${String(flowType || "default")}:${String(flowKey || "")}`;
|
|
1732
|
+
}
|
|
1733
|
+
async function getWorkspaceFlowBindings(client, profile, options) {
|
|
1734
|
+
if (options.all) {
|
|
1735
|
+
return void 0;
|
|
1736
|
+
}
|
|
1737
|
+
const workspace = normalizeWorkspaceKey(options.workspace || profile.config.workspace);
|
|
1738
|
+
const workspaceInfo = await apiRequest(client, "GET", "/workspace/by_key", {
|
|
1739
|
+
params: {
|
|
1740
|
+
key: workspace
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
return new Set(
|
|
1744
|
+
(workspaceInfo.workspace_flow || []).map((item) => flowBindingKey(item.flow_type, item.flow_key))
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1747
|
+
function filterFlowsByBindings(flows, bindings) {
|
|
1748
|
+
if (!bindings) {
|
|
1749
|
+
return flows;
|
|
1750
|
+
}
|
|
1751
|
+
return flows.filter((flow) => bindings.has(flowBindingKey(flow.flow_type, flow.key)));
|
|
1752
|
+
}
|
|
1726
1753
|
function registerFlowCommands(program2) {
|
|
1727
1754
|
const flow = program2.command("flow").description("Flow commands");
|
|
1728
|
-
flow.command("list").description("List flows").option("--profile <profile>", "Profile name").option("--draft <draft>", "Draft flag", "1").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1755
|
+
flow.command("list").description("List flows").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--all", "List all flows without workspace binding filtering").option("--draft <draft>", "Draft flag", "1").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1729
1756
|
const config = await loadConfig();
|
|
1730
1757
|
const profile = resolveProfile(config, options.profile);
|
|
1758
|
+
const client = createApiClient(profile);
|
|
1759
|
+
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
1731
1760
|
const result = await apiRequest(
|
|
1732
|
-
|
|
1761
|
+
client,
|
|
1733
1762
|
"GET",
|
|
1734
1763
|
"/flow/flow_type",
|
|
1735
1764
|
{
|
|
@@ -1739,40 +1768,48 @@ function registerFlowCommands(program2) {
|
|
|
1739
1768
|
}
|
|
1740
1769
|
}
|
|
1741
1770
|
);
|
|
1742
|
-
printResult(options.format, result);
|
|
1771
|
+
printResult(options.format, filterFlowsByBindings(result, bindings));
|
|
1743
1772
|
});
|
|
1744
|
-
flow.command("options").description("List flow options").option("--profile <profile>", "Profile name").option("--name <name>", "Flow name filter").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1773
|
+
flow.command("options").description("List flow options").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--all", "List all flow options without workspace binding filtering").option("--name <name>", "Flow name filter").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1745
1774
|
const config = await loadConfig();
|
|
1746
1775
|
const profile = resolveProfile(config, options.profile);
|
|
1776
|
+
const client = createApiClient(profile);
|
|
1777
|
+
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
1747
1778
|
const result = await apiRequest(
|
|
1748
|
-
|
|
1779
|
+
client,
|
|
1749
1780
|
"GET",
|
|
1750
1781
|
"/flow/options",
|
|
1751
1782
|
{
|
|
1752
1783
|
params: options.name ? { name: options.name } : void 0
|
|
1753
1784
|
}
|
|
1754
1785
|
);
|
|
1755
|
-
printResult(options.format, result);
|
|
1786
|
+
printResult(options.format, filterFlowsByBindings(result, bindings));
|
|
1756
1787
|
});
|
|
1757
|
-
flow.command("get").description("Get flow detail by id or flow_type/flow_key").option("--id <id>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
1788
|
+
flow.command("get").description("Get flow detail by id or flow_type/flow_key").option("--id <id>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--all", "Get flow by flow_type without workspace binding filtering").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
1758
1789
|
const config = await loadConfig();
|
|
1759
1790
|
const profile = resolveProfile(config, options.profile);
|
|
1760
1791
|
const client = createApiClient(profile);
|
|
1761
1792
|
if (options.flowType) {
|
|
1793
|
+
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
1794
|
+
const path6 = options.flowKey ? "/flow/options" : "/flow/flow_type";
|
|
1795
|
+
const params = options.flowKey ? {
|
|
1796
|
+
detail: "1"
|
|
1797
|
+
} : {
|
|
1798
|
+
draft: "1",
|
|
1799
|
+
skip_i18n: "true"
|
|
1800
|
+
};
|
|
1762
1801
|
const result2 = await apiRequest(
|
|
1763
1802
|
client,
|
|
1764
1803
|
"GET",
|
|
1765
|
-
|
|
1804
|
+
path6,
|
|
1766
1805
|
{
|
|
1767
|
-
params
|
|
1768
|
-
draft: "1",
|
|
1769
|
-
skip_i18n: "true"
|
|
1770
|
-
}
|
|
1806
|
+
params
|
|
1771
1807
|
}
|
|
1772
1808
|
);
|
|
1809
|
+
const filteredResult = filterFlowsByBindings(result2, bindings);
|
|
1773
1810
|
printResult(
|
|
1774
1811
|
options.format,
|
|
1775
|
-
|
|
1812
|
+
filteredResult.find((item) => item.flow_type === options.flowType && String(item.key || "") === options.flowKey) ?? null
|
|
1776
1813
|
);
|
|
1777
1814
|
return;
|
|
1778
1815
|
}
|