Skip to content

Commit be6cf25

Browse files
committed
docs(data-api): state what the analytics query result's fields[] really declares
The callout said each entry carries exactly `name` and `type` "and nothing else", and that reading `label` / `format` off a query result yields `undefined`. `AnalyticsResultResponseSchema` declares `label` / `format` / `currency` / `percentScale` / `builtinAggregate` as optional members and the `AnalyticsResult` contract mirrors them, so both sentences are false on this tree. Rewrite the callout in the conditional form the schema supports and keep the cube-metadata pointer as the declaration surface it is. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8
1 parent 3118d15 commit be6cf25

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

content/docs/api/data-api.mdx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,23 @@ Filtering uses the canonical Query DSL `where` object (the same MongoDB-style `F
420420
```
421421

422422
<Callout type="info">
423-
**`fields[]` describes columns, not presentation.** Each entry carries exactly `name` and
424-
`type` — that is the whole descriptor `AnalyticsResultResponseSchema` declares, and every
425-
strategy answering this endpoint emits those two keys and nothing else.
426-
427-
Display name and number format live one layer up, in the **cube's metric/dimension
428-
definition** (`MetricSchema.label` / `MetricSchema.format`, `DimensionSchema.label`), and
429-
are read from cube metadata — `GET /analytics/meta` below reports each measure's and
430-
dimension's declared label as `title`. Reading `data.fields[i].label` or
431-
`data.fields[i].format` off a query result yields `undefined`; a client that renders table
432-
headers or formats amounts reads them from the cube metadata instead.
423+
**`fields[]` is the resolved presentation surface — read it first.** Each entry carries
424+
`name` and `type` and, when the producer declares them, `label`, `format`, `currency`,
425+
`percentScale` and `builtinAggregate`: the optional members
426+
`AnalyticsResultResponseSchema` declares (`packages/spec/src/api/analytics.zod.ts`),
427+
mirrored member for member by `IAnalyticsService.query`'s `AnalyticsResult` and bound to
428+
it at compile time. Optional means a given column may omit them — read them defensively,
429+
never as guaranteed present.
430+
431+
The **cube's metric/dimension definition** (`MetricSchema.label` / `MetricSchema.format`,
432+
`DimensionSchema.label`) is the *declaration* surface, not a substitute for this one.
433+
`GET /analytics/meta` below publishes a deliberately narrow projection of it — `name`,
434+
`type` and `title` (the definition's `label`) only, with `format` dropped
435+
([#6442](https://github.com/objectstack-ai/objectstack/issues/6442)). So a client that
436+
renders table headers or formats amounts takes `label` / `format` / `currency` /
437+
`percentScale` off the query result's `fields[]`: those are resolved server-side (the
438+
ADR-0053 currency chain, the percent-scale chain), and `format` is not reachable through
439+
the metadata endpoint at all.
433440
</Callout>
434441

435442
### `GET /analytics/meta`

0 commit comments

Comments
 (0)