Properties and value types

Properties are the typed attributes of an object type: a batch's litres, a silo's age in hours, a shop's location. Each property has a base type that fixes how it is stored and queried, and may have a value type that adds meaning and a constraint. This page covers every base type, value types and their versions, structs and arrays, required, action-only and derived properties, formatting, and index and display options

11 base typesFrom string to attachments
Value typesReusable, versioned constraints with meaning
DerivedComputed at read time, up to 3 link hops
SharedOne definition followed by every type that uses it

In the platform today

Built
  • Properties are declared under each object type in ontology.yaml with type, name, source, values, unit, hiddenFrom, required and description, and eleven base types: string, integer, double, boolean, date, timestamp, geopoint, array, struct, and attachment (one file id) and attachments (a list of them), with accept limiting content types, described on attachments
  • A property marked required: true is enforced on both paths: an action edit that would leave it empty (null, an empty string or an empty list) is refused with ACTION_VALIDATION_FAILED.REQUIRED_PROPERTY, naming each object and property, and sync refuses a source row whose required property is empty after edits are overlaid, keeps that object as it was, counts it in rows_rejected and lists it in rejections on ops.sync_runs with reason REQUIRED_PROPERTY
  • hiddenFrom removes a property from objects, filters and search for the groups it lists
  • Value types: valueTypes: with a base type and optional values, min and max, minLength and maxLength, pattern, unit and message, used by a property or parameter as valueType: <id>
  • They are enforced on action parameters (PARAMETER_INVALID) and on every value an action edit writes (422 VALUE_TYPE_CONSTRAINT), and synced values that break one are kept and listed by GET /api/v2/value-types/{id}/violations
  • Shared properties: sharedProperties:, one definition whose type, value type, unit and values every type that uses it follows, listed by GET /api/v2/shared-properties
In the demo
  • Every base type on this page, value types with constraints and versions, shared properties, structs, derived properties, statuses, display priority, index and display options, and formatting
On request
  • Value type versions, further base types, scale, relative ranges, uniqueness, struct fields, enforcement on pipeline outputs, masking, access label properties, display rollups and the size limits

Anatomy of a property

A property belongs to one object type and maps to one column of a backing dataset, or to no column when it is action-only or derived. Like object types, properties have an immutable ID in camelCase, which is also their name in the REST API and the generated client, and a display name that can change any time. The other settings are listed below

SettingDefaultEffect
baseType or valueTypeInferred from the columnHow the value is stored, validated, indexed and offered in filters
descriptionEmptyShown on hover, indexed for search and read by agents choosing which property answers a question
requiredfalseA null fails indexing of that object and fails any action that would write null
actionOnlyfalseNo backing column; values come only from actions
derivedNoneComputed at read time from linked objects or an expression; never stored
statusThe type's statusDraft, live or retiring; never higher than the type's
prioritystandardDisplay priority: high properties lead the object page; hidden ones are left out of apps
indexingBy base typeFull text, sort, aggregation, facets and others; see below
formatBy base typeDisplay formatting only; the stored value never changes
sharedPropertyNoneInherit name, description, base type and formatting from a shared property

Base types

The base type is the storage type. It decides which operations the index supports, which filters and aggregations apps offer, and what an action parameter writing the property must look like. Every base type below can also be an action parameter. Choose the narrowest type that holds every real value

Base typeHoldsPrimary keyQuery support
stringUTF-8 textYesExact, prefix, full text, fuzzy, regex when enabled
integer32-bit signedYesEquality, ranges, aggregation
double64-bit floating pointNoRanges, aggregation
booleanTrue or falseDiscouragedEquality, counts
dateCalendar date with no time zoneDiscouragedRanges, date buckets
timestampInstant in UTC, millisecond precisionDiscouragedRanges, time buckets, relative filters
geopointLatitude and longitude, WGS 84NoDistance, bounding box, within shape
structNamed, typed fieldsNoEach field queryable on its own
arrayA list of one base typeNoContains, contains any, size
attachment, attachmentsOne file id, or a list of them, for a file uploaded and then attached through an action, up to files.maxSize (200 MB by default)NoThe file id: {"signedForm": "fil_…"}, or {"photos": {"$has": "fil_…"}} for a list. The bytes are read through the object

On request, further base types: long, decimal for money, geoshape, vector for nearest-neighbour search, media, series and access label. Maps and raw binary are not property types: model a map as an array of structs with a key field, and store binary as an attachment

Time zones

Timestamps are stored in UTC and shown in the viewer's zone unless the property's format fixes one. The plant runs on Atlantic time, so properties such as a batch's start are usually formatted with tz: America/Halifax, which keeps shift reports stable when someone in Toronto opens them

Value types

A value type is a named, reusable wrapper around a base type that adds meaning and, optionally, a constraint and a failure message. Temperature °C is a double between −60 and 100. Lot code is a string that matches the plant's lot format. Define a value type once and use it on properties, shared properties and action parameters; the constraint is enforced everywhere it is used

In the platform service, value types are defined in ontology.yaml

valueTypes:
  temperature-c:
    name: Temperature °C
    type: double                 # string, integer, double, boolean, date, timestamp or array
    unit: °C
    min: -60
    max: 100
    message: Temperatures are between −60 and 100 °C
  lot-code:
    name: Lot code
    type: string
    # whole-value match: LOT-0841-1 is the first lot of batch B-0841
    pattern: 'LOT-[0-9]{4}-[0-9]+'
    message: Lot numbers look like LOT-0841-1
  qa-status:
    name: QA status
    type: string
    values: [In process, Pending QA, On hold, Released]
objectTypes:
  lot:
    properties:
      lotNo: { valueType: lot-code }        # type is optional with a value type
  batch:
    properties:
      qaStatus: { valueType: qa-status }

Constraint kinds

Base typeConstraintsExample
stringvalues, a length range, a pattern matched against the whole valueShop status, lot code
integer, doublevalues, a rangeTemperature, percentage 0 to 100
date, timestampA rangeA best-before date within a season
booleanvalues, to forbid one valueA flag that may only be set true
arrayA length range1 to 6 allergen codes

On request, value types take decimal scale, relative ranges, uniqueness and versions, and apply to pipeline output columns too

Structs, arrays and display rollups

A struct property groups related fields into one value: an address, a reading with its time and unit, a pickup's volume and fat percentage. An array holds a list of one base type, and empty arrays are treated as null. On request, struct fields map to their own columns, and display rollups show one value from a list, such as the latest test on a batch

Required, action-only and derived properties

A required property is enforced in two places

  • During sync. A source row whose required property is empty after edits are overlaid (null, an empty string, an empty list or NaN) is refused, its object is kept as it was, and the rest of the type keeps syncing. The run counts it in rows_rejected and lists the first 50 in rejections on ops.sync_runs, with the key and the reason REQUIRED_PROPERTY. On request, refused rows also go to the type's quarantine dataset
  • During an action. A create that leaves a required property unset, or a modify that clears one, fails the whole action with ACTION_VALIDATION_FAILED.REQUIRED_PROPERTY before anything is committed, with every object and property listed in errors

An action-only property has no backing column. It can be created before any source has the field, which is how teams capture decisions the source systems do not hold: a hold reason on a batch, a reroute reason on a delivery, a par-level override on a shop. If a source later gains the column, map it and the property becomes source-backed, with existing edits kept under the type's conflict policy

Derived properties

A derived property is computed when it is read, from linked objects or from an expression over the object's own properties. It is never stored, so it is always current, and it costs nothing until someone reads it

Scoop shopSHP-HFX Delivery stopstatus Planned Reefer deliverynot Delivered, tubs sum(tubs)= 150 hop 1hop 2 tubsOnIncomingRuns on SHP-HFX: follow delivery-stop-shop, then delivery-stop-delivery, filter status ≠ Delivered, sum tubs
A derived property follows up to 3 link hops and aggregates at the end. Any hop that can reach many objects must end in an aggregation
properties:
  tubsOnIncomingRuns:
    derived:
      path:
        - { link: delivery-stop-shop, where: { status: Planned } }
        - { link: delivery-stop-delivery, where: { status: { ne: Delivered } } }
      aggregate: { sum: tubs }
  openDeliveries:
    derived:
      path: [{ link: delivery-stop-shop, where: { status: Planned } }]
      aggregate: { count: true }
  hoursToLimit:
    derived:
      expression: "hoursBetween(now(), limitAt)"
RuleValue
Link hops per derived property3 at most
Aggregationscount, sum, avg, min, max, approximate distinct, exact distinct, collect list, collect set
Collect list and collect set10 values by default, 100 at most
Single value without aggregationOnly when every hop is to one
Depends on another derived propertyNot allowed
Primary key, title property, required, written by an actionNot allowed
SecurityComputed only over linked objects the reader can see; returns null when the reader lacks an access label on the path

Derived properties are cheap to display and expensive to filter or sort on, because a filter on a derived value cannot be pushed to the index and becomes a scan over the pre-filtered set. Filter on stored properties first to keep that set small. When a team filters on the same derived value all day, compute it in a pipeline instead and store it. Apps and functions can also define runtime derived properties for one query, which may use arithmetic over other properties

In the platform service, derive takes an expression string over the same object. Runtime derived properties over linked objects, as below, are delivered on request

const shops = await mso.objects(Shop)
  .where({ status: { $ne: "Closed" } })                         // pushed to the index first
  .derive({
    coverRatio: s => s.follow("delivery-stop-shop").follow("delivery-stop-delivery")
                       .aggregate({ $sum: "tubs" }).divide(s.property("tubsPerDay")),
  })
  .where({ coverRatio: { $lt: 2 } })                  // evaluated by scan over open shops only
  .page({ pageSize: 50 });

Formatting, index and display options

Value formatting changes how a value is displayed and never what is stored

  • Numbers. A style (plain, unit, percent or currency), notation (standard, compact, scientific or engineering), digit grouping, fraction and significant digits, and a prefix or suffix
  • Dates and timestamps. A style (date, date and time, short, ISO or relative, which switches to absolute after 24 hours) and a time zone, fixed or the viewer's
  • Strings that hold IDs. Rendered as a user's name, a group's name or a link to an object

Conditional formatting adds a colour or emphasis when a rule matches. Rules are evaluated top to bottom and the first match wins; an always-true rule at the end is the fallback. A rule can compare to a constant or to another property of the same object, such as freezerTemp greater than freezerSetpoint + 3

Index and display options, set under indexing, tell apps and the index how a property is used. Several of them add index cost, so set them where they are needed

OptionEffectDefault
fullTextIndexed for full-text and fuzzy search; the master switch for the options below itOn for strings under 1 KB
sortDoc values kept for orderingOn for numbers, dates and short strings
aggregatableAvailable as a group-by and metric in aggregationsOn for numbers, dates, booleans
facetShown as a facet with value countsOff
exactMatchNever grouped or range-filtered, even when numericOn for primary keys
multilineShown as a block in the object page; tokenized for searchOff
tagsShown as highlighted chipsOff
regexAllows whole-value regular expression filtersOff; adds index cost
leadingWildcardAllows *suffix searchesOff; adds index cost

Field access and access labels

Field access hides or masks properties per group, evaluated on every read. A hidden property is absent from results, filters and aggregations for that reader; a masked property is present but replaced, for example showing the last four digits of a wholesale customer's account number. Wholesale prices on Product are hidden from shop leads this way, and the same staff can still see the product, its flavour and its finished goods

A property with base type access label holds the access labels that govern its own object. A user must hold every access label in the list to see the object at all; an empty list means no extra restriction. This is how row-level controls follow the data rather than the type: a QA test on a failed quality check carries QUALITY, while routine fat and solids tests do not. An access label property must be required and hidden, and actions that create objects can set it from a parameter limited to the access labels the caller holds

Access labels on a backing dataset apply to every property it supplies. A derived property inherits the access labels of every object on its path, so the same derived value can be visible to one planner and null for another. See Access model and Access labels

Limitations

  • A derived property follows at most 3 link hops, cannot depend on another derived property, and cannot be a primary key, a title property, required or written by an action
  • Filters and sorts on a derived property cannot be pushed to the index. They run as a scan over the pre-filtered set, so they are slow on large sets
  • Structs cannot nest and cannot contain arrays. A property can be an array of structs, but not a struct of arrays
  • Maps and raw binary are not property types
  • A property's base type changes only through a model change set, whose checks refuse the merge while existing values won't convert, or while active edits still hold the old type (EDITS_NOT_CONVERTED) until the change set converts them with castEdits or drops them with dropEdits. For a type with many callers, adding a new property, backfilling it, moving callers and deprecating the old one is still the gentler path
  • Masking happens at read time per group. The unmasked value still exists in the backing dataset, so dataset access must be restricted separately

Related