Function
Public-facing function definitions and decorators
A Function is a public-facing callable definition that exposes a RuntimeFunction to the Code0 platform. It
carries display metadata without containing any implementation logic.
import { /* decorators */ } from '@code0-tech/hercules';Overview
Functions and RuntimeFunctions are always paired. The RuntimeFunction holds the run() method; the Function
extends it and adds metadata for the platform UI.
// Runtime layer — implementation
@Identifier('fibonacci_runtime')
@Signature('(n: number): number')
@OmitRuntimeFunction()
export class FibonacciRuntimeFunction {
run(context: FunctionContext, n: number): number { ... }
}
// Public layer — metadata only
@Identifier('fibonacci')
@Name({ code: 'en-US', content: 'Compute Fibonacci' })
@Parameter({ runtimeName: 'n', name: [{ code: 'en-US', content: 'N' }] })
export class FibonacciFunction extends FibonacciRuntimeFunction {}Register both with the Action:
action.registerRuntimeFunction(FibonacciRuntimeFunction);
action.registerFunction(FibonacciFunction);The resulting descriptor stored in action.functions is documented on the FunctionManager
page.
FunctionClass
type FunctionClass<T extends RuntimeFunctionClass> = new () => InstanceType<T>;The constructor type used when calling action.registerFunction().
Decorators
| Decorator | Description |
|---|---|
@Identifier | Sets the unique runtime identifier |
@Name | Sets the localised display name |
@Description | Sets a short localised description |
@Documentation | Sets long-form documentation text |
@DisplayMessage | Sets the summary text shown in the flow UI |
@Alias | Sets alternative search terms |
@DeprecationMessage | Marks the function as deprecated |
@Signature | Sets the TypeScript-like signature string |
@DisplayIcon | Sets the icon shown in the flow UI |
@Editable | Controls editability in the platform UI |
@Parameter | Adds a parameter definition |
@Design | Attaches a visual design token |
@ThrowsError | Marks the function as capable of throwing a RuntimeError |
@OmitFunction | Prevents auto-generation of a public function definition |