Skip to content

Commit 6502285

Browse files
committed
fix(spec): repo-rooted anchors in the CubeMeta docblock; leave the stage-2 changeset untouched
The pending stage-2 release note is restored byte-for-byte from the merge base (the foreign changeset rule); this change's own changeset states which of its sentences /meta now supersedes. Claude-Session: https://claude.ai/code/session_01Sfe5YjBLwB9J3y8fvm2xq1 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8ae3524 commit 6502285

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎.changeset/20282-analytics-cube-format-granularities-enforced.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Clause-②: yes (narrowing)
1313

1414
Until this change both keys were read on the compiled-dataset path only. One cube shape has three producers — cubes authored with `defineCube()` / `defineStack({ analyticsCubes })`, cubes the dataset compiler mints, and cubes inferred for an ad-hoc query — and only a compiled dataset's cube reached the two readers:
1515

16-
- **`measures.<metric>.format`** reached a caller as `fields[].format` only because the dataset door copies it from the DATASET measure. An authored cube has no dataset, so `POST /api/v1/analytics/query` described its measure columns with `name` and `type` alone. Now every measure column a query names carries the `format` its cube measure declares, whichever strategy answered, and a column that declares none carries no `format` key at all. A client that formats a result column reads `format` off the query result's `fields[]`, as the Data API page says; `GET /api/v1/analytics/meta` also publishes each measure's declared `format`, a separate entry in this release. The value is relayed verbatim; the vocabulary `fields[].format` documents is a numeral pattern such as `"$0,0.00"` or `"0.0%"`.
16+
- **`measures.<metric>.format`** reached a caller as `fields[].format` only because the dataset door copies it from the DATASET measure. An authored cube has no dataset, so `POST /api/v1/analytics/query` described its measure columns with `name` and `type` alone. Now every measure column a query names carries the `format` its cube measure declares, whichever strategy answered, and a column that declares none carries no `format` key at all. `GET /api/v1/analytics/meta` is unchanged: its projection stays `name`, `type` and `title`, and a client reads `format` off the query result's `fields[]`, as the Data API page already says. The value is relayed verbatim; the vocabulary `fields[].format` documents is a numeral pattern such as `"$0,0.00"` or `"0.0%"`.
1717
- **`dimensions.<dimension>.granularities`** was the default bucket only for a compiled dataset, which the dataset executor filled in before querying. An authored cube's time dimension grouped raw timestamps whatever it declared. Now `query()` and the `generateSql()` dry run read it the same way, through the one rule both paths share: a single-entry list is the dimension's default bucket for a query that groups by it; a granularity the query states always wins, and one the list does not name is not refused (the dataset path compares against no list either); a list of two or more states no default; and a `timeDimensions` entry that carries only a `dateRange` for a dimension the query does not group stays a filter.
1818

1919
What to expect after upgrading:

‎.changeset/20282-analytics-cube-meta-descriptions.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Clause-②: yes (widening)
1010
- `CubeMeta` (`@objectstack/spec/contracts`) gains an optional `description` on the cube and on each measure and dimension, and an optional `format` on each measure. `AnalyticsMetadataResponseSchema` declares the same members. A definition that declares none of them is published exactly as before.
1111
- `AnalyticsService.getMeta` copies what the definition declares and fills in nothing. A cube compiled from a dataset carries each dataset measure's `format` and no `description`.
1212
- The liveness ledger rows `analytics_cube.description`, `measures.description` and `dimensions.description` move from `dead` to `live`.
13+
14+
This supersedes one sentence of this release's note on an authored cube's measure `format` and `granularities`: it says `GET /api/v1/analytics/meta` is unchanged and keeps `name`, `type` and `title`. With this change `/meta` also publishes each measure's declared `format`. A client that formats a result column still reads `format` off the query result's `fields[]`.

‎packages/spec/src/contracts/analytics-service.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ export interface AnalyticsResult {
217217
*
218218
* `description` (on the cube and on each member) and a measure's `format` are
219219
* copied from the cube definition when it declares them and absent when it
220-
* does not; `api/analytics.zod.ts#AnalyticsMetadataResponseSchema` declares
221-
* the same shape and `api/analytics.test.ts` binds the two at compile time.
220+
* does not; `packages/spec/src/api/analytics.zod.ts#AnalyticsMetadataResponseSchema`
221+
* declares the same shape and `packages/spec/src/api/analytics.test.ts` binds
222+
* the two at compile time.
222223
*/
223224
export interface CubeMeta {
224225
/** Cube name */

0 commit comments

Comments
 (0)