Code0 LogoCodeZero

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

DecoratorDescription
@IdentifierSets the unique runtime identifier
@NameSets the localised display name
@DescriptionSets a short localised description
@DocumentationSets long-form documentation text
@DisplayMessageSets the summary text shown in the flow UI
@AliasSets alternative search terms
@DeprecationMessageMarks the function as deprecated
@SignatureSets the TypeScript-like signature string
@DisplayIconSets the icon shown in the flow UI
@EditableControls editability in the platform UI
@ParameterAdds a parameter definition
@DesignAttaches a visual design token
@ThrowsErrorMarks the function as capable of throwing a RuntimeError
@OmitFunctionPrevents auto-generation of a public function definition

On this page