bpmax-cli 0.1.15 → 0.1.17
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/README.md +33 -0
- package/dist/bin.js +299 -18
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-project/SKILL.md +7 -0
- package/skills/bpmax-schema/SKILL.md +2 -0
package/README.md
CHANGED
|
@@ -132,6 +132,39 @@ bpmax-cli project my-step --key-of-flow-node 'flow802926525::1776572829122' --fo
|
|
|
132
132
|
|
|
133
133
|
Use `--flow-key` when the target flow has a non-empty key. `--flow-step-id` maps to the backend node filter.
|
|
134
134
|
|
|
135
|
+
Create a project with an interactive form guide:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
bpmax-cli project create --profile yuanrong --flow-id 123 --interactive --format json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
During the guide, choose "打开 BPMAX 表单页继续填写" to hand off to the web form. The CLI prints a PC URL and mobile path with the fields already entered encoded in `init_value`.
|
|
142
|
+
|
|
143
|
+
## ES fast queries
|
|
144
|
+
|
|
145
|
+
Use raw ES project search for high-volume reads, aggregations, budget summaries, trend analysis, and other reporting-style queries. Prefer ES aggregations over paging through `project list` and grouping locally.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
bpmax-cli es project-search --profile yuanrong --body @query.json --format json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The body is passed to `POST /api/project/raw-es-search` unchanged:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"data_set_key": "budget_project",
|
|
156
|
+
"flow_type": "flow123",
|
|
157
|
+
"flow_key": "",
|
|
158
|
+
"body": {
|
|
159
|
+
"size": 0,
|
|
160
|
+
"query": { "match_all": {} },
|
|
161
|
+
"aggs": {
|
|
162
|
+
"by_status": { "terms": { "field": "status" } }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
135
168
|
## Profile recipes
|
|
136
169
|
|
|
137
170
|
Profile recipes are local, profile-scoped playbooks for environment-specific BPMAX operations. They live outside project repositories under:
|
package/dist/bin.js
CHANGED
|
@@ -179,6 +179,9 @@ async function apiRequest(client, method, path5, options = {}) {
|
|
|
179
179
|
});
|
|
180
180
|
const body = response.data;
|
|
181
181
|
if (body.code !== 0) {
|
|
182
|
+
if (options.preserveErrorBody) {
|
|
183
|
+
throw new Error(JSON.stringify(body));
|
|
184
|
+
}
|
|
182
185
|
throw new Error(body.msg || `Request failed with code ${body.code}`);
|
|
183
186
|
}
|
|
184
187
|
return body.data ?? body;
|
|
@@ -716,6 +719,47 @@ function registerConfigCommands(program2) {
|
|
|
716
719
|
});
|
|
717
720
|
}
|
|
718
721
|
|
|
722
|
+
// src/core/json-input.ts
|
|
723
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
724
|
+
async function parseJsonInput(input, label = "JSON input") {
|
|
725
|
+
const source = input.startsWith("@") ? input.slice(1) : void 0;
|
|
726
|
+
if (source === "") {
|
|
727
|
+
throw new Error(`${label} file path is empty.`);
|
|
728
|
+
}
|
|
729
|
+
const raw = source ? await readFile2(source, "utf8") : input;
|
|
730
|
+
let parsed;
|
|
731
|
+
try {
|
|
732
|
+
parsed = JSON.parse(raw);
|
|
733
|
+
} catch (error) {
|
|
734
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
735
|
+
throw new Error(`${label} is not valid JSON: ${detail}`);
|
|
736
|
+
}
|
|
737
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
738
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
739
|
+
}
|
|
740
|
+
return parsed;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// src/commands/es.ts
|
|
744
|
+
function registerEsCommands(program2) {
|
|
745
|
+
const es = program2.command("es").description("Fast ES-backed data queries");
|
|
746
|
+
es.command("project-search").description("Run raw ES project search for high-volume reads and aggregations").option("--profile <profile>", "Profile name").requiredOption("--body <json>", "Raw ES request body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
747
|
+
const config = await loadConfig();
|
|
748
|
+
const profile = resolveProfile(config, options.profile);
|
|
749
|
+
const body = await parseJsonInput(options.body, "--body");
|
|
750
|
+
const result = await apiRequest(
|
|
751
|
+
createApiClient(profile),
|
|
752
|
+
"POST",
|
|
753
|
+
"/project/raw-es-search",
|
|
754
|
+
{
|
|
755
|
+
data: body,
|
|
756
|
+
preserveErrorBody: true
|
|
757
|
+
}
|
|
758
|
+
);
|
|
759
|
+
printResult(options.format, result);
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
|
|
719
763
|
// src/commands/flow.ts
|
|
720
764
|
function registerFlowCommands(program2) {
|
|
721
765
|
const flow = program2.command("flow").description("Flow commands");
|
|
@@ -768,7 +812,7 @@ function registerFlowCommands(program2) {
|
|
|
768
812
|
// package.json
|
|
769
813
|
var package_default = {
|
|
770
814
|
name: "bpmax-cli",
|
|
771
|
-
version: "0.1.
|
|
815
|
+
version: "0.1.17",
|
|
772
816
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
773
817
|
type: "module",
|
|
774
818
|
bin: {
|
|
@@ -888,7 +932,7 @@ function setupSummary(input) {
|
|
|
888
932
|
}
|
|
889
933
|
|
|
890
934
|
// src/core/skills.ts
|
|
891
|
-
import { mkdir as mkdir2, readFile as
|
|
935
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
892
936
|
import path2 from "path";
|
|
893
937
|
import { fileURLToPath } from "url";
|
|
894
938
|
|
|
@@ -954,7 +998,7 @@ function stampPath(configDir = getConfigDir()) {
|
|
|
954
998
|
}
|
|
955
999
|
async function readSkillsStamp(configDir = getConfigDir()) {
|
|
956
1000
|
try {
|
|
957
|
-
return (await
|
|
1001
|
+
return (await readFile3(stampPath(configDir), "utf8")).trim();
|
|
958
1002
|
} catch {
|
|
959
1003
|
return "";
|
|
960
1004
|
}
|
|
@@ -1224,6 +1268,170 @@ function validateFormAgainstFields(form, fields) {
|
|
|
1224
1268
|
return { fields, errors };
|
|
1225
1269
|
}
|
|
1226
1270
|
|
|
1271
|
+
// src/core/form-prompts.ts
|
|
1272
|
+
import { confirm, isCancel, multiselect, select, text as text2 } from "@clack/prompts";
|
|
1273
|
+
function isEmpty2(value) {
|
|
1274
|
+
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
1275
|
+
}
|
|
1276
|
+
function cancelIfNeeded(value) {
|
|
1277
|
+
if (isCancel(value)) {
|
|
1278
|
+
throw new Error("Interactive project creation cancelled.");
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
function fieldLabel(field) {
|
|
1282
|
+
return field.label ? `${field.label} (${field.key})` : field.key;
|
|
1283
|
+
}
|
|
1284
|
+
function isArrayField(field) {
|
|
1285
|
+
return /(array|multi|multiple)/.test(field.type?.toLowerCase() ?? "");
|
|
1286
|
+
}
|
|
1287
|
+
function isBooleanField(field) {
|
|
1288
|
+
return /(boolean|bool|switch|checkbox)/.test(field.type?.toLowerCase() ?? "");
|
|
1289
|
+
}
|
|
1290
|
+
function isNumberField(field) {
|
|
1291
|
+
return /(number|int|decimal|float|double|amount)/.test(field.type?.toLowerCase() ?? "");
|
|
1292
|
+
}
|
|
1293
|
+
function stringifyInitial(value) {
|
|
1294
|
+
if (value === void 0 || value === null) {
|
|
1295
|
+
return "";
|
|
1296
|
+
}
|
|
1297
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
1298
|
+
}
|
|
1299
|
+
async function promptField(field, currentValue) {
|
|
1300
|
+
const message = field.required ? `${fieldLabel(field)} *` : fieldLabel(field);
|
|
1301
|
+
if (field.options?.length && isArrayField(field)) {
|
|
1302
|
+
const value2 = await multiselect({
|
|
1303
|
+
message,
|
|
1304
|
+
options: field.options.map((option) => ({ value: option, label: option })),
|
|
1305
|
+
initialValues: Array.isArray(currentValue) ? currentValue.map(String) : [],
|
|
1306
|
+
required: field.required
|
|
1307
|
+
});
|
|
1308
|
+
cancelIfNeeded(value2);
|
|
1309
|
+
return value2;
|
|
1310
|
+
}
|
|
1311
|
+
if (field.options?.length) {
|
|
1312
|
+
const value2 = await select({
|
|
1313
|
+
message,
|
|
1314
|
+
options: [
|
|
1315
|
+
...!field.required ? [{ value: "", label: "(skip)" }] : [],
|
|
1316
|
+
...field.options.map((option) => ({ value: option, label: option }))
|
|
1317
|
+
],
|
|
1318
|
+
initialValue: typeof currentValue === "string" ? currentValue : void 0
|
|
1319
|
+
});
|
|
1320
|
+
cancelIfNeeded(value2);
|
|
1321
|
+
return value2;
|
|
1322
|
+
}
|
|
1323
|
+
if (isBooleanField(field)) {
|
|
1324
|
+
const value2 = await confirm({
|
|
1325
|
+
message,
|
|
1326
|
+
initialValue: typeof currentValue === "boolean" ? currentValue : false
|
|
1327
|
+
});
|
|
1328
|
+
cancelIfNeeded(value2);
|
|
1329
|
+
return value2;
|
|
1330
|
+
}
|
|
1331
|
+
const value = await text2({
|
|
1332
|
+
message,
|
|
1333
|
+
placeholder: isArrayField(field) ? 'JSON array, e.g. ["A","B"]' : void 0,
|
|
1334
|
+
initialValue: stringifyInitial(currentValue),
|
|
1335
|
+
validate(input) {
|
|
1336
|
+
const candidate = input ?? "";
|
|
1337
|
+
if (field.required && !candidate.trim()) {
|
|
1338
|
+
return `${field.key} is required`;
|
|
1339
|
+
}
|
|
1340
|
+
if (!candidate.trim()) {
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
if (isNumberField(field) && Number.isNaN(Number(candidate))) {
|
|
1344
|
+
return `${field.key} must be a number`;
|
|
1345
|
+
}
|
|
1346
|
+
if (isArrayField(field)) {
|
|
1347
|
+
try {
|
|
1348
|
+
const parsed = JSON.parse(candidate);
|
|
1349
|
+
if (!Array.isArray(parsed)) {
|
|
1350
|
+
return `${field.key} must be a JSON array`;
|
|
1351
|
+
}
|
|
1352
|
+
} catch {
|
|
1353
|
+
return `${field.key} must be valid JSON`;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
cancelIfNeeded(value);
|
|
1359
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
1360
|
+
return void 0;
|
|
1361
|
+
}
|
|
1362
|
+
if (isNumberField(field)) {
|
|
1363
|
+
return Number(value);
|
|
1364
|
+
}
|
|
1365
|
+
if (isArrayField(field)) {
|
|
1366
|
+
return JSON.parse(value);
|
|
1367
|
+
}
|
|
1368
|
+
return value;
|
|
1369
|
+
}
|
|
1370
|
+
async function promptAction(message) {
|
|
1371
|
+
const value = await select({
|
|
1372
|
+
message,
|
|
1373
|
+
options: [
|
|
1374
|
+
{ value: "continue", label: "\u7EE7\u7EED\u586B\u5199" },
|
|
1375
|
+
{ value: "open_form", label: "\u6253\u5F00 BPMAX \u8868\u5355\u9875\u7EE7\u7EED\u586B\u5199" },
|
|
1376
|
+
{ value: "submit", label: "\u76F4\u63A5\u63D0\u4EA4" },
|
|
1377
|
+
{ value: "cancel", label: "\u53D6\u6D88" }
|
|
1378
|
+
],
|
|
1379
|
+
initialValue: "continue"
|
|
1380
|
+
});
|
|
1381
|
+
cancelIfNeeded(value);
|
|
1382
|
+
return value;
|
|
1383
|
+
}
|
|
1384
|
+
async function promptProjectCreateForm(input) {
|
|
1385
|
+
let name = input.name;
|
|
1386
|
+
if (!name?.trim()) {
|
|
1387
|
+
const value = await text2({
|
|
1388
|
+
message: "\u6D41\u7A0B\u5355\u6807\u9898 *",
|
|
1389
|
+
validate(candidate) {
|
|
1390
|
+
if (!(candidate ?? "").trim()) {
|
|
1391
|
+
return "\u6D41\u7A0B\u5355\u6807\u9898 is required";
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
cancelIfNeeded(value);
|
|
1396
|
+
name = String(value).trim();
|
|
1397
|
+
}
|
|
1398
|
+
const form = { ...input.form };
|
|
1399
|
+
const requiredFields = input.fields.filter((field) => field.required);
|
|
1400
|
+
const optionalFields = input.fields.filter((field) => !field.required);
|
|
1401
|
+
for (const field of requiredFields) {
|
|
1402
|
+
form[field.key] = await promptField(field, form[field.key]);
|
|
1403
|
+
const action2 = await promptAction("\u4E0B\u4E00\u6B65");
|
|
1404
|
+
if (action2 === "open_form" || action2 === "submit" || action2 === "cancel") {
|
|
1405
|
+
return { name, form, action: action2 };
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
if (optionalFields.length > 0) {
|
|
1409
|
+
const fillOptional = await confirm({
|
|
1410
|
+
message: "\u662F\u5426\u7EE7\u7EED\u586B\u5199\u53EF\u9009\u5B57\u6BB5\uFF1F",
|
|
1411
|
+
initialValue: false
|
|
1412
|
+
});
|
|
1413
|
+
cancelIfNeeded(fillOptional);
|
|
1414
|
+
if (fillOptional) {
|
|
1415
|
+
for (const field of optionalFields) {
|
|
1416
|
+
const value = await promptField(field, form[field.key]);
|
|
1417
|
+
if (!isEmpty2(value)) {
|
|
1418
|
+
form[field.key] = value;
|
|
1419
|
+
}
|
|
1420
|
+
const action2 = await promptAction("\u4E0B\u4E00\u6B65");
|
|
1421
|
+
if (action2 === "open_form" || action2 === "submit" || action2 === "cancel") {
|
|
1422
|
+
return { name, form, action: action2 };
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
const action = await promptAction("\u5B57\u6BB5\u586B\u5199\u5B8C\u6210\uFF0C\u4E0B\u4E00\u6B65");
|
|
1428
|
+
return {
|
|
1429
|
+
name,
|
|
1430
|
+
form,
|
|
1431
|
+
action: action === "continue" ? "submit" : action
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1227
1435
|
// src/core/urls.ts
|
|
1228
1436
|
function stripSlashes(value) {
|
|
1229
1437
|
return value.trim().replace(/^\/+|\/+$/g, "");
|
|
@@ -1256,7 +1464,12 @@ function requireNumericId(value, name) {
|
|
|
1256
1464
|
return nextValue;
|
|
1257
1465
|
}
|
|
1258
1466
|
function withQuery(path5, query) {
|
|
1259
|
-
const params = new URLSearchParams(
|
|
1467
|
+
const params = new URLSearchParams();
|
|
1468
|
+
for (const [key, value] of Object.entries(query)) {
|
|
1469
|
+
if (value !== void 0) {
|
|
1470
|
+
params.set(key, value);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1260
1473
|
return `${path5}?${params.toString()}`;
|
|
1261
1474
|
}
|
|
1262
1475
|
function buildBpmaxUrl(profile, kind, params = {}) {
|
|
@@ -1285,11 +1498,27 @@ function buildBpmaxUrl(profile, kind, params = {}) {
|
|
|
1285
1498
|
});
|
|
1286
1499
|
result.project_id = projectId;
|
|
1287
1500
|
result.step_id = stepId;
|
|
1501
|
+
} else if (kind === "project-create") {
|
|
1502
|
+
const flowType = params.flowType || "default";
|
|
1503
|
+
const flowKey = params.flowKey || "";
|
|
1504
|
+
const initValue = params.initValue ? JSON.stringify(params.initValue) : void 0;
|
|
1505
|
+
const query = {
|
|
1506
|
+
flow_type: flowType,
|
|
1507
|
+
flow_key: flowKey,
|
|
1508
|
+
...flowKey ? { key: flowKey } : {},
|
|
1509
|
+
init_value: initValue
|
|
1510
|
+
};
|
|
1511
|
+
path5 = withQuery(`${basePath}/project/create`, query);
|
|
1512
|
+
result.flow_type = flowType;
|
|
1513
|
+
result.flow_key = flowKey;
|
|
1514
|
+
result.mobile_path = withQuery("/pages/projectCreate/projectCreate", query);
|
|
1288
1515
|
}
|
|
1516
|
+
const url = `${origin}${path5}`;
|
|
1289
1517
|
return {
|
|
1290
1518
|
...result,
|
|
1291
1519
|
path: path5,
|
|
1292
|
-
url
|
|
1520
|
+
url,
|
|
1521
|
+
...kind === "project-create" ? { pc_url: url } : {}
|
|
1293
1522
|
};
|
|
1294
1523
|
}
|
|
1295
1524
|
function extractProjectId(value) {
|
|
@@ -1444,23 +1673,61 @@ function registerProjectCommands(program2) {
|
|
|
1444
1673
|
);
|
|
1445
1674
|
printResult(options.format, result);
|
|
1446
1675
|
});
|
|
1447
|
-
project.command("create").description("Minimal project create shortcut").option("--profile <profile>", "Profile name").option("--flow-id <flowId>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key").option("--name <name>", "Project name").option("--json <json>", "Additional request JSON").option("--body <body>", "Full request body JSON override").option("--skip-form-validation", "Skip local form schema validation before submit").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
1676
|
+
project.command("create").description("Minimal project create shortcut").option("--profile <profile>", "Profile name").option("--flow-id <flowId>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key").option("--name <name>", "Project name").option("--json <json>", "Additional request JSON").option("--body <body>", "Full request body JSON override").option("--interactive", "Guide the user through filling project form fields").option("--skip-form-validation", "Skip local form schema validation before submit").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
1677
|
+
if (options.body && options.interactive) {
|
|
1678
|
+
throw new Error("--body and --interactive cannot be used together.");
|
|
1679
|
+
}
|
|
1448
1680
|
const config = await loadConfig();
|
|
1449
1681
|
const profile = resolveProfile(config, options.profile);
|
|
1450
1682
|
const client = createApiClient(profile);
|
|
1451
1683
|
let payload = parseJson2(options.body);
|
|
1452
1684
|
if (!options.body) {
|
|
1453
|
-
if (!options.name) {
|
|
1454
|
-
throw new Error("--name is required unless --body is provided.");
|
|
1455
|
-
}
|
|
1456
1685
|
const flow = await resolveFlowIdentifiers(client, options);
|
|
1457
1686
|
const { flowDetail, ...flowIdentifiers } = flow;
|
|
1458
1687
|
const extra = parseJson2(options.json);
|
|
1459
1688
|
const form = typeof extra.form === "object" && extra.form !== null && !Array.isArray(extra.form) ? extra.form : {};
|
|
1689
|
+
let name = options.name;
|
|
1690
|
+
if (options.interactive) {
|
|
1691
|
+
if (!flowDetail) {
|
|
1692
|
+
throw new Error("--interactive requires --flow-id so the form schema can be discovered.");
|
|
1693
|
+
}
|
|
1694
|
+
const fields = extractFormFields(flowDetail);
|
|
1695
|
+
const promptResult = await promptProjectCreateForm({ name, form: { ...form }, fields });
|
|
1696
|
+
name = promptResult.name;
|
|
1697
|
+
Object.keys(form).forEach((key) => {
|
|
1698
|
+
delete form[key];
|
|
1699
|
+
});
|
|
1700
|
+
Object.assign(form, promptResult.form);
|
|
1701
|
+
if (promptResult.action === "cancel") {
|
|
1702
|
+
printResult(options.format, { cancelled: true });
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
if (promptResult.action === "open_form") {
|
|
1706
|
+
const url = buildBpmaxUrl(profile, "project-create", {
|
|
1707
|
+
flowType: flowIdentifiers.flow_type,
|
|
1708
|
+
flowKey: flowIdentifiers.flow_key,
|
|
1709
|
+
initValue: {
|
|
1710
|
+
project: { name },
|
|
1711
|
+
key_to_value: form
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
printResult(options.format, {
|
|
1715
|
+
handoff: true,
|
|
1716
|
+
url: url.url,
|
|
1717
|
+
pc_url: url.pc_url,
|
|
1718
|
+
mobile_path: url.mobile_path,
|
|
1719
|
+
message: "\u5DF2\u751F\u6210 BPMAX \u521B\u5EFA\u9875\u94FE\u63A5\uFF0C\u8BF7\u70B9\u51FB\u7EE7\u7EED\u586B\u5199\u5E76\u63D0\u4EA4\u3002"
|
|
1720
|
+
});
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (!name) {
|
|
1725
|
+
throw new Error("--name is required unless --body is provided.");
|
|
1726
|
+
}
|
|
1460
1727
|
payload = {
|
|
1461
1728
|
...extra,
|
|
1462
1729
|
...flowIdentifiers,
|
|
1463
|
-
name
|
|
1730
|
+
name,
|
|
1464
1731
|
workspace: profile.config.workspace,
|
|
1465
1732
|
form
|
|
1466
1733
|
};
|
|
@@ -1485,7 +1752,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
1485
1752
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1486
1753
|
|
|
1487
1754
|
// src/core/recipes.ts
|
|
1488
|
-
import { access, mkdir as mkdir3, readdir, readFile as
|
|
1755
|
+
import { access, mkdir as mkdir3, readdir, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
1489
1756
|
import path3 from "path";
|
|
1490
1757
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
1491
1758
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
@@ -1567,7 +1834,7 @@ function parseRecipeDefinition(input) {
|
|
|
1567
1834
|
};
|
|
1568
1835
|
}
|
|
1569
1836
|
async function loadRecipe(recipeDir) {
|
|
1570
|
-
const raw = await
|
|
1837
|
+
const raw = await readFile4(path3.join(recipeDir, "recipe.json"), "utf8");
|
|
1571
1838
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
1572
1839
|
}
|
|
1573
1840
|
async function listRecipes(recipesDir) {
|
|
@@ -1666,7 +1933,7 @@ async function renderArgv(options) {
|
|
|
1666
1933
|
const rendered = [];
|
|
1667
1934
|
for (const token of options.recipe.command.argv) {
|
|
1668
1935
|
if (token.startsWith("@")) {
|
|
1669
|
-
const raw = await
|
|
1936
|
+
const raw = await readFile4(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
1670
1937
|
rendered.push(renderTemplate(raw, options.variables));
|
|
1671
1938
|
} else {
|
|
1672
1939
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -1848,6 +2115,7 @@ var schemaEntries = [
|
|
|
1848
2115
|
{ name: "flow.list", description: "List flows.", method: "GET", path: "/api/flow/flow_type" },
|
|
1849
2116
|
{ name: "flow.options", description: "List flow options.", method: "GET", path: "/api/flow/options" },
|
|
1850
2117
|
{ name: "flow.get", description: "Fetch flow details by id.", method: "POST", path: "/api/flow/batch_get" },
|
|
2118
|
+
{ name: "es.project-search", description: "Run a raw ES project search for high-volume data reads and aggregations.", method: "POST", path: "/api/project/raw-es-search" },
|
|
1851
2119
|
{ name: "project.list", description: "List projects.", method: "POST", path: "/api/project/list" },
|
|
1852
2120
|
{ name: "project.get", description: "Get project detail.", method: "GET", path: "/api/project/:id" },
|
|
1853
2121
|
{ name: "project.my-step", description: "List my pending steps.", method: "GET", path: "/api/project/my_step" },
|
|
@@ -1871,19 +2139,19 @@ function registerSchemaCommands(program2) {
|
|
|
1871
2139
|
}
|
|
1872
2140
|
|
|
1873
2141
|
// src/commands/setup.ts
|
|
1874
|
-
import { confirm, text as
|
|
2142
|
+
import { confirm as confirm2, text as text3 } from "@clack/prompts";
|
|
1875
2143
|
async function promptText(current, message, placeholder) {
|
|
1876
2144
|
if (current?.trim()) {
|
|
1877
2145
|
return current.trim();
|
|
1878
2146
|
}
|
|
1879
|
-
const value = await
|
|
2147
|
+
const value = await text3({ message, placeholder });
|
|
1880
2148
|
if (typeof value !== "string" || !value.trim()) {
|
|
1881
2149
|
throw new Error(`${message} is required.`);
|
|
1882
2150
|
}
|
|
1883
2151
|
return value.trim();
|
|
1884
2152
|
}
|
|
1885
2153
|
async function promptConfirm(message) {
|
|
1886
|
-
const value = await
|
|
2154
|
+
const value = await confirm2({ message, initialValue: true });
|
|
1887
2155
|
return value === true;
|
|
1888
2156
|
}
|
|
1889
2157
|
function registerSetupCommand(program2, deps = {}) {
|
|
@@ -1968,7 +2236,7 @@ function registerStepCommands(program2) {
|
|
|
1968
2236
|
}
|
|
1969
2237
|
|
|
1970
2238
|
// src/core/update.ts
|
|
1971
|
-
import { access as access2, mkdir as mkdir4, readFile as
|
|
2239
|
+
import { access as access2, mkdir as mkdir4, readFile as readFile5, realpath, writeFile as writeFile4 } from "fs/promises";
|
|
1972
2240
|
import path4 from "path";
|
|
1973
2241
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
1974
2242
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -2085,7 +2353,7 @@ function updateStatePath(configDir = getConfigDir()) {
|
|
|
2085
2353
|
}
|
|
2086
2354
|
async function readUpdateState(configDir) {
|
|
2087
2355
|
try {
|
|
2088
|
-
const raw = await
|
|
2356
|
+
const raw = await readFile5(updateStatePath(configDir), "utf8");
|
|
2089
2357
|
const parsed = JSON.parse(raw);
|
|
2090
2358
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
2091
2359
|
return null;
|
|
@@ -2350,6 +2618,18 @@ async function resolveUrl(load, kind, options) {
|
|
|
2350
2618
|
function registerUrlCommands(program2, deps = {}) {
|
|
2351
2619
|
const load = deps.loadConfig || loadConfig;
|
|
2352
2620
|
const url = program2.command("url").description("Generate BPMAX web URLs");
|
|
2621
|
+
url.command("project-create").description("Generate a project create URL").requiredOption("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--workspace <workspace>", "Workspace override").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
2622
|
+
const config = await load();
|
|
2623
|
+
const profile = resolveProfile(config, options.profile);
|
|
2624
|
+
printUrl(
|
|
2625
|
+
options.format,
|
|
2626
|
+
buildBpmaxUrl(profile, "project-create", {
|
|
2627
|
+
workspace: options.workspace,
|
|
2628
|
+
flowType: options.flowType,
|
|
2629
|
+
flowKey: options.flowKey
|
|
2630
|
+
})
|
|
2631
|
+
);
|
|
2632
|
+
});
|
|
2353
2633
|
url.command("workspace").description("Generate the current workspace URL").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
2354
2634
|
await resolveUrl(load, "workspace", options);
|
|
2355
2635
|
});
|
|
@@ -2461,6 +2741,7 @@ registerAuthCommands(program);
|
|
|
2461
2741
|
registerApiCommands(program);
|
|
2462
2742
|
registerSchemaCommands(program);
|
|
2463
2743
|
registerUserCommands(program);
|
|
2744
|
+
registerEsCommands(program);
|
|
2464
2745
|
registerFlowCommands(program);
|
|
2465
2746
|
registerProjectCommands(program);
|
|
2466
2747
|
registerStepCommands(program);
|