SERVER / STANDARD LIBRARY

Compose portable server values

The standard library gives reusable server functions small, deterministic operations for parsing, sorting, formatting, and numeric work. Each declaration names a capability, a source function, and the named props that it needs.

1 / MENTAL MODEL

Declare a capability-first value

The binding is the value exposed to later statements. source selects one function in the namespace, and every other prop is named. There is no assignment operator, callback, or dynamic code.

dowe
parse parsed source:"json" value:args.payload fallback:[]
sort sorted source:"asc" values:parsed
math total source:"sum" values:sorted
Part
How to read it

No data

There are no records to display

2 / FN + HANDLER FLOW

Keep algorithms reusable and HTTP at the edge

A reusable fn transforms data and returns value. The handler imports it, passes named args, and owns the HTTP response. This keeps parsing, sorting, and aggregation out of route wiring.

server/functions/scores.dowe

dowe
fn summarizeScores params:{ payload:string }
  parse parsed source:"json" value:args.payload fallback:[]
  sort sorted source:"asc" values:parsed
  math total source:"sum" values:sorted
  return value:{ total:total sorted:sorted }

server/handlers/scores.dowe

dowe
import summarizeScores from "@/server/functions/scores"

handler summarize
  const body value:req.json
  summarizeScores result args:{ payload:body.payload }
  return json:result
Boundary
What it means

No data

There are no records to display

3 / IMPLEMENTED CATALOG

Use only the canonical functions

The namespace and source names below are implemented today. Unknown functions and props are rejected during compilation. The optional ? marks an optional argument.

Namespace
Available functions

No data

There are no records to display

4 / DETAILS

Know the predictable edge cases

The declarations are intentionally finite. Read the result rules below before using a parser or aggregate in a handler.

math

All math values are finite numbers. sum([]) is 0. average([]), min([]), and max([]) are null. Division by zero and non-finite results are controlled runtime results.

dowe
math total source:"sum" values:[1 2 3]
math mean source:"average" values:body.scores

parse

int rejects decimal text, float accepts finite text, bool accepts the documented boolean spellings, and json returns a JSON value. Every parser returns fallback or null instead of throwing into the handler.

dowe
parse page source:"int" value:req.params.page fallback:1
parse filters source:"json" value:body.filters fallback:[]
parse icon source:"svg" value:body.icon fallback:""

sort

asc and desc compare values stably. by reads a dotted field, accepts direction asc or desc, and places missing values first or last with nulls.

dowe
sort newest source:"by" values:body.items field:"createdAt" direction:"desc" nulls:"last"
The implemented contract is defined by /specs/features/00068-add-portable-standard-library and /specs/features/00131-canonicalize-server-values-and-returns. This page documents the server subset; it does not add functions beyond the shared catalog.