bpmax-cli 0.1.44-beta.8 → 0.1.44-beta.9

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 CHANGED
@@ -300,6 +300,9 @@ function capabilityForRequest(method, path9) {
300
300
  if (normalizedMethod === "POST" && normalizedPath === "/data_set") return "config.dataset.create";
301
301
  if (normalizedMethod === "GET" && /^\/data_set\/[^/]+$/.test(normalizedPath)) return "config.dataset.export";
302
302
  if (normalizedMethod === "POST" && /^\/data_set\/relationFields\/[^/]+$/.test(normalizedPath)) return "config.dataset.submit";
303
+ if (normalizedMethod === "POST" && /^\/data_set\/publish\/[^/]+$/.test(normalizedPath)) return "config.dataset.publish";
304
+ if (normalizedMethod === "POST" && /^\/data_set\/pause\/[^/]+$/.test(normalizedPath)) return "config.dataset.pause";
305
+ if (normalizedMethod === "POST" && /^\/data_set\/cancel-refresh\/[^/]+$/.test(normalizedPath)) return "config.dataset.cancel_refresh";
303
306
  if (normalizedMethod === "DELETE" && /^\/data_set\/[^/]+$/.test(normalizedPath)) return "config.dataset.delete";
304
307
  if (normalizedMethod === "POST" && normalizedPath === "/data_set_field") return "config.dataset_field.create";
305
308
  if (normalizedMethod === "GET" && /^\/data_set_field\/[^/]+$/.test(normalizedPath)) return "config.dataset_field.export";
@@ -441,7 +444,7 @@ function normalizePath2(path9) {
441
444
  // package.json
442
445
  var package_default = {
443
446
  name: "bpmax-cli",
444
- version: "0.1.44-beta.8",
447
+ version: "0.1.44-beta.9",
445
448
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
446
449
  type: "module",
447
450
  bin: {
@@ -2762,8 +2765,16 @@ var CONFIG_DOMAINS = {
2762
2765
  submitPath: (id) => `/data_set/relationFields/${id}`,
2763
2766
  submitMethod: "POST",
2764
2767
  readEndpoints: ["GET /api/data_set/:id", "POST /api/data_set/list"],
2765
- writeEndpoints: ["POST /api/data_set", "POST /api/data_set/relationFields/:id", "DELETE /api/data_set/:id"],
2766
- notes: ["Create posts a new dataset through the huanpingtong API-Key proxy. Edit submit updates dataset basics and selected field relations. Publish, pause, cancel-refresh, and index refresh remain separate lifecycle operations."]
2768
+ writeEndpoints: [
2769
+ "POST /api/data_set",
2770
+ "POST /api/data_set/relationFields/:id",
2771
+ "DELETE /api/data_set/:id",
2772
+ "POST /api/data_set/publish/:id",
2773
+ "POST /api/data_set/pause/:id",
2774
+ "POST /api/data_set/cancel-refresh/:id",
2775
+ "POST /api/data_set/pause/:id + POST /api/data_set/publish/:id (refresh/reindex)"
2776
+ ],
2777
+ notes: ["Create posts a new dataset through the huanpingtong API-Key proxy. Edit submit updates dataset basics and selected field relations. Publish, pause, cancel-refresh, and refresh/reindex are explicit lifecycle commands."]
2767
2778
  },
2768
2779
  "dataset-field": {
2769
2780
  capability: "config.dataset_field",
@@ -5344,6 +5355,58 @@ async function deleteConfigDomain(config, profile, domain, id, confirm3) {
5344
5355
  response
5345
5356
  };
5346
5357
  }
5358
+ async function runDatasetLifecycleAction(config, profile, action, id, confirm3) {
5359
+ void config;
5360
+ const commandAction = action;
5361
+ const normalizedAction = action === "reindex" ? "refresh" : action;
5362
+ const definition = CONFIG_DOMAINS.dataset;
5363
+ const capability = `${definition.capability}.${normalizedAction === "cancel-refresh" ? "cancel_refresh" : normalizedAction}`;
5364
+ await ensureConfigCapability(profile, capability);
5365
+ const method = "POST";
5366
+ const expectedConfirm = `${commandAction} dataset ${id}`;
5367
+ const operations = normalizedAction === "refresh" ? [
5368
+ { action: "pause", method, endpoint: `/data_set/pause/${id}`, capability: `${definition.capability}.pause`, optional: true },
5369
+ { action: "publish", method, endpoint: `/data_set/publish/${id}`, capability: `${definition.capability}.publish` }
5370
+ ] : [
5371
+ { action: normalizedAction, method, endpoint: `/data_set/${normalizedAction}/${id}`, capability }
5372
+ ];
5373
+ if (confirm3 !== expectedConfirm) {
5374
+ return {
5375
+ dry_run: true,
5376
+ domain: "dataset",
5377
+ id,
5378
+ action: commandAction,
5379
+ operations,
5380
+ next: `Run again with --confirm "${expectedConfirm}" to ${commandAction} dataset ${id}.`
5381
+ };
5382
+ }
5383
+ const client = createApiClient(profile);
5384
+ const current = await readRemoteConfigDomain(profile, "dataset", id, definition);
5385
+ const currentStatus = isRecord3(current) ? Number(current.status) : NaN;
5386
+ const executableOperations = normalizedAction === "refresh" && currentStatus !== 1 && currentStatus !== 3 ? operations.filter((operation) => operation.action !== "pause") : operations;
5387
+ const responses = [];
5388
+ for (const operation of executableOperations) {
5389
+ responses.push({
5390
+ action: operation.action,
5391
+ response: await apiRequest(
5392
+ client,
5393
+ operation.method,
5394
+ operation.endpoint,
5395
+ { data: {}, capability: operation.capability }
5396
+ )
5397
+ });
5398
+ }
5399
+ const readback = await readRemoteConfigDomain(profile, "dataset", id, definition);
5400
+ return {
5401
+ dry_run: false,
5402
+ domain: "dataset",
5403
+ id,
5404
+ action: commandAction,
5405
+ operations: executableOperations,
5406
+ operation_responses: responses,
5407
+ readback
5408
+ };
5409
+ }
5347
5410
 
5348
5411
  // src/core/config-workspace.ts
5349
5412
  import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
@@ -6369,6 +6432,29 @@ function registerConfigCommands(program2) {
6369
6432
  await saveConfig(configData);
6370
6433
  printResult(options.format, result);
6371
6434
  });
6435
+ if (domain === "dataset") {
6436
+ [
6437
+ ["publish", "Publish/start a dataset and trigger ES batch generation"],
6438
+ ["pause", "Pause a published or pending dataset"],
6439
+ ["cancel-refresh", "Cancel a stuck dataset refresh without changing publish status"],
6440
+ ["refresh", "Refresh/reindex a dataset and generate a new ES batch"],
6441
+ ["reindex", "Alias of refresh; regenerate the dataset ES batch"]
6442
+ ].forEach(([action, description]) => {
6443
+ domainCommand.command(action).description(`${description}; dry-run unless --confirm is exact`).requiredOption("--id <id>", "Remote dataset id").option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
6444
+ const configData = await loadConfig();
6445
+ const resolved = resolveProfile(configData, options.profile);
6446
+ const result = await runDatasetLifecycleAction(
6447
+ configData,
6448
+ resolved,
6449
+ action,
6450
+ options.id,
6451
+ options.confirm
6452
+ );
6453
+ await saveConfig(configData);
6454
+ printResult(options.format, result);
6455
+ });
6456
+ });
6457
+ }
6372
6458
  domainCommand.command("verify").description(`Read back a ${domain} config and optionally compare with an expected JSON file`).requiredOption("--id <id>", "Remote config id").option("--expect <file>", "Expected JSON file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
6373
6459
  const configData = await loadConfig();
6374
6460
  const resolved = resolveProfile(configData, options.profile);
@@ -8560,6 +8646,10 @@ var schemaEntries = [
8560
8646
  { name: "config.dataset.create", description: "Create dataset config through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set" },
8561
8647
  { name: "config.dataset.delete", description: "Delete dataset config through the huanpingtong API-key proxy.", method: "DELETE", path: "/api/data_set/:id" },
8562
8648
  { name: "config.dataset.submit", description: "Submit dataset edit payloads through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set/relationFields/:id" },
8649
+ { name: "config.dataset.publish", description: "Publish/start a dataset and trigger ES batch generation through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set/publish/:id" },
8650
+ { name: "config.dataset.pause", description: "Pause a published or pending dataset before a republish lifecycle.", method: "POST", path: "/api/data_set/pause/:id" },
8651
+ { name: "config.dataset.cancel_refresh", description: "Cancel a stuck dataset refresh without changing dataset publish status.", method: "POST", path: "/api/data_set/cancel-refresh/:id" },
8652
+ { name: "config.dataset.refresh", description: "Refresh/reindex a dataset by running the pause/publish lifecycle through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set/pause/:id + /api/data_set/publish/:id" },
8563
8653
  { name: "config.dataset_field.export", description: "Export dataset field config through huanpingtong API-key proxy.", method: "GET", path: "/api/data_set_field/:id + /api/data_set_field/getBatchByFlow" },
8564
8654
  { name: "config.dataset_field.create", description: "Create dataset field config through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set_field" },
8565
8655
  { name: "config.dataset_field.delete", description: "Delete dataset field config through the huanpingtong API-key proxy.", method: "DELETE", path: "/api/data_set_field/:id" },