bpmax-cli 0.2.1-beta.59 → 0.2.1-beta.60

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 CHANGED
@@ -200,6 +200,8 @@ bpmax-cli project search --profile yuanrong --body @project-search-query.json --
200
200
 
201
201
  Raw Elasticsearch DTOs are intentionally not supported through `bpmax-cli project search` or `bpmax-cli es project-search`. `huanpingtong-server` does not expose `/api/project/raw-es-search` as a public endpoint, and legacy `/api/project/<id>` routing can fall through to project creation. If the payload contains a top-level `body` field, the CLI fails before sending any request.
202
202
 
203
+ Each `/project/list` filter uses the field-oriented `{ "type": "<ES query type>", "value": ... }` contract. The CLI also accepts a scalar shorthand such as `"current_flow_step_name": "方案review"` and normalizes it to a strict `term` filter. Invalid object shapes fail before HTTP instead of being silently ignored by the server.
204
+
203
205
  Use a project search body instead:
204
206
 
205
207
  ```json
package/dist/bin.js CHANGED
@@ -501,7 +501,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
501
501
  // package.json
502
502
  var package_default = {
503
503
  name: "bpmax-cli",
504
- version: "0.2.1-beta.59",
504
+ version: "0.2.1-beta.60",
505
505
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
506
506
  type: "module",
507
507
  bin: {
@@ -11112,7 +11112,23 @@ async function auditSubFormTemplateReferences(payload, profile) {
11112
11112
  const remoteId = positiveIntegerId(remote.id);
11113
11113
  const remoteOriginTemplateId = positiveIntegerId(remote.origin_template_id);
11114
11114
  const remoteUuid = typeof remote.uuid === "string" ? remote.uuid.trim() : "";
11115
- const matches = remoteId === binding.id && remoteOriginTemplateId === binding.originTemplateId && (!remoteUuid || remoteUuid.toLowerCase() === uuidKey);
11115
+ const remoteMatchesPublishedRelation = remoteId === binding.id && remoteOriginTemplateId === binding.originTemplateId;
11116
+ let remoteMatchesEditableDraft = remoteId === binding.originTemplateId && remoteOriginTemplateId === void 0;
11117
+ if (remoteMatchesEditableDraft) {
11118
+ try {
11119
+ const publishedResponse = await apiRequest(
11120
+ client,
11121
+ "GET",
11122
+ `/form_template/${binding.id}`,
11123
+ { capability: `${CONFIG_DOMAINS["form-template"].capability}.export` }
11124
+ );
11125
+ const publishedRecord = isRecord4(publishedResponse) && isRecord4(publishedResponse.data) ? publishedResponse.data : publishedResponse;
11126
+ remoteMatchesEditableDraft = isRecord4(publishedRecord) && positiveIntegerId(publishedRecord.id) === binding.id && positiveIntegerId(publishedRecord.origin_template_id) === binding.originTemplateId;
11127
+ } catch {
11128
+ remoteMatchesEditableDraft = false;
11129
+ }
11130
+ }
11131
+ const matches = (remoteMatchesPublishedRelation || remoteMatchesEditableDraft) && (!remoteUuid || remoteUuid.toLowerCase() === uuidKey);
11116
11132
  if (!matches) {
11117
11133
  errors.push(
11118
11134
  `[form.sub_form.template_reference_mismatch] \u5173\u8054\u8868\u5355\u5B57\u6BB5 ${binding.field} \u7684\u5B50\u8868\u6A21\u677F\u7ED1\u5B9A\u4E0E UUID \u56DE\u8BFB\u4E0D\u4E00\u81F4\uFF1B\u5DE5\u4F5C\u6587\u4EF6 id=${binding.id}, origin_template_id=${binding.originTemplateId}, uuid=${binding.uuid}\uFF1B\u5F53\u524D\u53D1\u5E03\u5173\u7CFB id=${String(remote.id ?? "\u7F3A\u5931")}, origin_template_id=${String(remote.origin_template_id ?? "\u7F3A\u5931")}, uuid=${String(remote.uuid ?? "\u7F3A\u5931")}\u3002`
@@ -11120,7 +11136,11 @@ async function auditSubFormTemplateReferences(payload, profile) {
11120
11136
  references.push({ ...binding, status: "mismatch", remote_id: remoteId ?? null, remote_origin_template_id: remoteOriginTemplateId ?? null, remote_uuid: remoteUuid || null });
11121
11137
  continue;
11122
11138
  }
11123
- references.push({ ...binding, status: "verified" });
11139
+ references.push({
11140
+ ...binding,
11141
+ status: "verified",
11142
+ remote_relation: remoteMatchesEditableDraft ? "editable_draft" : "published_relation"
11143
+ });
11124
11144
  }
11125
11145
  return {
11126
11146
  errors,
@@ -35207,11 +35227,64 @@ function assertProjectSearchBody(value) {
35207
35227
  );
35208
35228
  }
35209
35229
  }
35230
+ var PROJECT_LIST_QUERY_SHORTHAND_TYPES = /* @__PURE__ */ new Set([
35231
+ "exists",
35232
+ "match",
35233
+ "match_phrase",
35234
+ "prefix",
35235
+ "range",
35236
+ "regexp",
35237
+ "term",
35238
+ "terms",
35239
+ "wildcard"
35240
+ ]);
35241
+ function normalizeProjectListQuery(query) {
35242
+ if (!isRecord16(query)) {
35243
+ throw new Error("project search query \u5FC5\u987B\u662F\u5BF9\u8C61\u3002");
35244
+ }
35245
+ const normalized = {};
35246
+ for (const [field, item] of Object.entries(query)) {
35247
+ if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
35248
+ normalized[field] = { type: "term", value: item };
35249
+ continue;
35250
+ }
35251
+ if (isRecord16(item) && typeof item.type === "string" && Object.prototype.hasOwnProperty.call(item, "value")) {
35252
+ const type = item.type.trim();
35253
+ if (!type) {
35254
+ throw new Error(`project search query.${field}.type \u4E0D\u80FD\u4E3A\u7A7A\u3002`);
35255
+ }
35256
+ normalized[field] = { ...item, type };
35257
+ continue;
35258
+ }
35259
+ if (PROJECT_LIST_QUERY_SHORTHAND_TYPES.has(field) && isRecord16(item)) {
35260
+ const clauses = Object.entries(item);
35261
+ if (clauses.length !== 1) {
35262
+ throw new Error(
35263
+ `project search query.${field} \u53EA\u652F\u6301\u5355\u5B57\u6BB5\u7B80\u5199\uFF1B\u8BF7\u6539\u7528 { "<field>": { "type": "${field}", "value": ... } }\u3002`
35264
+ );
35265
+ }
35266
+ const [nestedField, nestedValue] = clauses[0];
35267
+ normalized[nestedField] = { type: field, value: nestedValue };
35268
+ continue;
35269
+ }
35270
+ throw new Error(
35271
+ `project search query.${field} \u5F62\u72B6\u65E0\u6548\uFF1B\u8BF7\u4F7F\u7528 { "type": "term", "value": ... }\uFF0C\u590D\u6742 ES DSL \u4F7F\u7528 { "type": "raw", "value": { ... } }\u3002`
35272
+ );
35273
+ }
35274
+ return normalized;
35275
+ }
35276
+ function normalizeProjectSearchBody(body) {
35277
+ if (!Object.prototype.hasOwnProperty.call(body, "query")) return body;
35278
+ return {
35279
+ ...body,
35280
+ query: normalizeProjectListQuery(body.query)
35281
+ };
35282
+ }
35210
35283
  function isProjectListEsQuery(value) {
35211
35284
  return ["data_set_id", "data_set_key", "query", "is_select_all", "_source", "aggs"].some((key) => Object.prototype.hasOwnProperty.call(value, key));
35212
35285
  }
35213
35286
  function splitProjectListPagination(body, options) {
35214
- const data = { ...body };
35287
+ const data = normalizeProjectSearchBody(body);
35215
35288
  const normalizePositiveInteger = (value, path27) => {
35216
35289
  if (typeof value === "string" && value.trim() === "") {
35217
35290
  throw new Error(`project search ${path27} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u4E0D\u80FD\u662F\u7A7A\u5B57\u7B26\u4E32\u3002`);