@causa/workspace v0.12.1
Causa Workspace package
This is the repository for the @causa/workspace
npm package. The main way to access Causa workspace functionalities is through the Causa CLI. For more information about CLI features and how to configure a Causa workspace, look at the CLI documentation.
This document is addressed to Causa module developers, who need more information about the internals of the Causa workspace API.
Configuration
The configuration
folder exposes the ConfigurationReader
, which implements a generic way of loading a YAML / JSON configuration from several files. It also provides a rendering API, to format configuration values from other configuration values and using custom functions.
Workspace context
The context
folder exposes the main part of the workspace API, namely the WorkspaceContext
. It is the entrypoint for most workspace operations, as it initializes the configuration and function registry, and loads the Causa modules.
Function registry
The function-registry
folder exposes the FunctionRegistry
, which is how function definitions and implementations are registered, as well as called. The FunctionRegistry
is parameterized with a context object, which for WorkspaceContext.functionRegistry
is the WorkspaceContext
itself.
Initialization
The initialization
folder exposes utilities to initialize an existing workspace, i.e. install the required modules in the Causa folder (.causa
).
Service cache
The service-cache
exposes the simple ServiceCache
, allowing to register singleton services within a WorkspaceContext
.
Testing
The testing
folder exposes testing utilities.
The createContext
function allows creating a WorkspaceContext
without loading a configuration from the disk. This is useful when "mocking" a context to test a workspace function.
The registerMockFunction
registers a mock implementation of the given workspace function definition, returning a spy that can be used to assert calls made to the function.