Ontology
Functions
Read-only computations over objects.
A function is a small, read-only computation over ontology objects that you publish for reuse.
- A function is a sandboxed Python expression over the object reads it declares.
- It runs as the caller, so object visibility, property masking and policies apply to every read.
- Functions are versioned. You test a draft, publish a version, and retire old versions when they are no longer needed.
- Published functions appear as query types, so apps, actions, Logic and agents can call them.
| Method | Path | Does |
|---|---|---|
| GET, POST | /api/v2/ontologies/{ontology}/authored/functions | List or create |
| POST | …/authored/functions/{name}/test | Test a draft |
| POST | …/authored/functions/{name}/publish | Publish a version |
Read objects from code
A Python function, and a Python compute module that declares reads, can call an objects builtin to read more objects while it runs.
| Call | Returns |
|---|---|
objects.get(type, pk) | One object, as GET /api/v2/ontologies/{ontology}/objects/{type}/{pk} returns it |
objects.search(type, where, limit) | {data, totalCount} for at most limit objects (1 to 1,000, default 100). where uses the search grammar, or None |
objects.aggregate(type, aggregation) | The same answer as POST …/objects/{type}/aggregate |
- Every call runs as the caller, through the same read path as the matching API route. Object visibility, property masking, row policies, restricted views and markings apply. Filtering or aggregating on a masked property is refused.
- A call may only use the object types in
reads. It may only filter, group and aggregate on the properties those reads list. Objects come back with those properties and their$fields, and nothing else. - A refused call raises an error in your code. It never returns data. A run makes at most 8 calls, and the 5 second time limit covers the calls too.
- A read's own
whereandlimitonly shape the rows that are loaded before the code runs. They do not limit whatobjectsmay ask for.
A compute module declares reads in the same shape when you create or update it: "reads": [{"objectType": "Order", "properties": ["hasStatus"]}]. When it runs, every declared property must be readable for the caller (403 otherwise). A module without reads runs exactly as before, and has no objects. The sql runtime keeps its own restricted database login, which grants table access but does not apply the ontology's visibility and masking, so use a Python module with objects to read ontology objects.
TypeScript functions do not have objects yet. They get their declared reads as preloaded rows.