bpmax-cli 0.2.1-beta.82 → 0.2.1-beta.84

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
@@ -540,7 +540,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
540
540
  // package.json
541
541
  var package_default = {
542
542
  name: "bpmax-cli",
543
- version: "0.2.1-beta.82",
543
+ version: "0.2.1-beta.84",
544
544
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
545
545
  type: "module",
546
546
  bin: {
@@ -10584,6 +10584,7 @@ var PAGE_COMPOSITION_QUERY_MODES = /* @__PURE__ */ new Set(["list", "aggregate"]
10584
10584
  var PAGE_COMPOSITION_AGGREGATE_TYPES = /* @__PURE__ */ new Set([
10585
10585
  "terms",
10586
10586
  "date_histogram",
10587
+ "top_hits",
10587
10588
  "sum",
10588
10589
  "avg",
10589
10590
  "min",
@@ -10599,12 +10600,27 @@ var PAGE_COMPOSITION_AGGREGATE_BUCKET_TYPES = /* @__PURE__ */ new Set([
10599
10600
  var PAGE_COMPOSITION_AGGREGATE_MAX_NODES = 32;
10600
10601
  var PAGE_COMPOSITION_AGGREGATE_MAX_DEPTH = 3;
10601
10602
  var PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE = 100;
10603
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_VALUES = 100;
10604
+ var PAGE_COMPOSITION_AGGREGATE_MAX_STRING_LENGTH = 1024;
10605
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SIZE = 100;
10606
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SOURCE_FIELDS = 30;
10607
+ var PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS = 1e4;
10608
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_BUCKET_DOCUMENTS = 1e5;
10609
+ var PAGE_COMPOSITION_AGGREGATE_SINGLE_VALUE_METRICS = /* @__PURE__ */ new Set([
10610
+ "sum",
10611
+ "avg",
10612
+ "min",
10613
+ "max",
10614
+ "value_count",
10615
+ "cardinality"
10616
+ ]);
10602
10617
  var PAGE_COMPOSITION_AGGREGATE_PARAM_KEYS = /* @__PURE__ */ new Set([
10603
10618
  "data_set_id",
10604
10619
  "data_set_key",
10605
10620
  "flow_type",
10606
10621
  "flow_key",
10607
- "query"
10622
+ "query",
10623
+ "pagination"
10608
10624
  ]);
10609
10625
  var PAGE_COMPOSITION_AGGREGATE_QUERY_TYPES = /* @__PURE__ */ new Set([
10610
10626
  "term",
@@ -10630,6 +10646,7 @@ var PAGE_COMPOSITION_ES_DEFAULT_PAGE = 1;
10630
10646
  var PAGE_COMPOSITION_ES_DEFAULT_PAGE_SIZE = 20;
10631
10647
  var PAGE_COMPOSITION_ROW_PATH = /^[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z0-9_$-]+)*$/;
10632
10648
  var PAGE_COMPOSITION_METHOD_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;
10649
+ var PAGE_COMPOSITION_METHOD_SAFE_CONSTRUCTORS = /* @__PURE__ */ new Set(["Date", "Array"]);
10633
10650
  var PAGE_COMPOSITION_METHOD_SHA = /^[a-f0-9]{64}$/i;
10634
10651
  var PAGE_COMPOSITION_METHOD_RESOURCE_URL = /^\/static\/client\/[^\s"'<>?#]+\.mjs(?:\?[^\s"'<>#]*)?$/i;
10635
10652
  var PAGE_COMPOSITION_METHOD_FORBIDDEN = /(?:\b(?:constructor|__proto__|prototype|Function|eval|globalThis|window|document|process|require|import|this|ownerDocument|defaultView|fetch|XMLHttpRequest|WebSocket|setTimeout|setInterval|location|localStorage|sessionStorage|navigator|alert|confirm|prompt)\b|\$(?:root|parent|children|refs|el)\b)/i;
@@ -10660,6 +10677,39 @@ var PAGE_COMPOSITION_METHOD_RESERVED = /* @__PURE__ */ new Set([
10660
10677
  "setFilterCreatedDate",
10661
10678
  "resetFilters"
10662
10679
  ]);
10680
+ function validatePageCompositionExportActions(actions, errors) {
10681
+ for (const [name, value] of Object.entries(actions)) {
10682
+ if (!isRecord6(value)) {
10683
+ errors.push(`page-template action ${name} must be an object.`);
10684
+ continue;
10685
+ }
10686
+ if (value.previewOnly !== void 0 && typeof value.previewOnly !== "boolean") {
10687
+ errors.push(`page-template action ${name} previewOnly must be a boolean.`);
10688
+ }
10689
+ const hasDataExport = value.dataSource !== void 0 || value.config !== void 0;
10690
+ if (!hasDataExport) continue;
10691
+ if (typeof value.capability !== "string" || !value.capability.trim() || !PAGE_COMPOSITION_CAPABILITIES[value.capability.trim()]) {
10692
+ errors.push(`page-template action ${name} data export requires a registered capability.`);
10693
+ }
10694
+ for (const key of ["dataSource", "config"]) {
10695
+ if (typeof value[key] !== "string" || !value[key].trim()) {
10696
+ errors.push(`page-template action ${name} data export ${key} must be a non-empty string.`);
10697
+ }
10698
+ }
10699
+ if (value.name !== void 0 && (typeof value.name !== "string" || !value.name.trim())) {
10700
+ errors.push(`page-template action ${name} data export name must be a non-empty string when provided.`);
10701
+ }
10702
+ if (value.role_key !== void 0 && (typeof value.role_key !== "string" || !value.role_key.trim())) {
10703
+ errors.push(`page-template action ${name} role_key must be a non-empty string when provided.`);
10704
+ }
10705
+ if (value.exportCount !== void 0) {
10706
+ const count = Number(value.exportCount);
10707
+ if (!Number.isSafeInteger(count) || count < 1) {
10708
+ errors.push(`page-template action ${name} exportCount must be a positive integer.`);
10709
+ }
10710
+ }
10711
+ }
10712
+ }
10663
10713
  function validatePageCompositionMethods(methods, resources, contexts, queries, actions) {
10664
10714
  const errors = [];
10665
10715
  const declarations = isRecord6(methods) ? methods : {};
@@ -10695,8 +10745,13 @@ ${code}
10695
10745
  if (!node || typeof node !== "object") return;
10696
10746
  if (node.type === "AwaitExpression" && definition.mode !== "async")
10697
10747
  throw new Error("await requires async mode");
10698
- if (node.type === "ForStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement" || node.type === "NewExpression" || node.type === "ClassDeclaration" || node.type === "WithStatement")
10748
+ if (node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement" || node.type === "ClassDeclaration")
10699
10749
  throw new Error(`unsupported syntax ${node.type}`);
10750
+ if (node.type === "NewExpression" && (node.callee?.type !== "Identifier" || !PAGE_COMPOSITION_METHOD_SAFE_CONSTRUCTORS.has(node.callee.name)))
10751
+ throw new Error("unsupported constructor in methods");
10752
+ if (node.type === "WithStatement") {
10753
+ throw new Error("unsupported syntax WithStatement");
10754
+ }
10700
10755
  for (const [key, child] of Object.entries(node)) {
10701
10756
  if (["start", "end", "loc", "raw", "type"].includes(key))
10702
10757
  continue;
@@ -10737,6 +10792,7 @@ ${code}
10737
10792
  checkRefs("context", contexts, "transform");
10738
10793
  checkRefs("query", queries, "transform");
10739
10794
  checkRefs("action", actions, "prepare");
10795
+ validatePageCompositionExportActions(actions, errors);
10740
10796
  return errors;
10741
10797
  }
10742
10798
  function validatePageCompositionRowMapping(name, value, errors) {
@@ -10968,10 +11024,11 @@ function validatePageCompositionAggregations(name, value, errors) {
10968
11024
  errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregation ${aggregationName} aggregations is not allowed; use aggs.`);
10969
11025
  return void 0;
10970
11026
  }
10971
- const commonKeys = ["type", "field", "aggs"];
11027
+ const commonKeys = type === "top_hits" ? ["type"] : ["type", "field", "aggs"];
10972
11028
  const allowed = /* @__PURE__ */ new Set([
10973
11029
  ...commonKeys,
10974
- ...type === "terms" ? ["size", "order", "missing", "min_doc_count"] : [],
11030
+ ...type === "terms" ? ["size", "order", "missing", "min_doc_count", "include", "exclude"] : [],
11031
+ ...type === "top_hits" ? ["size", "sort", "_source"] : [],
10975
11032
  ...type === "date_histogram" ? ["calendar_interval", "fixed_interval", "interval", "min_doc_count", "format", "time_zone", "order", "missing"] : [],
10976
11033
  ...type === "cardinality" ? ["missing", "precision_threshold", "rehash"] : [],
10977
11034
  ...(/* @__PURE__ */ new Set(["sum", "avg", "min", "max", "stats", "value_count"])).has(type) ? ["missing"] : []
@@ -10981,16 +11038,27 @@ function validatePageCompositionAggregations(name, value, errors) {
10981
11038
  errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregation ${aggregationName} contains unsupported key ${invalidKey}; script, runtime_mappings and arbitrary DSL are forbidden.`);
10982
11039
  return void 0;
10983
11040
  }
10984
- if (!isSafePageCompositionAggregateField(input.field)) {
11041
+ if (type !== "top_hits" && !isSafePageCompositionAggregateField(input.field)) {
10985
11042
  errors.push(`[page_template.query.aggregate_field] query ${name} aggregation ${aggregationName} requires a safe field path.`);
10986
11043
  return void 0;
10987
11044
  }
10988
- const result = { type, field: input.field };
11045
+ const result = {
11046
+ type,
11047
+ ...type !== "top_hits" ? { field: input.field } : {}
11048
+ };
10989
11049
  if (input.size !== void 0) {
10990
11050
  const size = input.size;
10991
- if (!isSafePageCompositionAggregateInteger(size) || size < 1 || size > PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE || type !== "terms") {
10992
- errors.push(`[page_template.query.aggregate_limit] query ${name} aggregation ${aggregationName} size must be an integer from 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE} and is only supported for terms.`);
10993
- } else result.size = size;
11051
+ if (type === "terms") {
11052
+ if (!isSafePageCompositionAggregateInteger(size) || size < 1 || size > PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE) {
11053
+ errors.push(`[page_template.query.aggregate_limit] query ${name} aggregation ${aggregationName} size must be an integer from 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE} for terms.`);
11054
+ } else result.size = size;
11055
+ } else if (type === "top_hits") {
11056
+ if (!isSafePageCompositionAggregateInteger(size) || size < 1 || size > PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SIZE) {
11057
+ errors.push(`[page_template.query.aggregate_limit] query ${name} aggregation ${aggregationName} top_hits.size must be an integer from 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SIZE}.`);
11058
+ } else result.size = size;
11059
+ } else {
11060
+ errors.push(`[page_template.query.aggregate_limit] query ${name} aggregation ${aggregationName} size is only supported for terms and top_hits.`);
11061
+ }
10994
11062
  }
10995
11063
  if (type === "terms" && input.min_doc_count !== void 0) {
10996
11064
  const min = input.min_doc_count;
@@ -10998,6 +11066,34 @@ function validatePageCompositionAggregations(name, value, errors) {
10998
11066
  errors.push(`[page_template.query.aggregate_invalid] query ${name} terms ${aggregationName} min_doc_count must be an integer from 0 to 1000000.`);
10999
11067
  } else result.min_doc_count = min;
11000
11068
  }
11069
+ if (type === "terms") {
11070
+ for (const key of ["include", "exclude"]) {
11071
+ const values = input[key];
11072
+ if (values === void 0) continue;
11073
+ if (!Array.isArray(values) || values.length === 0 || values.length > PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_VALUES) {
11074
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} terms ${aggregationName} ${key} must contain 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_VALUES} strings.`);
11075
+ } else if (values.some((value2) => typeof value2 !== "string" || value2.length > PAGE_COMPOSITION_AGGREGATE_MAX_STRING_LENGTH)) {
11076
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} terms ${aggregationName} ${key} values must be strings no longer than ${PAGE_COMPOSITION_AGGREGATE_MAX_STRING_LENGTH} characters.`);
11077
+ } else result[key] = [...values];
11078
+ }
11079
+ }
11080
+ if (type === "top_hits") {
11081
+ const sort = input.sort;
11082
+ if (!isRecord6(sort) || Object.keys(sort).length !== 1) {
11083
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} top_hits ${aggregationName} sort must contain one field mapped to asc or desc.`);
11084
+ } else {
11085
+ const [field, direction] = Object.entries(sort)[0];
11086
+ if (!isSafePageCompositionAggregateField(field) || !["asc", "desc"].includes(String(direction))) {
11087
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} top_hits ${aggregationName} sort must contain one safe field mapped to asc or desc.`);
11088
+ } else result.sort = { [field]: String(direction) };
11089
+ }
11090
+ const sourceFields = input._source;
11091
+ if (!Array.isArray(sourceFields) || sourceFields.length === 0 || sourceFields.length > PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SOURCE_FIELDS) {
11092
+ errors.push(`[page_template.query.aggregate_limit] query ${name} top_hits ${aggregationName} _source must contain 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SOURCE_FIELDS} safe fields.`);
11093
+ } else if (sourceFields.some((field) => !isSafePageCompositionAggregateField(field))) {
11094
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} top_hits ${aggregationName} _source must contain safe field paths.`);
11095
+ } else result._source = [...sourceFields];
11096
+ }
11001
11097
  const order = validatePageCompositionAggregateOrder(name, input.order, errors);
11002
11098
  if (input.order !== void 0 && !PAGE_COMPOSITION_AGGREGATE_BUCKET_TYPES.has(type)) {
11003
11099
  errors.push(`[page_template.query.aggregate_invalid] query ${name} metric aggregation ${aggregationName} cannot contain order.`);
@@ -11086,6 +11182,99 @@ function validatePageCompositionAggregations(name, value, errors) {
11086
11182
  }
11087
11183
  return normalized;
11088
11184
  }
11185
+ function pageCompositionAggregateType(value) {
11186
+ return isRecord6(value) && typeof value.type === "string" ? value.type : null;
11187
+ }
11188
+ function validatePageCompositionAggregatePagination(name, value, aggregations, errors) {
11189
+ if (value === void 0) return void 0;
11190
+ if (!isRecord6(value)) {
11191
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination must be an object.`);
11192
+ return void 0;
11193
+ }
11194
+ const allowedKeys = /* @__PURE__ */ new Set(["agg", "page", "page_size", "total_agg", "sort"]);
11195
+ const unsupportedKey = Object.keys(value).find((key) => !allowedKeys.has(key));
11196
+ if (unsupportedKey) {
11197
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination cannot contain ${unsupportedKey}.`);
11198
+ return void 0;
11199
+ }
11200
+ const agg = typeof value.agg === "string" ? value.agg.trim() : "";
11201
+ const target = agg && Object.prototype.hasOwnProperty.call(aggregations, agg) ? aggregations[agg] : void 0;
11202
+ const bucketType = pageCompositionAggregateType(target);
11203
+ if (!isSafePageCompositionAggregateName(agg) || !isRecord6(target) || !PAGE_COMPOSITION_AGGREGATE_BUCKET_TYPES.has(String(bucketType))) {
11204
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.agg must name a declared terms or date_histogram aggregation.`);
11205
+ return void 0;
11206
+ }
11207
+ const page = value.page;
11208
+ const pageSize = value.page_size;
11209
+ if (!isSafePageCompositionAggregateInteger(page) || page < 1 || page > PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS) {
11210
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.page must be an integer from 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS}.`);
11211
+ return void 0;
11212
+ }
11213
+ if (!isSafePageCompositionAggregateInteger(pageSize) || pageSize < 1 || pageSize > 100) {
11214
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.page_size must be an integer from 1 to 100.`);
11215
+ return void 0;
11216
+ }
11217
+ if (page * pageSize > PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS) {
11218
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination page window exceeds ${PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS} buckets.`);
11219
+ return void 0;
11220
+ }
11221
+ const targetAggs = isRecord6(target.aggs) ? target.aggs : {};
11222
+ if (Object.prototype.hasOwnProperty.call(targetAggs, "bucket_sort")) {
11223
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination target ${agg} already declares bucket_sort.`);
11224
+ return void 0;
11225
+ }
11226
+ const topHitsSize = Object.values(targetAggs).reduce((max, definition) => {
11227
+ if (pageCompositionAggregateType(definition) !== "top_hits" || !isRecord6(definition)) return max;
11228
+ const size = Number(definition.size ?? 1);
11229
+ return Number.isSafeInteger(size) && size > 0 ? Math.max(max, size) : max;
11230
+ }, 0);
11231
+ if (bucketType === "terms" && topHitsSize > 0 && page * pageSize * topHitsSize > PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_BUCKET_DOCUMENTS) {
11232
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination bucket window multiplied by top_hits.size exceeds ${PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_BUCKET_DOCUMENTS} documents.`);
11233
+ return void 0;
11234
+ }
11235
+ const validateSortTarget = (sortKey, path29) => {
11236
+ if (sortKey === "_count" || sortKey === "_key") return true;
11237
+ if (!Object.prototype.hasOwnProperty.call(targetAggs, sortKey)) {
11238
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} ${path29} must use _count, _key or a declared sibling aggregation.`);
11239
+ return false;
11240
+ }
11241
+ const metricType = pageCompositionAggregateType(targetAggs[sortKey]);
11242
+ if (!metricType || !PAGE_COMPOSITION_AGGREGATE_SINGLE_VALUE_METRICS.has(metricType)) {
11243
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} ${path29} must reference a single-value numeric metric aggregation.`);
11244
+ return false;
11245
+ }
11246
+ return true;
11247
+ };
11248
+ const normalized = { agg, page, page_size: pageSize };
11249
+ if (value.sort !== void 0) {
11250
+ if (!isRecord6(value.sort) || Object.keys(value.sort).length !== 1) {
11251
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.sort must contain one field mapped to asc or desc.`);
11252
+ return void 0;
11253
+ }
11254
+ const [sortKey, direction] = Object.entries(value.sort)[0];
11255
+ if (!/^(_count|_key|[A-Za-z][A-Za-z0-9_-]{0,63})$/.test(sortKey) || !["asc", "desc"].includes(String(direction)) || !validateSortTarget(sortKey, "params.pagination.sort")) {
11256
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.sort only supports a safe aggregation key and asc or desc.`);
11257
+ return void 0;
11258
+ }
11259
+ normalized.sort = { [sortKey]: String(direction) };
11260
+ } else {
11261
+ const declaredOrder = isRecord6(target) && isRecord6(target.order) ? target.order : void 0;
11262
+ if (declaredOrder && Object.keys(declaredOrder).length === 1) {
11263
+ const [sortKey] = Object.entries(declaredOrder)[0];
11264
+ if (!validateSortTarget(sortKey, `params.pagination.${agg}.order`)) return void 0;
11265
+ }
11266
+ }
11267
+ if (value.total_agg !== void 0) {
11268
+ const totalAgg = typeof value.total_agg === "string" ? value.total_agg.trim() : "";
11269
+ const totalDefinition = totalAgg && Object.prototype.hasOwnProperty.call(aggregations, totalAgg) ? aggregations[totalAgg] : void 0;
11270
+ if (!isSafePageCompositionAggregateName(totalAgg) || pageCompositionAggregateType(totalDefinition) !== "cardinality") {
11271
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.total_agg must name a declared root cardinality aggregation; value_count counts documents, not buckets.`);
11272
+ return void 0;
11273
+ }
11274
+ normalized.total_agg = totalAgg;
11275
+ }
11276
+ return normalized;
11277
+ }
11089
11278
  function pageCompositionAggregationTrace(value) {
11090
11279
  if (!isRecord6(value)) return [];
11091
11280
  const trace = [];
@@ -11096,7 +11285,10 @@ function pageCompositionAggregationTrace(value) {
11096
11285
  type: aggregation.type ?? null,
11097
11286
  field: aggregation.field ?? null,
11098
11287
  depth,
11099
- ...aggregation.size !== void 0 ? { size: aggregation.size } : {}
11288
+ ...aggregation.size !== void 0 ? { size: aggregation.size } : {},
11289
+ ...Array.isArray(aggregation._source) ? { source_fields: aggregation._source.length } : {},
11290
+ ...Array.isArray(aggregation.include) ? { include_values: aggregation.include.length } : {},
11291
+ ...Array.isArray(aggregation.exclude) ? { exclude_values: aggregation.exclude.length } : {}
11100
11292
  });
11101
11293
  const children = isRecord6(aggregation.aggs) ? aggregation.aggs : {};
11102
11294
  Object.entries(children).forEach(([childName, child]) => visit(childName, child, depth + 1));
@@ -11328,17 +11520,29 @@ function analyzePageCompositionQueries(queries) {
11328
11520
  errors.push(`[page_template.query.aggregate_invalid] query ${name} params cannot contain ${forbiddenParamKey}; arbitrary ES DSL is forbidden.`);
11329
11521
  continue;
11330
11522
  }
11523
+ const directPageKey = ["page", "page_size"].find((key) => Object.prototype.hasOwnProperty.call(params, key));
11524
+ if (directPageKey) {
11525
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregate queries must not carry list ${directPageKey}; use params.pagination for bucket pagination.`);
11526
+ continue;
11527
+ }
11331
11528
  const unsupportedParamKey = Object.keys(params).find((key) => !PAGE_COMPOSITION_AGGREGATE_PARAM_KEYS.has(key));
11332
11529
  if (unsupportedParamKey) {
11333
- errors.push(`[page_template.query.aggregate_invalid] query ${name} params cannot contain ${unsupportedParamKey}; aggregate queries only accept dataset, flow and typed query parameters.`);
11530
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} params cannot contain ${unsupportedParamKey}; aggregate queries only accept dataset, flow, typed query and params.pagination parameters.`);
11334
11531
  continue;
11335
11532
  }
11336
11533
  validatePageCompositionAggregateQuery(name, params.query, errors);
11337
11534
  if (errors.some((error) => error.includes(`[page_template.query.aggregate_query] query ${name} `))) continue;
11338
11535
  const normalizedAggs = validatePageCompositionAggregations(name, definition.aggs, errors);
11339
11536
  if (!normalizedAggs || errors.some((error) => error.includes(`query ${name} `) && error.includes("aggregate"))) continue;
11537
+ const normalizedPagination = validatePageCompositionAggregatePagination(
11538
+ name,
11539
+ params.pagination,
11540
+ normalizedAggs,
11541
+ errors
11542
+ );
11543
+ if (errors.some((error) => error.includes(`[page_template.query.aggregate_pagination] query ${name} `))) continue;
11340
11544
  if (Object.prototype.hasOwnProperty.call(params, "page") || Object.prototype.hasOwnProperty.call(params, "page_size")) {
11341
- errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregate queries must not carry pagination parameters.`);
11545
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregate queries must not carry list page/page_size; use params.pagination for bucket pagination.`);
11342
11546
  continue;
11343
11547
  }
11344
11548
  const normalizedDefinition2 = {
@@ -11347,7 +11551,10 @@ function analyzePageCompositionQueries(queries) {
11347
11551
  mode: "aggregate",
11348
11552
  resource: "/project/aggregate",
11349
11553
  method: "POST",
11350
- params: { ...params },
11554
+ params: {
11555
+ ...params,
11556
+ ...normalizedPagination ? { pagination: normalizedPagination } : {}
11557
+ },
11351
11558
  aggs: normalizedAggs,
11352
11559
  ...filterGroup ? { filterGroup } : {}
11353
11560
  };
@@ -11530,7 +11737,18 @@ function pageCompositionQueryEngineTrace(queries) {
11530
11737
  data_set_key: params.data_set_key ?? null,
11531
11738
  data_set_id: params.data_set_id ?? null,
11532
11739
  ...filterFields ? { filter_fields: filterFields } : {},
11533
- ...item.mode === "aggregate" ? { aggregations: pageCompositionAggregationTrace(item.aggs) } : {},
11740
+ ...item.mode === "aggregate" ? {
11741
+ aggregations: pageCompositionAggregationTrace(item.aggs),
11742
+ ...isRecord6(params.pagination) ? {
11743
+ pagination: {
11744
+ agg: params.pagination.agg ?? null,
11745
+ page: params.pagination.page ?? null,
11746
+ page_size: params.pagination.page_size ?? null,
11747
+ ...params.pagination.total_agg !== void 0 ? { total_agg: params.pagination.total_agg } : {},
11748
+ ...params.pagination.sort !== void 0 ? { sort: params.pagination.sort } : {}
11749
+ }
11750
+ } : {}
11751
+ } : {},
11534
11752
  ...item.engine === "sql" ? { reason: item.reason ?? null } : {}
11535
11753
  }
11536
11754
  ];
@@ -40742,8 +40960,8 @@ function findCatalogFrom(start) {
40742
40960
  }
40743
40961
  }
40744
40962
  function resolveDefaultIconCatalog() {
40745
- const packageRoot = path23.resolve(path23.dirname(fileURLToPath5(import.meta.url)), "..", "..");
40746
- return findCatalogFrom(process.cwd()) ?? findCatalogFrom(packageRoot) ?? path23.resolve(process.cwd(), CATALOG_RELATIVE);
40963
+ const moduleDir = path23.dirname(fileURLToPath5(import.meta.url));
40964
+ return findCatalogFrom(process.cwd()) ?? findCatalogFrom(moduleDir) ?? path23.resolve(process.cwd(), CATALOG_RELATIVE);
40747
40965
  }
40748
40966
  var DEFAULT_ICON_CATALOG = resolveDefaultIconCatalog();
40749
40967
  async function loadRiIcons(source = process.env.BPMAX_ICON_CATALOG || DEFAULT_ICON_CATALOG) {