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
In the platform today
- Properties are declared under each object type in
ontology.yamlwithtype,name,source,values,unit,hiddenFrom,requiredanddescription, and eleven base types: string, integer, double, boolean, date, timestamp, geopoint, array, struct, andattachment(one file id) andattachments(a list of them), withacceptlimiting content types, described on attachments - A property marked
required: trueis enforced on both paths: an action edit that would leave it empty (null, an empty string or an empty list) is refused withACTION_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 inrows_rejectedand lists it inrejectionsonops.sync_runswith reasonREQUIRED_PROPERTY hiddenFromremoves a property from objects, filters and search for the groups it lists- Value types:
valueTypes:with a base type and optionalvalues,minandmax,minLengthandmaxLength,pattern,unitandmessage, used by a property or parameter asvalueType: <id> - They are enforced on action parameters (
PARAMETER_INVALID) and on every value an action edit writes (422VALUE_TYPE_CONSTRAINT), and synced values that break one are kept and listed byGET /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 byGET /api/v2/shared-properties
- 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
- 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
| Setting | Default | Effect |
|---|---|---|
baseType or valueType | Inferred from the column | How the value is stored, validated, indexed and offered in filters |
description | Empty | Shown on hover, indexed for search and read by agents choosing which property answers a question |
required | false | A null fails indexing of that object and fails any action that would write null |
actionOnly | false | No backing column; values come only from actions |
derived | None | Computed at read time from linked objects or an expression; never stored |
status | The type's status | Draft, live or retiring; never higher than the type's |
priority | standard | Display priority: high properties lead the object page; hidden ones are left out of apps |
indexing | By base type | Full text, sort, aggregation, facets and others; see below |
format | By base type | Display formatting only; the stored value never changes |
sharedProperty | None | Inherit 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 type | Holds | Primary key | Query support |
|---|---|---|---|
| string | UTF-8 text | Yes | Exact, prefix, full text, fuzzy, regex when enabled |
| integer | 32-bit signed | Yes | Equality, ranges, aggregation |
| double | 64-bit floating point | No | Ranges, aggregation |
| boolean | True or false | Discouraged | Equality, counts |
| date | Calendar date with no time zone | Discouraged | Ranges, date buckets |
| timestamp | Instant in UTC, millisecond precision | Discouraged | Ranges, time buckets, relative filters |
| geopoint | Latitude and longitude, WGS 84 | No | Distance, bounding box, within shape |
| struct | Named, typed fields | No | Each field queryable on its own |
| array | A list of one base type | No | Contains, contains any, size |
| attachment, attachments | One 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) | No | The 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
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 type | Constraints | Example |
|---|---|---|
| string | values, a length range, a pattern matched against the whole value | Shop status, lot code |
| integer, double | values, a range | Temperature, percentage 0 to 100 |
| date, timestamp | A range | A best-before date within a season |
| boolean | values, to forbid one value | A flag that may only be set true |
| array | A length range | 1 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_rejectedand lists the first 50 inrejectionsonops.sync_runs, with the key and the reasonREQUIRED_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_PROPERTYbefore anything is committed, with every object and property listed inerrors
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
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)"
| Rule | Value |
|---|---|
| Link hops per derived property | 3 at most |
| Aggregations | count, sum, avg, min, max, approximate distinct, exact distinct, collect list, collect set |
| Collect list and collect set | 10 values by default, 100 at most |
| Single value without aggregation | Only when every hop is to one |
| Depends on another derived property | Not allowed |
| Primary key, title property, required, written by an action | Not allowed |
| Security | Computed 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
| Option | Effect | Default |
|---|---|---|
fullText | Indexed for full-text and fuzzy search; the master switch for the options below it | On for strings under 1 KB |
sort | Doc values kept for ordering | On for numbers, dates and short strings |
aggregatable | Available as a group-by and metric in aggregations | On for numbers, dates, booleans |
facet | Shown as a facet with value counts | Off |
exactMatch | Never grouped or range-filtered, even when numeric | On for primary keys |
multiline | Shown as a block in the object page; tokenized for search | Off |
tags | Shown as highlighted chips | Off |
regex | Allows whole-value regular expression filters | Off; adds index cost |
leadingWildcard | Allows *suffix searches | Off; 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 withcastEditsor drops them withdropEdits. 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