The NocoBase FlowEngine's context system is divided into three layers, each corresponding to a different scope. Proper use can achieve flexible sharing and isolation of services, configurations, and data, improving business maintainability and scalability.
mode: 'runtime' | 'settings', corresponding to runtime mode and settings mode respectively.All FlowEngineContext (Global Context), FlowModelContext (Model Context), and FlowRuntimeContext (Flow Runtime Context) are subclasses or instances of FlowContext.
FlowModelContext can access the properties and methods of FlowEngineContext through a delegate mechanism, enabling the sharing of global capabilities.FlowModelContext can access the parent model's context (synchronous relationship) through a delegate mechanism, supporting same-name overrides.FlowRuntimeContext always accesses its corresponding FlowModelContext through a delegate mechanism, but it does not propagate changes upwards.FlowRuntimeContext supports two modes, distinguished by the mode parameter:
mode: 'runtime' (Runtime mode): Used during the actual execution phase of the flow. Properties and methods return real data. For example:
mode: 'settings' (Settings mode): Used during the flow design and configuration phase. Property access returns a variable template string, facilitating expression and variable selection. For example:
This dual-mode design ensures data availability at runtime and facilitates variable referencing and expression generation during configuration, enhancing the flexibility and usability of the FlowEngine.
In certain scenarios (such as RunJS code editing in JS*Model or AI coding), the "caller" needs to understand the following without executing the code:
ctx (API documentation, parameters, examples, documentation links, etc.).await ctx.getApiInfos(options?) (Static API Information)await ctx.getVarInfos(options?) (Variable Structure Information)defineProperty(...).meta (including meta factory).path clipping and maxDepth depth control.Common parameters:
maxDepth: Maximum expansion depth (default is 3).path: string | string[]: Clipping, only outputs the specified path subtree.await ctx.getEnvInfos() (Runtime Environment Snapshot)Node structure (simplified):