Bosca / Scripts

Authoring

Write Kotlin, not a DSL

A script isn't a string of expressions in a box — it's real Kotlin, with a context handed to it and the platform's own services a call away. If you can write it in Kotlin, you can run it here.

The context

Everything a run needs, handed to it

When a script runs, it's given a context: the input it was called with, who called it, a scope to launch async work in, and a logger. No global reaching around — what a run needs is right there.

  • Read the call's input as typed JSON.
  • Act as the caller, with exactly their permissions.
  • Launch coroutines on the provided scope, and log as you go.
context
inputThe typed JSON payload the script was called with.
authenticationThe caller's identity and permissions.
scopeA coroutine scope for async work.
logA structured logger for output.

Typed service access

The platform's services, one call away

Scripts reach platform services the same way the platform reaches them itself — asked for by type. Content, collections, metadata, and search are there to call directly, fully typed, no HTTP hop in between.

  • Ask for a service by its type and get a real, typed instance.
  • Content, collection, metadata, and search services come pre-imported.
  • It's an in-process call, not a round-trip through the API.
services
val content = provide<MetadataService>()
val collections = provide<CollectionService>()

val item = content.getById(id)
log.info("loaded ${item.name}")

Validated & compiled

Checked before it ever runs

Nothing runs unseen. The source is validated for dangerous calls, then compiled to bytecode — any error shows up now, not in production. The compiled result is cached, so the second run doesn't pay the compile cost again.

  • Source validation rejects unsafe system calls up front.
  • Compilation surfaces errors before the script is used.
  • Compiled scripts are cached in memory and the database.
validate
source check · no blocked calls
compiles to bytecode
cached · next run is instant

Keep exploring

More on Scripts