Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
fix(data-objectstack): aggregate()'s spec-shape branch refuses an unlowered `where` at the producer by claude[bot] · Pull Request #6911 · objectstack-ai/objectui · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(data-objectstack): aggregate()'s spec-shape branch refuses an unlowered `where` at the producer by claude[bot] · Pull Request #6911 · objectstack-ai/objectui · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(data-objectstack): aggregate()'s spec-shape branch refuses an unlowered `where` at the producer by claude[bot] · Pull Request #6911 · objectstack-ai/objectui · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' fix(data-objectstack): aggregate()'s spec-shape branch refuses an unlowered `where` at the producer by claude[bot] · Pull Request #6911 · objectstack-ai/objectui · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(data-objectstack): aggregate()'s spec-shape branch refuses an unlowered `where` at the producer by claude[bot] · Pull Request #6911 · objectstack-ai/objectui · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix(data-objectstack): aggregate()'s spec-shape branch refuses an unlowered `where` at the producer by claude[bot] · Pull Request #6911 · objectstack-ai/objectui · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .changeset/6825-aggregate-spec-shape-strict-where.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
---
'@object-ui/data-objectstack': minor
---

`aggregate()`'s spec-shape branch now REFUSES an unlowered `where` instead of
posting it (objectui#6825, maintainer ruling 2026-08-30 — option A).

**Breaking for callers that were already broken, so read this if you call
`aggregate()` with a `where`.** `aggregate()` has two branches. The analytics
branch takes `filter` and lowers a rule-shaped array before the wire (#6302).
The spec-shape branch — entered when `params` carries an array `groupBy`, an
array `aggregations`, or ANY `where` key — takes `where` and posts it to
`POST /data/:object/query` verbatim. It never lowered, and it still does not:
it now says so.

**What now throws that previously went through.** A `where` that is an ARRAY
the spec's own `isFilterAST` gate rejects — an unlowered
`[{ field, operator, value }, ...]` above all, plus the infix join dialect
(`[condA, 'or', condB]`), a tuple whose operator is outside the AST vocabulary,
`['and']` with nothing to join, and an element that is not a condition. The
throw is an `UnloweredAggregateWhereError` (exported), carrying the same
`code: 'INVALID_FILTER'` / `httpStatus: 400` pair as `MalformedFilterError`, so
`isMalformedFilterError()` recognises it and a failed widget renders "this
filter is malformed" rather than "check your connection".

**This adds no new failure — it relocates one.** Every shape now refused is one
the receiving engine already refused (`is not a filter`, 400 `INVALID_FILTER`,
before the store is touched). What changed is WHERE you find out and whether you
can act on it: previously the predicate was lost on the wire — or dropped
outright, leaving a chart rendering confident, wrong numbers with no signal to
its author. The refusal is now raised at the producer, names the value it
received, names the shape expected and where the spec declares it, and says
nothing was sent.

**What an affected caller should send instead.** Lower the rules to a filter AST
BEFORE calling `aggregate()`:

```diff
- adapter.aggregate('opportunity', {
- groupBy: ['stage'], aggregations: [...],
- where: [{ field: 'stage', operator: 'equals', value: 'won' }],
- })
+ adapter.aggregate('opportunity', {
+ groupBy: ['stage'], aggregations: [...],
+ where: ['stage', '=', 'won'],
+ })
```

Or keep using the analytics branch, which lowers for you: pass the rules under
`filter` with the legacy `field` / `function` / `groupBy` params.

**Unchanged, deliberately.** The analytics branch still lowers `filter` exactly
as #6302 left it. On the spec-shape branch a `FilterCondition` object
(`{ stage: 'won' }` — what `QuerySchema.where` actually declares), an empty
array (`[]` is "no filter", and the engine agrees), and every already-valid
filter AST all reach `client.data.query` byte-unchanged.
49 changes: 49 additions & 0 deletions packages/data-objectstack/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,6 +175,43 @@ one condition of an `and` would widen the result set and report success.
Non-array filters are passed through unchanged on the aggregate path: a
MongoDB-style object is already what `/analytics/query` accepts.

#### `aggregate({ where })` does NOT lower — it refuses

The lowering above is the `filter` parameter, on the analytics path.
`aggregate()` has a second, spec-shape branch — entered when the params carry
an array `groupBy`, an array `aggregations`, or **any** `where` key — which
posts `where` to `POST /data/:object/query` verbatim. That `where` is the spec
Query DSL's `where`, so it must ALREADY be lowered, and since objectui#6825 an
array that the spec's own `isFilterAST` gate rejects is refused here rather
than shipped:

```typescript
// ✅ lowered — reaches the wire unchanged
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: ['stage', '=', 'won'],
});

// ⛔ throws UnloweredAggregateWhereError — authoring sugar, not a filter
await dataSource.aggregate('opportunity', {
groupBy: ['stage'],
aggregations: [{ function: 'count', field: 'id', alias: 'n' }],
where: [{ field: 'stage', operator: 'equals', value: 'won' }],
});
```

This is a producer-side refusal of a value the server already refused (`is not
a filter`, `400 INVALID_FILTER`): the point is that you now find out at the call
site, with the offending value named, instead of on the wire — or not at all,
with a chart quietly rendering unfiltered numbers. Lower the rules in whatever
built the params, or use the analytics branch (`filter` + the legacy `field` /
`function` / `groupBy` params), which lowers for you.

Two shapes are deliberately NOT refused, because the receiving door accepts
them: a `FilterCondition` object (`{ stage: 'won' }` — what `QuerySchema.where`
declares), and an empty array (`[]` means "no filter").

### Sorting

```typescript
Expand DownExpand Up@@ -305,6 +342,16 @@ import {
// SYMBOL is prefixed because @objectstack/spec/kernel
// owns `ValidationError` for a { field, message, code? }
// record (objectui#3160).
MalformedFilterError, // A filter rule that cannot be translated (400
// INVALID_FILTER) — thrown rather than dropped,
// because dropping one condition of an `and` widens
// the result set and reports success.
UnloweredAggregateWhereError, // aggregate()'s spec-shape `where` was an array
// the spec's filter-AST gate rejects (400
// INVALID_FILTER). See "aggregate({ where }) does
// NOT lower" above.
isMalformedFilterError, // Recognises BOTH of the two above, and the server's
// own version of the same refusal.
} from '@object-ui/data-objectstack';
```

Expand DownExpand Up@@ -362,6 +409,8 @@ All errors include unique error codes for programmatic handling:
- `CONNECTION_ERROR` - Connection/network error
- `AUTHENTICATION_ERROR` - Authentication failure
- `VALIDATION_ERROR` - Data validation error
- `INVALID_FILTER` - A filter the adapter refuses to send (`MalformedFilterError`,
`UnloweredAggregateWhereError`); matches the data API's own code for the same refusal
- `UNSUPPORTED_OPERATION` - Unsupported operation
- `NOT_FOUND` - Resource not found
- `UNKNOWN_ERROR` - Unknown error
Expand Down
Loading
Loading