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 { DatasetSchema, DatasetDimensionSchema, DatasetMeasureSchema, DerivedMeasureOp } from '@objectstack/spec/ui';
import type { Dataset, DatasetDimension, DatasetMeasure } from '@objectstack/spec/ui';

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

Dataset

Properties

PropertyTypeRequiredDescription
namestringDataset unique name
labelstring | Record<string, string>Dataset label
descriptionstring | Record<string, string>optionalDisplay label — the default-language string, or an inline locale map ({ en, "zh-CN" }) resolved at render time
objectstringBase object name
includestring[]optionalRelationship names/paths to join (derived from object graph; max 3 hops)
filteranyoptionalIntrinsic dataset scope filter
dimensions{ name: string; label?: string | Record<string, string>; field: string; type?: Enum<'string' | 'number' | 'date' | 'boolean' | 'lookup'>; … }[]Groupable axes
measures{ name: string; label?: string | Record<string, string>; aggregate?: Enum<'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct'>; field?: string; … }[]Aggregatable values
protection{ lock: Enum<'none' | 'no-overlay' | 'no-delete' | 'full'>; reason: string; docsUrl?: string }optionalPackage 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
labelstring | Record<string, string>optionalDisplay label — the default-language string, or an inline locale map ({ en, "zh-CN" }) resolved at render time
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
labelstring | Record<string, string>optionalDisplay label — the default-language string, or an inline locale map ({ en, "zh-CN" }) resolved at render time
aggregateEnum<'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct'>optionalAggregation (sum/avg/count/...); omit when derived is set
fieldstringoptionalAggregated field; optional for count(*)
filteranyoptional
formatstringoptional
currencystringoptionalDisplay currency code (ISO 4217)
derived{ op: Enum<'ratio' | 'sum' | 'difference' | 'product'>; of: string[] }optional

DerivedMeasureOp

Allowed Values

  • ratio
  • sum
  • difference
  • product

On this page