bpmax-cli 0.2.1-beta.83 → 0.2.1-beta.85

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.83",
543
+ version: "0.2.1-beta.85",
544
544
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
545
545
  type: "module",
546
546
  bin: {
@@ -6080,7 +6080,10 @@ function diffJsonNormalized(domain, before, after) {
6080
6080
  domain,
6081
6081
  before,
6082
6082
  after,
6083
- (value) => buildDomainSubmitPayload(domain, value)
6083
+ // Diffing raw/work/readback is a comparison, not a write. Use the same
6084
+ // gate-free projection as verify so legacy server configuration cannot
6085
+ // degrade one side into the raw shape and surface metadata as differences.
6086
+ (value) => buildComparableSubmitPayload(domain, value)
6084
6087
  );
6085
6088
  }
6086
6089
  function diffJsonComparable(domain, before, after, normalize) {
@@ -10584,6 +10587,7 @@ var PAGE_COMPOSITION_QUERY_MODES = /* @__PURE__ */ new Set(["list", "aggregate"]
10584
10587
  var PAGE_COMPOSITION_AGGREGATE_TYPES = /* @__PURE__ */ new Set([
10585
10588
  "terms",
10586
10589
  "date_histogram",
10590
+ "top_hits",
10587
10591
  "sum",
10588
10592
  "avg",
10589
10593
  "min",
@@ -10599,12 +10603,27 @@ var PAGE_COMPOSITION_AGGREGATE_BUCKET_TYPES = /* @__PURE__ */ new Set([
10599
10603
  var PAGE_COMPOSITION_AGGREGATE_MAX_NODES = 32;
10600
10604
  var PAGE_COMPOSITION_AGGREGATE_MAX_DEPTH = 3;
10601
10605
  var PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE = 100;
10606
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_VALUES = 100;
10607
+ var PAGE_COMPOSITION_AGGREGATE_MAX_STRING_LENGTH = 1024;
10608
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SIZE = 100;
10609
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SOURCE_FIELDS = 30;
10610
+ var PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS = 1e4;
10611
+ var PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_BUCKET_DOCUMENTS = 1e5;
10612
+ var PAGE_COMPOSITION_AGGREGATE_SINGLE_VALUE_METRICS = /* @__PURE__ */ new Set([
10613
+ "sum",
10614
+ "avg",
10615
+ "min",
10616
+ "max",
10617
+ "value_count",
10618
+ "cardinality"
10619
+ ]);
10602
10620
  var PAGE_COMPOSITION_AGGREGATE_PARAM_KEYS = /* @__PURE__ */ new Set([
10603
10621
  "data_set_id",
10604
10622
  "data_set_key",
10605
10623
  "flow_type",
10606
10624
  "flow_key",
10607
- "query"
10625
+ "query",
10626
+ "pagination"
10608
10627
  ]);
10609
10628
  var PAGE_COMPOSITION_AGGREGATE_QUERY_TYPES = /* @__PURE__ */ new Set([
10610
10629
  "term",
@@ -10630,6 +10649,7 @@ var PAGE_COMPOSITION_ES_DEFAULT_PAGE = 1;
10630
10649
  var PAGE_COMPOSITION_ES_DEFAULT_PAGE_SIZE = 20;
10631
10650
  var PAGE_COMPOSITION_ROW_PATH = /^[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z0-9_$-]+)*$/;
10632
10651
  var PAGE_COMPOSITION_METHOD_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;
10652
+ var PAGE_COMPOSITION_METHOD_SAFE_CONSTRUCTORS = /* @__PURE__ */ new Set(["Date", "Array"]);
10633
10653
  var PAGE_COMPOSITION_METHOD_SHA = /^[a-f0-9]{64}$/i;
10634
10654
  var PAGE_COMPOSITION_METHOD_RESOURCE_URL = /^\/static\/client\/[^\s"'<>?#]+\.mjs(?:\?[^\s"'<>#]*)?$/i;
10635
10655
  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 +10680,39 @@ var PAGE_COMPOSITION_METHOD_RESERVED = /* @__PURE__ */ new Set([
10660
10680
  "setFilterCreatedDate",
10661
10681
  "resetFilters"
10662
10682
  ]);
10683
+ function validatePageCompositionExportActions(actions, errors) {
10684
+ for (const [name, value] of Object.entries(actions)) {
10685
+ if (!isRecord6(value)) {
10686
+ errors.push(`page-template action ${name} must be an object.`);
10687
+ continue;
10688
+ }
10689
+ if (value.previewOnly !== void 0 && typeof value.previewOnly !== "boolean") {
10690
+ errors.push(`page-template action ${name} previewOnly must be a boolean.`);
10691
+ }
10692
+ const hasDataExport = value.dataSource !== void 0 || value.config !== void 0;
10693
+ if (!hasDataExport) continue;
10694
+ if (typeof value.capability !== "string" || !value.capability.trim() || !PAGE_COMPOSITION_CAPABILITIES[value.capability.trim()]) {
10695
+ errors.push(`page-template action ${name} data export requires a registered capability.`);
10696
+ }
10697
+ for (const key of ["dataSource", "config"]) {
10698
+ if (typeof value[key] !== "string" || !value[key].trim()) {
10699
+ errors.push(`page-template action ${name} data export ${key} must be a non-empty string.`);
10700
+ }
10701
+ }
10702
+ if (value.name !== void 0 && (typeof value.name !== "string" || !value.name.trim())) {
10703
+ errors.push(`page-template action ${name} data export name must be a non-empty string when provided.`);
10704
+ }
10705
+ if (value.role_key !== void 0 && (typeof value.role_key !== "string" || !value.role_key.trim())) {
10706
+ errors.push(`page-template action ${name} role_key must be a non-empty string when provided.`);
10707
+ }
10708
+ if (value.exportCount !== void 0) {
10709
+ const count = Number(value.exportCount);
10710
+ if (!Number.isSafeInteger(count) || count < 1) {
10711
+ errors.push(`page-template action ${name} exportCount must be a positive integer.`);
10712
+ }
10713
+ }
10714
+ }
10715
+ }
10663
10716
  function validatePageCompositionMethods(methods, resources, contexts, queries, actions) {
10664
10717
  const errors = [];
10665
10718
  const declarations = isRecord6(methods) ? methods : {};
@@ -10695,8 +10748,13 @@ ${code}
10695
10748
  if (!node || typeof node !== "object") return;
10696
10749
  if (node.type === "AwaitExpression" && definition.mode !== "async")
10697
10750
  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")
10751
+ if (node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement" || node.type === "ClassDeclaration")
10699
10752
  throw new Error(`unsupported syntax ${node.type}`);
10753
+ if (node.type === "NewExpression" && (node.callee?.type !== "Identifier" || !PAGE_COMPOSITION_METHOD_SAFE_CONSTRUCTORS.has(node.callee.name)))
10754
+ throw new Error("unsupported constructor in methods");
10755
+ if (node.type === "WithStatement") {
10756
+ throw new Error("unsupported syntax WithStatement");
10757
+ }
10700
10758
  for (const [key, child] of Object.entries(node)) {
10701
10759
  if (["start", "end", "loc", "raw", "type"].includes(key))
10702
10760
  continue;
@@ -10737,6 +10795,7 @@ ${code}
10737
10795
  checkRefs("context", contexts, "transform");
10738
10796
  checkRefs("query", queries, "transform");
10739
10797
  checkRefs("action", actions, "prepare");
10798
+ validatePageCompositionExportActions(actions, errors);
10740
10799
  return errors;
10741
10800
  }
10742
10801
  function validatePageCompositionRowMapping(name, value, errors) {
@@ -10968,10 +11027,11 @@ function validatePageCompositionAggregations(name, value, errors) {
10968
11027
  errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregation ${aggregationName} aggregations is not allowed; use aggs.`);
10969
11028
  return void 0;
10970
11029
  }
10971
- const commonKeys = ["type", "field", "aggs"];
11030
+ const commonKeys = type === "top_hits" ? ["type"] : ["type", "field", "aggs"];
10972
11031
  const allowed = /* @__PURE__ */ new Set([
10973
11032
  ...commonKeys,
10974
- ...type === "terms" ? ["size", "order", "missing", "min_doc_count"] : [],
11033
+ ...type === "terms" ? ["size", "order", "missing", "min_doc_count", "include", "exclude"] : [],
11034
+ ...type === "top_hits" ? ["size", "sort", "_source"] : [],
10975
11035
  ...type === "date_histogram" ? ["calendar_interval", "fixed_interval", "interval", "min_doc_count", "format", "time_zone", "order", "missing"] : [],
10976
11036
  ...type === "cardinality" ? ["missing", "precision_threshold", "rehash"] : [],
10977
11037
  ...(/* @__PURE__ */ new Set(["sum", "avg", "min", "max", "stats", "value_count"])).has(type) ? ["missing"] : []
@@ -10981,16 +11041,27 @@ function validatePageCompositionAggregations(name, value, errors) {
10981
11041
  errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregation ${aggregationName} contains unsupported key ${invalidKey}; script, runtime_mappings and arbitrary DSL are forbidden.`);
10982
11042
  return void 0;
10983
11043
  }
10984
- if (!isSafePageCompositionAggregateField(input.field)) {
11044
+ if (type !== "top_hits" && !isSafePageCompositionAggregateField(input.field)) {
10985
11045
  errors.push(`[page_template.query.aggregate_field] query ${name} aggregation ${aggregationName} requires a safe field path.`);
10986
11046
  return void 0;
10987
11047
  }
10988
- const result = { type, field: input.field };
11048
+ const result = {
11049
+ type,
11050
+ ...type !== "top_hits" ? { field: input.field } : {}
11051
+ };
10989
11052
  if (input.size !== void 0) {
10990
11053
  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;
11054
+ if (type === "terms") {
11055
+ if (!isSafePageCompositionAggregateInteger(size) || size < 1 || size > PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_SIZE) {
11056
+ 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.`);
11057
+ } else result.size = size;
11058
+ } else if (type === "top_hits") {
11059
+ if (!isSafePageCompositionAggregateInteger(size) || size < 1 || size > PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SIZE) {
11060
+ 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}.`);
11061
+ } else result.size = size;
11062
+ } else {
11063
+ errors.push(`[page_template.query.aggregate_limit] query ${name} aggregation ${aggregationName} size is only supported for terms and top_hits.`);
11064
+ }
10994
11065
  }
10995
11066
  if (type === "terms" && input.min_doc_count !== void 0) {
10996
11067
  const min = input.min_doc_count;
@@ -10998,6 +11069,34 @@ function validatePageCompositionAggregations(name, value, errors) {
10998
11069
  errors.push(`[page_template.query.aggregate_invalid] query ${name} terms ${aggregationName} min_doc_count must be an integer from 0 to 1000000.`);
10999
11070
  } else result.min_doc_count = min;
11000
11071
  }
11072
+ if (type === "terms") {
11073
+ for (const key of ["include", "exclude"]) {
11074
+ const values = input[key];
11075
+ if (values === void 0) continue;
11076
+ if (!Array.isArray(values) || values.length === 0 || values.length > PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_VALUES) {
11077
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} terms ${aggregationName} ${key} must contain 1 to ${PAGE_COMPOSITION_AGGREGATE_MAX_TERMS_VALUES} strings.`);
11078
+ } else if (values.some((value2) => typeof value2 !== "string" || value2.length > PAGE_COMPOSITION_AGGREGATE_MAX_STRING_LENGTH)) {
11079
+ 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.`);
11080
+ } else result[key] = [...values];
11081
+ }
11082
+ }
11083
+ if (type === "top_hits") {
11084
+ const sort = input.sort;
11085
+ if (!isRecord6(sort) || Object.keys(sort).length !== 1) {
11086
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} top_hits ${aggregationName} sort must contain one field mapped to asc or desc.`);
11087
+ } else {
11088
+ const [field, direction] = Object.entries(sort)[0];
11089
+ if (!isSafePageCompositionAggregateField(field) || !["asc", "desc"].includes(String(direction))) {
11090
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} top_hits ${aggregationName} sort must contain one safe field mapped to asc or desc.`);
11091
+ } else result.sort = { [field]: String(direction) };
11092
+ }
11093
+ const sourceFields = input._source;
11094
+ if (!Array.isArray(sourceFields) || sourceFields.length === 0 || sourceFields.length > PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_SOURCE_FIELDS) {
11095
+ 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.`);
11096
+ } else if (sourceFields.some((field) => !isSafePageCompositionAggregateField(field))) {
11097
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} top_hits ${aggregationName} _source must contain safe field paths.`);
11098
+ } else result._source = [...sourceFields];
11099
+ }
11001
11100
  const order = validatePageCompositionAggregateOrder(name, input.order, errors);
11002
11101
  if (input.order !== void 0 && !PAGE_COMPOSITION_AGGREGATE_BUCKET_TYPES.has(type)) {
11003
11102
  errors.push(`[page_template.query.aggregate_invalid] query ${name} metric aggregation ${aggregationName} cannot contain order.`);
@@ -11086,6 +11185,99 @@ function validatePageCompositionAggregations(name, value, errors) {
11086
11185
  }
11087
11186
  return normalized;
11088
11187
  }
11188
+ function pageCompositionAggregateType(value) {
11189
+ return isRecord6(value) && typeof value.type === "string" ? value.type : null;
11190
+ }
11191
+ function validatePageCompositionAggregatePagination(name, value, aggregations, errors) {
11192
+ if (value === void 0) return void 0;
11193
+ if (!isRecord6(value)) {
11194
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination must be an object.`);
11195
+ return void 0;
11196
+ }
11197
+ const allowedKeys = /* @__PURE__ */ new Set(["agg", "page", "page_size", "total_agg", "sort"]);
11198
+ const unsupportedKey = Object.keys(value).find((key) => !allowedKeys.has(key));
11199
+ if (unsupportedKey) {
11200
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination cannot contain ${unsupportedKey}.`);
11201
+ return void 0;
11202
+ }
11203
+ const agg = typeof value.agg === "string" ? value.agg.trim() : "";
11204
+ const target = agg && Object.prototype.hasOwnProperty.call(aggregations, agg) ? aggregations[agg] : void 0;
11205
+ const bucketType = pageCompositionAggregateType(target);
11206
+ if (!isSafePageCompositionAggregateName(agg) || !isRecord6(target) || !PAGE_COMPOSITION_AGGREGATE_BUCKET_TYPES.has(String(bucketType))) {
11207
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.agg must name a declared terms or date_histogram aggregation.`);
11208
+ return void 0;
11209
+ }
11210
+ const page = value.page;
11211
+ const pageSize = value.page_size;
11212
+ if (!isSafePageCompositionAggregateInteger(page) || page < 1 || page > PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS) {
11213
+ 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}.`);
11214
+ return void 0;
11215
+ }
11216
+ if (!isSafePageCompositionAggregateInteger(pageSize) || pageSize < 1 || pageSize > 100) {
11217
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.page_size must be an integer from 1 to 100.`);
11218
+ return void 0;
11219
+ }
11220
+ if (page * pageSize > PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS) {
11221
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination page window exceeds ${PAGE_COMPOSITION_AGGREGATE_MAX_PAGINATED_BUCKETS} buckets.`);
11222
+ return void 0;
11223
+ }
11224
+ const targetAggs = isRecord6(target.aggs) ? target.aggs : {};
11225
+ if (Object.prototype.hasOwnProperty.call(targetAggs, "bucket_sort")) {
11226
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination target ${agg} already declares bucket_sort.`);
11227
+ return void 0;
11228
+ }
11229
+ const topHitsSize = Object.values(targetAggs).reduce((max, definition) => {
11230
+ if (pageCompositionAggregateType(definition) !== "top_hits" || !isRecord6(definition)) return max;
11231
+ const size = Number(definition.size ?? 1);
11232
+ return Number.isSafeInteger(size) && size > 0 ? Math.max(max, size) : max;
11233
+ }, 0);
11234
+ if (bucketType === "terms" && topHitsSize > 0 && page * pageSize * topHitsSize > PAGE_COMPOSITION_AGGREGATE_MAX_TOP_HITS_BUCKET_DOCUMENTS) {
11235
+ 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.`);
11236
+ return void 0;
11237
+ }
11238
+ const validateSortTarget = (sortKey, path29) => {
11239
+ if (sortKey === "_count" || sortKey === "_key") return true;
11240
+ if (!Object.prototype.hasOwnProperty.call(targetAggs, sortKey)) {
11241
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} ${path29} must use _count, _key or a declared sibling aggregation.`);
11242
+ return false;
11243
+ }
11244
+ const metricType = pageCompositionAggregateType(targetAggs[sortKey]);
11245
+ if (!metricType || !PAGE_COMPOSITION_AGGREGATE_SINGLE_VALUE_METRICS.has(metricType)) {
11246
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} ${path29} must reference a single-value numeric metric aggregation.`);
11247
+ return false;
11248
+ }
11249
+ return true;
11250
+ };
11251
+ const normalized = { agg, page, page_size: pageSize };
11252
+ if (value.sort !== void 0) {
11253
+ if (!isRecord6(value.sort) || Object.keys(value.sort).length !== 1) {
11254
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.sort must contain one field mapped to asc or desc.`);
11255
+ return void 0;
11256
+ }
11257
+ const [sortKey, direction] = Object.entries(value.sort)[0];
11258
+ if (!/^(_count|_key|[A-Za-z][A-Za-z0-9_-]{0,63})$/.test(sortKey) || !["asc", "desc"].includes(String(direction)) || !validateSortTarget(sortKey, "params.pagination.sort")) {
11259
+ errors.push(`[page_template.query.aggregate_pagination] query ${name} params.pagination.sort only supports a safe aggregation key and asc or desc.`);
11260
+ return void 0;
11261
+ }
11262
+ normalized.sort = { [sortKey]: String(direction) };
11263
+ } else {
11264
+ const declaredOrder = isRecord6(target) && isRecord6(target.order) ? target.order : void 0;
11265
+ if (declaredOrder && Object.keys(declaredOrder).length === 1) {
11266
+ const [sortKey] = Object.entries(declaredOrder)[0];
11267
+ if (!validateSortTarget(sortKey, `params.pagination.${agg}.order`)) return void 0;
11268
+ }
11269
+ }
11270
+ if (value.total_agg !== void 0) {
11271
+ const totalAgg = typeof value.total_agg === "string" ? value.total_agg.trim() : "";
11272
+ const totalDefinition = totalAgg && Object.prototype.hasOwnProperty.call(aggregations, totalAgg) ? aggregations[totalAgg] : void 0;
11273
+ if (!isSafePageCompositionAggregateName(totalAgg) || pageCompositionAggregateType(totalDefinition) !== "cardinality") {
11274
+ 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.`);
11275
+ return void 0;
11276
+ }
11277
+ normalized.total_agg = totalAgg;
11278
+ }
11279
+ return normalized;
11280
+ }
11089
11281
  function pageCompositionAggregationTrace(value) {
11090
11282
  if (!isRecord6(value)) return [];
11091
11283
  const trace = [];
@@ -11096,7 +11288,10 @@ function pageCompositionAggregationTrace(value) {
11096
11288
  type: aggregation.type ?? null,
11097
11289
  field: aggregation.field ?? null,
11098
11290
  depth,
11099
- ...aggregation.size !== void 0 ? { size: aggregation.size } : {}
11291
+ ...aggregation.size !== void 0 ? { size: aggregation.size } : {},
11292
+ ...Array.isArray(aggregation._source) ? { source_fields: aggregation._source.length } : {},
11293
+ ...Array.isArray(aggregation.include) ? { include_values: aggregation.include.length } : {},
11294
+ ...Array.isArray(aggregation.exclude) ? { exclude_values: aggregation.exclude.length } : {}
11100
11295
  });
11101
11296
  const children = isRecord6(aggregation.aggs) ? aggregation.aggs : {};
11102
11297
  Object.entries(children).forEach(([childName, child]) => visit(childName, child, depth + 1));
@@ -11328,17 +11523,29 @@ function analyzePageCompositionQueries(queries) {
11328
11523
  errors.push(`[page_template.query.aggregate_invalid] query ${name} params cannot contain ${forbiddenParamKey}; arbitrary ES DSL is forbidden.`);
11329
11524
  continue;
11330
11525
  }
11526
+ const directPageKey = ["page", "page_size"].find((key) => Object.prototype.hasOwnProperty.call(params, key));
11527
+ if (directPageKey) {
11528
+ errors.push(`[page_template.query.aggregate_invalid] query ${name} aggregate queries must not carry list ${directPageKey}; use params.pagination for bucket pagination.`);
11529
+ continue;
11530
+ }
11331
11531
  const unsupportedParamKey = Object.keys(params).find((key) => !PAGE_COMPOSITION_AGGREGATE_PARAM_KEYS.has(key));
11332
11532
  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.`);
11533
+ 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
11534
  continue;
11335
11535
  }
11336
11536
  validatePageCompositionAggregateQuery(name, params.query, errors);
11337
11537
  if (errors.some((error) => error.includes(`[page_template.query.aggregate_query] query ${name} `))) continue;
11338
11538
  const normalizedAggs = validatePageCompositionAggregations(name, definition.aggs, errors);
11339
11539
  if (!normalizedAggs || errors.some((error) => error.includes(`query ${name} `) && error.includes("aggregate"))) continue;
11540
+ const normalizedPagination = validatePageCompositionAggregatePagination(
11541
+ name,
11542
+ params.pagination,
11543
+ normalizedAggs,
11544
+ errors
11545
+ );
11546
+ if (errors.some((error) => error.includes(`[page_template.query.aggregate_pagination] query ${name} `))) continue;
11340
11547
  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.`);
11548
+ 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
11549
  continue;
11343
11550
  }
11344
11551
  const normalizedDefinition2 = {
@@ -11347,7 +11554,10 @@ function analyzePageCompositionQueries(queries) {
11347
11554
  mode: "aggregate",
11348
11555
  resource: "/project/aggregate",
11349
11556
  method: "POST",
11350
- params: { ...params },
11557
+ params: {
11558
+ ...params,
11559
+ ...normalizedPagination ? { pagination: normalizedPagination } : {}
11560
+ },
11351
11561
  aggs: normalizedAggs,
11352
11562
  ...filterGroup ? { filterGroup } : {}
11353
11563
  };
@@ -11530,7 +11740,18 @@ function pageCompositionQueryEngineTrace(queries) {
11530
11740
  data_set_key: params.data_set_key ?? null,
11531
11741
  data_set_id: params.data_set_id ?? null,
11532
11742
  ...filterFields ? { filter_fields: filterFields } : {},
11533
- ...item.mode === "aggregate" ? { aggregations: pageCompositionAggregationTrace(item.aggs) } : {},
11743
+ ...item.mode === "aggregate" ? {
11744
+ aggregations: pageCompositionAggregationTrace(item.aggs),
11745
+ ...isRecord6(params.pagination) ? {
11746
+ pagination: {
11747
+ agg: params.pagination.agg ?? null,
11748
+ page: params.pagination.page ?? null,
11749
+ page_size: params.pagination.page_size ?? null,
11750
+ ...params.pagination.total_agg !== void 0 ? { total_agg: params.pagination.total_agg } : {},
11751
+ ...params.pagination.sort !== void 0 ? { sort: params.pagination.sort } : {}
11752
+ }
11753
+ } : {}
11754
+ } : {},
11534
11755
  ...item.engine === "sql" ? { reason: item.reason ?? null } : {}
11535
11756
  }
11536
11757
  ];
@@ -16332,6 +16553,16 @@ function canonicalFormTemplateValues(value) {
16332
16553
  return identity(left).localeCompare(identity(right));
16333
16554
  });
16334
16555
  }
16556
+ function buildComparableSubmitPayload(domain, value) {
16557
+ try {
16558
+ return buildDomainSubmitPayload(domain, value);
16559
+ } catch (error) {
16560
+ if (domain !== "flow-template" || !isRecord6(value)) {
16561
+ throw error;
16562
+ }
16563
+ return buildDomainSubmitPayload(domain, value, { prevalidatedFlowTemplateLint: true });
16564
+ }
16565
+ }
16335
16566
  function normalizeTypedReadbackComparable(domain, value) {
16336
16567
  let comparable2 = value;
16337
16568
  try {
@@ -16342,7 +16573,7 @@ function normalizeTypedReadbackComparable(domain, value) {
16342
16573
  comparable2.id = id;
16343
16574
  }
16344
16575
  } else {
16345
- comparable2 = buildDomainSubmitPayload(domain, value);
16576
+ comparable2 = buildComparableSubmitPayload(domain, value);
16346
16577
  }
16347
16578
  } catch {
16348
16579
  }