Server Functions (CLI)
Declare server functions in SQL with CREATE FUNCTION or CREATE PROCEDURE, implement them as project TypeScript (or inline JavaScript), then let the CLI generate, build, and activate the module.
The SQL contract, CALL, HTTP /v1/functions, topic triggers, and schedules are documented in Server Functions. This page is the CLI lifecycle.
Schema-first loop
- Add a bodyless
CREATE FUNCTIONorCREATE PROCEDURE(and anyCREATE TYPEit needs) to your schema file. - Run
kalam schema gen(or letkalam devdo it). - Implement
functions/src/<schema>/<procedure>.ts. - Activate with
kalam devorkalam deploy.
kalam schema gen writes procedure.<schema>.<method>(handler) builders and a one-time named-export scaffold for each unbound procedure. Existing implementations are preserved. Do not hand-edit functions/src/generated/.
.unimplemented() scaffolds typecheck and build but are omitted from the compiled registry. CALL fails with procedure not implemented until a real handler is activated.
kalam dev
After the schema pipeline, kalam dev builds functions/ and activates the project module (same activation as kalam deploy). Failures print as errors; they do not stop the app process. Watched edits to functions/src rebuild and reactivate.
Use matching CLI and server versions. Function deployment includes SQL and JavaScript activation; check both when a call fails.
See Local Development.
kalam deploy
kalam deploy generates schema artifacts, builds the project’s server functions, applies migrations, activates the function module, and checks target health.
Deployment does not publish or start frontend, mobile, or service applications; use your application rollout process. See the complete schema evolution lifecycle.
The dry run does not apply migrations, upload functions, or activate a revision. Production-like environments still require sealed migrations when automatic migrations are enabled.
kalam functions
Build and inspect independently of a full deploy:
| Command | Purpose |
|---|---|
build | Compile functions/ without activating |
status | Current module, every procedure (implementation + signature), isolate stats |
revisions | Module history with is_current |
runtime | Resident V8 isolates and in-flight root calls |
logs | Recent invocation, console / ctx.log, and error records from system.procedure_logs |
override | Operator override for a procedure |
rollback | Activate a previous revision without rebuilding |
Rollback identifiers come from kalam functions revisions. Rollback does not undo schema migrations.
On disk, invocation logs live under {data_path}/functions/runtime/<procedure_id>/logs/ (default ./data/functions/runtime/...). Compiled module bytes live under {data_path}/functions/artifacts/.