Advanced

Foundry Functions

Module Summary

Write TypeScript functions that query and compute over the Ontology — the logic layer for applications and automations.

What Are Foundry Functions?

Foundry Functions are TypeScript functions that run on the platform and have first-class access to the Ontology. You can query Object Types, traverse Links, aggregate Properties, and return computed results — all with type safety and auto-completion. Functions are hosted in Function Repositories (similar to Code Repositories) and are versioned and testable.

Querying the Ontology

A simple Function might look like:
@Function()
public getActiveEmployeesInCity(city: string): ObjectSet<Employee> {
    return Objects.search().employee()
        .filter(e => e.city.exactMatch(city))
        .filter(e => e.status.exactMatch("active"));
}
This returns a live ObjectSet that Workshop widgets can render — tables, charts, maps, and more. Functions can also return scalars, arrays, or structs for computed metrics.

Functions in Applications

Functions power: - Workshop widgets — data sources for tables, charts, KPIs. - Action validations — custom rules that run before an action executes. - Automations — triggered computations that run on a schedule or event. - External APIs — exposed via Foundry's API gateway for third-party consumption. Because Functions read from the Ontology, they always return fresh data without manual refresh logic.

Key Takeaways

  • Functions are TypeScript code with first-class Ontology access.
  • They query Object Types, traverse Links, and return computed results.
  • Functions power Workshop widgets, Action validations, and automations.
  • Type safety and auto-completion make development fast and reliable.