Facade & Service Patterns
The Ever Works platform uses the Facade pattern to provide pipeline steps and services with a unified interface to plugin capabilities. Each facade abstracts provider resolution, settings hierarchy, and enable checks behind a simple API, decoupling business logic from the specifics of which plugin is active.
Architecture Overview
BaseFacadeService
All facades extend BaseFacadeService, which provides common provider resolution and settings management:
abstract class BaseFacadeService {
protected abstract readonly CAPABILITY: string;
protected abstract readonly logger: Logger;
constructor(
protected readonly registry: PluginRegistryService,
protected readonly settingsService: PluginSettingsService | undefined,
protected readonly workPluginRepository?: WorkPluginRepository
) {}
}
Provider Resolution
The resolvePlugin<T>() method follows a four-level priority chain:
| Priority | Source | Description |
|---|---|---|
| 1 | providerOverride | Explicit provider ID from the request |
| 2 | Work default | Active provider set for the specific work |
| 3 | defaultForCapabilities | Plugin declaring itself as the default for a capability |
| 4 | First enabled | First loaded and enabled plugin with the required capability |
Settings Hierarchy
Plugin settings are resolved through a four-level hierarchy via PluginSettingsService:
| Level | Scope | Description |
|---|---|---|
| 1 | Work | Settings specific to a work |
| 2 | User | Settings specific to a user |
| 3 | Admin | Global admin-configured settings |
| 4 | Plugin defaults | Default values from the plugin's JSON Schema |
Setting Utilities
The base facade provides typed setting accessors:
| Method | Behavior |
|---|---|
getSettingTyped<T>(settings, key, type) | Returns typed value or undefined |
getSettingRequired<T>(settings, key, type) | Returns typed value or throws |
getSettingWithDefault<T>(settings, key, type, default) | Returns typed value or default |
Error Classes
| Error Class | Description |
|---|---|
FacadeError | Base error with operation name and provider context |
NoProviderError | No provider configured for the capability |
ProviderNotFoundError | Requested provider ID not found in registry |