ObjectStackObjectStack

Dataset

Dataset protocol schemas

Analytics Dataset — the one semantic layer (ADR-0021).

A dataset is a named, reusable analytical definition: a base object, the

relationships to include (joins are derived from the object graph — the

author never writes an ON clause), and the declared dimensions

(groupable axes) and measures (aggregatable values). It is deliberately

SMALLER than QuerySchema: no raw SQL, no hand-authored join predicates,

no window/having grammar in the author surface.

Presentations (report / dashboard) bind to a dataset by reference and

pick dimensions/measures by name. The dataset compiles to the existing

Cube analytics runtime (ADR-0021 D-A=(c)); RLS / tenant scoping is enforced

by the runtime per joined object (D-C), never declared here.

Naming: this module owns the high-prior dataset / dimension / measure

vocabulary (LookML / dbt / Cube / PowerBI). The Zod export identifiers are

Dataset-prefixed (DatasetDimensionSchema, DatasetMeasureSchema) so they

do not clash with the Cube layer's DimensionSchema / MetricSchema in

data/analytics.zod.ts while the two layers coexist (Phase 1). The Cube

layer is absorbed/retired in a later phase (D-A).

Source: packages/spec/src/ui/dataset.zod.ts

TypeScript Usage

import { Dataset, DatasetDimension, DatasetMeasure, DerivedMeasureOp } from '@objectstack/spec/ui';
import type { Dataset, DatasetDimension, DatasetMeasure, DerivedMeasureOp } from '@objectstack/spec/ui';

// Validate data
const result = Dataset.parse(data);

Dataset

Properties

PropertyTypeRequiredDescription
namestringDataset unique name
labelstringDataset label
descriptionstringoptionalDisplay label (plain string; i18n keys are auto-generated by the framework)
objectstringBase object name
includestring[]optionalRelationship names/paths to join (derived from object graph; max 3 hops)
filter[__schema0](./__schema0)optionalIntrinsic dataset scope filter
dimensionsObject[]Groupable axes
measuresObject[]Aggregatable values
protectionObjectoptionalPackage author protection block — lock policy for this dataset.
_lockEnum<'none' | 'no-overlay' | 'no-delete' | 'full'>optionalItem-level lock — controls overlay & delete (ADR-0010).
_lockReasonstringoptionalHuman-readable reason shown when a write is refused by _lock.
_lockSourceEnum<'artifact' | 'package' | 'env-forced'>optionalLayer that set _lock (artifact | package | env-forced).
_provenanceEnum<'package' | 'org' | 'env-forced'>optionalOrigin of the item (package | org | env-forced).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.

DatasetDimension

Properties

PropertyTypeRequiredDescription
namestringDimension name — referenced by presentations
labelstringoptionalDisplay label (plain string; i18n keys are auto-generated by the framework)
fieldstringBase field, or relationship[.relationship].field path
typeEnum<'string' | 'number' | 'date' | 'boolean' | 'lookup'>optional
dateGranularityEnum<'day' | 'week' | 'month' | 'quarter' | 'year'>optional

DatasetMeasure

Properties

PropertyTypeRequiredDescription
namestringMeasure name — e.g. "revenue"; defined once
labelstringoptionalDisplay label (plain string; i18n keys are auto-generated by the framework)
aggregateEnum<'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct' | 'array_agg' | 'string_agg'>optionalAggregation (sum/avg/count/...); omit when derived is set
fieldstringoptionalAggregated field; optional for count(*)
filter[__schema0](./__schema0)optional
formatstringoptional
currencystringoptionalDisplay currency code (ISO 4217)
certifiedbooleanBlessed metric (governance checkpoint)
derivedObjectoptional

DerivedMeasureOp

Allowed Values

  • ratio
  • sum
  • difference
  • product

On this page