The parameters for the kosDependency decorator.

interface KosDependencyParams<Options> {
    modelType: string;
    id?: string;
    options?: Options;
    lifecycle?: DependencyLifecycle;
    resolutionPolicy?: DependencyResolutionPolicy;
}

Type Parameters

  • Options = unknown

Properties

modelType: string

The type of the model to be injected.

id?: string

The id of the model to be injected.

options?: Options

The options to be passed to the model constructor.

lifecycle?: DependencyLifecycle

The lifecycle at which the dependency should be injected.

resolutionPolicy?: DependencyResolutionPolicy

Policy for handling dependency resolution failures.

All policies first attempt to look up an existing model instance. If found and the type matches, the existing instance is returned. Only if lookup fails does the policy apply:

  • CREATE (default): Attempts to create model instance after lookup fails
  • CONTINUE: Returns undefined after lookup fails, allows graceful degradation
  • FAIL: Throws exception with detailed logging after lookup fails