Class BehaviourBase<TName, TKosmosConfig, TInstanceConfig>Abstract

The base Behaviour class.

Mermaid

Behaviour life cycle / configuration flow

%%{init:{"theme":"dark"}}%% sequenceDiagram actor User participant IoC participant Kosmos config participant GraphQL participant BehaviourTrait participant Behaviour participant BehaviourInstanceManager IoC->>Kosmos config: Reads config Kosmos config->>IoC: List of available Behaviours and their Kosmos configs loop All available behaviours Note over IoC,Behaviour: Configurations are tenant and content type agnostic IoC->>Behaviour: Instantiate and pass in KosmosConfig end loop Handling requests User->>GraphQL: GraphQL query calling Behaviour GraphQL->>BehaviourTrait: Calls Behaviour wrapper BehaviourTrait->>BehaviourInstanceManager: Retrieve Behaviour instance config opt Missing config/instance BehaviourInstanceManager->>BehaviourTrait: Error BehaviourTrait->>GraphQL: Error GraphQL->>User: Error end BehaviourInstanceManager->>BehaviourTrait: Behaviour instance config BehaviourTrait->>Behaviour: Executes resolver, passing in context, args and instance config Behaviour->>BehaviourTrait: Response BehaviourTrait->>GraphQL: Response GraphQL->>User: Response end
%%{init:{"theme":"default"}}%% sequenceDiagram actor User participant IoC participant Kosmos config participant GraphQL participant BehaviourTrait participant Behaviour participant BehaviourInstanceManager IoC->>Kosmos config: Reads config Kosmos config->>IoC: List of available Behaviours and their Kosmos configs loop All available behaviours Note over IoC,Behaviour: Configurations are tenant and content type agnostic IoC->>Behaviour: Instantiate and pass in KosmosConfig end loop Handling requests User->>GraphQL: GraphQL query calling Behaviour GraphQL->>BehaviourTrait: Calls Behaviour wrapper BehaviourTrait->>BehaviourInstanceManager: Retrieve Behaviour instance config opt Missing config/instance BehaviourInstanceManager->>BehaviourTrait: Error BehaviourTrait->>GraphQL: Error GraphQL->>User: Error end BehaviourInstanceManager->>BehaviourTrait: Behaviour instance config BehaviourTrait->>Behaviour: Executes resolver, passing in context, args and instance config Behaviour->>BehaviourTrait: Response BehaviourTrait->>GraphQL: Response GraphQL->>User: Response end
sequenceDiagram
    actor User
    participant IoC
    participant Kosmos config
    participant GraphQL
    participant BehaviourTrait
    participant Behaviour
    participant BehaviourInstanceManager
    IoC->>Kosmos config: Reads config
    Kosmos config->>IoC: List of available Behaviours and their Kosmos configs
    loop All available behaviours
        Note over IoC,Behaviour: Configurations are tenant and content type agnostic
        IoC->>Behaviour: Instantiate and pass in KosmosConfig
    end
    loop Handling requests
        User->>GraphQL: GraphQL query calling Behaviour
        GraphQL->>BehaviourTrait: Calls Behaviour wrapper
        BehaviourTrait->>BehaviourInstanceManager: Retrieve Behaviour instance config
        opt Missing config/instance
            BehaviourInstanceManager->>BehaviourTrait: Error
            BehaviourTrait->>GraphQL: Error
            GraphQL->>User: Error
        end
        BehaviourInstanceManager->>BehaviourTrait: Behaviour instance config
        BehaviourTrait->>Behaviour: Executes resolver, passing in context, args and instance config
        Behaviour->>BehaviourTrait: Response
        BehaviourTrait->>GraphQL: Response
        GraphQL->>User: Response
    end

Type Parameters

Hierarchy

Constructors

Properties

_kosmosConfig?: TKosmosConfig

Accessors

Methods

  • This method would be automatically before the first invocation of Behaviour for each entity type.

    Behaviours may override this method, and it would be called once before each resolver.

    Parameters

    • __namedParameters: RuntimeInitParameters<TName, TInstanceConfig>

    Returns Promise<void>

  • Validates runtime (e.g. ContentItem) configuration for this Behaviour.

    Inherited classes may either return false for generic issues or throw BehaviourRuntimeError to return a specific error message.

    Parameters

    • config: InstanceConfig<any>

      The instance configuration value to check.

    Returns config is TInstanceConfig

  • Validates Kosmos (e.g. build time) configuration for this Behaviour.

    Inherited classes may either return false for generic issues or throw BehaviourConfigError to return a specific error message.

    Parameters

    • config: KosmosConfig<any>

      The Kosmos configuration value to check.

    Returns config is TKosmosConfig

Generated using TypeDoc