Source: openaf 06414cd9. See documentation baseline for availability and verification.

This page is curated against the implementation to correct discrepancies in the upstream prose.

OpenAF core guide

This guide connects the core APIs to their detailed references and runnable examples. It follows the pinned source baseline; inspect installed help when using an older runtime.

Core Helper Functions

$$ - Enhanced Object Inspection

var user = { name: "Ana", address: { city: "Lisbon" } };
print($$(user).get("address.city"));
$$(user).set("address.country", "PT");
print($$(user).isMap());

get() returns the value at the path. getI() performs case-insensitive lookup. Use a fresh wrapper for independent operations. See Sigil helpers and the source API reference.

_$ - Parameter Validation

var port = _$("8080", "port").toNumber()
  .check(v => isNumber(v) && isFinite(v) && Math.floor(v) === v && v >= 1 && v <= 65535)
  .$_();
var label = _$(undefined, "label").isString().default("untitled");

Conversions return a builder; .$_() and .default(...) return the final value. Use one combined predicate when all rules must hold. The source has compatibility quirks in chaining and some helpers; follow the validation guide. Methods such as inRange, isEmail, minLength and hasKeys are not available on this builder.

OpenWrap Extensions

Load wrapper modules explicitly before using them. The table links directly to source-generated API entries.

Module Loader Detailed reference
Formatting ow.loadFormat() ow.format
Objects and HTTP ow.loadObj() ow.obj
Channels ow.loadCh() ow.ch
AI providers ow.loadAI() ow.ai
Network ow.loadNet() ow.net
Java utilities ow.loadJava() ow.java
Server utilities ow.loadServer() ow.server
Templates ow.loadTemplate() ow.template
Tests ow.loadTest() ow.test
Metrics ow.loadMetrics() ow.metrics

ow.format - Formatting Utilities

ow.loadFormat();
print(ow.format.toBytesAbbreviation(1048576));
print(ow.format.fromDate(new Date(), "yyyy-MM-dd HH:mm:ss"));

For terminal capabilities, colors and widgets see CLI behavior, console usage, and desktop and terminal views.

ow.obj - Object Utilities and REST Client

var result = $rest({ throwExceptions: true, timeout: 5000 })
  .get("https://api.example.com/items");
print(result);

The endpoint is a placeholder. $rest returns the decoded body; do not chain response-wrapper methods on it. Use the lower-level HTTP API when you need transport details.

ow.ch - Channels

$ch("example").create();
try {
  $ch("example").set({ id: 1 }, { id: 1, name: "Ana" });
  print($ch("example").get({ id: 1 }));
} finally {
  $ch("example").destroy();
}

Channel types control persistence and backend behavior. Subscribers run asynchronously; use waitForJobs() where completion matters. See channel concepts and optional backends.

Graph channels

Use the graph type for nodes and edges, with file or backing-channel storage. Navigation helpers provide neighbors, traversal and shortest paths. See graph channels for key formats, edge identity, saves and read-only behavior.

Time-series channels

Use timeseries for labelled numeric samples, retention, rollups and OpenMetrics integration. See time-series channels for timestamp rules, selectors and storage options.

ow.ai - AI APIs

Use $llm or the documented provider interfaces. Configure the provider, model and credentials for your account; model availability is not guaranteed by a source revision. See LLM concepts, provider APIs, decision contracts, schema hooks, and MCP servers.

nLinq - Query Processing

var people = [{ name: "Ana", age: 31 }, { name: "Rui", age: 17 }];
var adults = $from(people).greaterEquals("age", 18).sort("name").select();
print(adults);

$from queries in-memory collections. Do not assume that a fluent query creates a bounded-memory stream. Use oafp’s documented streaming inputs for record processing. See nLinq concepts.

Security Features

Use the secret-store API and your configured repository/bucket for credentials. OpenAF is not Node.js: read environment variables with getEnv, not process.env. Review oJob security and the JDBC URL policy when accepting configuration or SQL connection options from callers.

Server Management

The core HTTP server plugin is HTTPServer. Server helpers wrap routing, responses and request handling. oJob-common HTTP and REST modules provide reusable jobs, including file browsing and health/metrics endpoints.

Template Engine

print($t("Hello {{name}}", { name: "Ana" }));

$t expands Handlebars templates from a context map. Follow the templating cheat sheet for helpers and escaping, and SQL template examples for a larger application.

Testing Framework

ow.loadTest();
ow.test.assert(2 + 2, 4, "arithmetic");

Test failure paths as well as successful output. The authoring testing guide and testing reference cover fixtures, assertions, reports and integration boundaries.

Python Integration

Follow the Python integration guide for subprocess execution, input/output variables, server mode and CLI entry points. Python must be available in the environment where the script runs. Starting a Python server or an external process introduces resource ownership; shut it down in cleanup code.

Parsing Utilities

var config = af.fromYAML("name: Ana\ncount: 2\n");
print(af.toYAML(config));
print(af.toSLON(config));

See JSON and YAML file I/O, JSON extraction, JSON Schema, and the core reference.

Data Formats and Streams

Streams, strings and byte arrays have different lifetimes and types. Close streams you open, and use byte conversion methods for binary plugin APIs. ZIP, HTTP, and oafp format options document their input contracts. TOON is a structured-data notation; af.toTOON / af.fromTOON encode and decode it.

Data Validation

Use JSON Schema for structural constraints and parameter validation for explicit JavaScript predicates. A schema, example, or model output is not by itself a validation step: invoke the validator and handle failures.

Additional Core Shortcuts & Utilities

The dollar-function guide covers $sh, $rest, $job, $do, $sec, $output and related helpers. The scope reference contains the extracted signatures. Prefer syncFn when the synchronized callback’s return value is needed; sync does not forward that value.

Metrics API (ow.metrics)

ow.metrics.add(name, callback) registers a callback, and getSome([names]) returns a map of collected values. See metrics collection for counters, channel collection and strict OpenMetrics output, and OpenTelemetry for export integrations.

$path – JMESPath Inspired Query & Transform

var names = $path({ users: [{ name: "Ana" }, { name: "Rui" }] }, "users[].name");
print(names);

See the scope reference for supported functions and options. In oafp, input, main and output query stages have different positions in the pipeline; see processor concepts.

Terminal Visualization & Live Dashboards

Use console and terminal APIs, desktop windows, and oafp charts. Interactive examples depend on terminal capabilities or GUI providers and cannot be established by a headless build alone.

Additional ow.* Highlights

See instrumentation, Java path integration, ODoc, JQ, and package management. Optional integrations are indexed in the oPack catalog.

Putting It Together: Authoring a New oJob from Scratch

Start with script-to-oJob authoring, choose a recipe from the authoring examples, and use the YAML reference for lifecycle and argument behavior. Keep external effects in explicit jobs and test them with suitable fixtures.


This site uses Just the Docs, a documentation theme for Jekyll.