@bluelibs/runner - v6.3.1
    Preparing search index...

    Interface IResourceDefinition<TConfig, TValue, TDependencies, TContext, _THooks, _TRegisterableItems, TMeta, TTags, TMiddleware>

    Declarative resource definition contract.

    Resources own lifecycle, subtree registration, and isolation boundaries.

    interface IResourceDefinition<
        TConfig = any,
        TValue extends Promise<any> = Promise<any>,
        TDependencies extends DependencyMapType = {},
        TContext = any,
        _THooks = any,
        _TRegisterableItems = any,
        TMeta extends IResourceMeta = any,
        TTags extends ResourceTagType[] = ResourceTagType[],
        TMiddleware extends
            ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[],
    > {
        "[symbolFilePath]"?: string;
        "[symbolResourceIsolateDeclarations]"?: readonly IsolationPolicyDeclaration<
            TConfig,
        >[];
        "[symbolResourceSubtreeDeclarations]"?: readonly ResourceSubtreePolicyDeclaration<
            TConfig,
        >[];
        configSchema?: ValidationSchemaInput<TConfig>;
        context?: () => TContext;
        cooldown?: (
            this: unknown,
            value: TValue extends Promise<U> ? U : TValue,
            config: TConfig,
            dependencies: ResourceDependencyValuesType<TDependencies>,
            context: TContext,
        ) => Promise<void | ResourceCooldownAdmissionTargets>;
        dependencies?:
            | TDependencies
            | ((config: TConfig, mode: RunnerMode) => TDependencies);
        dispose?: (
            this: unknown,
            value: TValue extends Promise<U> ? U : TValue,
            config: TConfig,
            dependencies: ResourceDependencyValuesType<TDependencies>,
            context: TContext,
        ) => Promise<void>;
        health?: (
            this: unknown,
            value: (TValue extends Promise<U> ? U : TValue) | undefined,
            config: TConfig,
            dependencies: ResourceDependencyValuesType<TDependencies>,
            context: TContext,
        ) => Promise<IResourceHealthResult>;
        id: string;
        init?: (
            config: HasInputContracts<[...TTags[], ...TMiddleware[]]> extends true
                ? IsUnspecified<TConfig> extends true
                    ? InferInputOrViolationFromContracts<[...TTags[], ...TMiddleware[]]>
                    : EnsureInputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TConfig>
                : TConfig,
            dependencies: ResourceDependencyValuesType<TDependencies>,
            context: TContext,
        ) => HasOutputContracts<[...TTags[], ...TMiddleware[]]> extends true
            ? EnsureOutputSatisfiesContracts<
                [...TTags[], ...TMiddleware[]],
                TValue,
            >
            : TValue;
        isolate?: IsolationPolicyInput<TConfig>;
        meta?: TMeta;
        middleware?: TMiddleware;
        overrides?:
            | OverridableElements[]
            | ((config: TConfig, mode: RunnerMode) => OverridableElements[]);
        ready?: (
            this: unknown,
            value: TValue extends Promise<U> ? U : TValue,
            config: TConfig,
            dependencies: ResourceDependencyValuesType<TDependencies>,
            context: TContext,
        ) => Promise<void>;
        register?:
            | RegisterableItem[]
            | ((config: TConfig, mode: RunnerMode) => RegisterableItem[]);
        resultSchema?: ValidationSchemaInput<
            TValue extends Promise<U> ? U : TValue,
        >;
        subtree?:
            | ResourceSubtreePolicyInput<TConfig>
            | DisplayResourceSubtreePolicy<TConfig>;
        tags?: TTags;
        throws?: ThrowsList;
    }

    Type Parameters

    Index

    Properties

    "[symbolFilePath]"?: string

    This is optional and used from an index resource to get the correct caller. This is the reason we allow it here as well.

    "[symbolResourceIsolateDeclarations]"?: readonly IsolationPolicyDeclaration<
        TConfig,
    >[]

    Ordered isolate declarations preserved across builder composition.

    "[symbolResourceSubtreeDeclarations]"?: readonly ResourceSubtreePolicyDeclaration<
        TConfig,
    >[]

    Ordered subtree declarations preserved across builder composition.

    Optional validation schema for runtime config validation. When provided, resource config will be validated when .with() is called.

    context?: () => TContext

    Create a private, mutable context shared between init, ready, cooldown, and dispose.

    cooldown?: (
        this: unknown,
        value: TValue extends Promise<U> ? U : TValue,
        config: TConfig,
        dependencies: ResourceDependencyValuesType<TDependencies>,
        context: TContext,
    ) => Promise<void | ResourceCooldownAdmissionTargets>

    Cooldown hook for the resource. This runs during shutdown to stop intake quickly before runtime drains in-flight business work.

    Keep this fast and non-blocking in intent: trigger ingress stop, capture handles/promises in context, and return promptly. The cooling resource is always allowed as a resource-origin source during the later drain window. Returning additional resource definitions extends that shutdown allowlist.

    dependencies?:
        | TDependencies
        | ((config: TConfig, mode: RunnerMode) => TDependencies)

    Static or lazy dependency map. Receives config when provided.

    dispose?: (
        this: unknown,
        value: TValue extends Promise<U> ? U : TValue,
        config: TConfig,
        dependencies: ResourceDependencyValuesType<TDependencies>,
        context: TContext,
    ) => Promise<void>

    Clean-up function for the resource. This is called when the resource is no longer needed.

    Type Declaration

    health?: (
        this: unknown,
        value: (TValue extends Promise<U> ? U : TValue) | undefined,
        config: TConfig,
        dependencies: ResourceDependencyValuesType<TDependencies>,
        context: TContext,
    ) => Promise<IResourceHealthResult>

    Optional async health probe for this resource.

    Resources without health are excluded from runtime health reports.

    id: string

    Stable identifier.

    init?: (
        config: HasInputContracts<[...TTags[], ...TMiddleware[]]> extends true
            ? IsUnspecified<TConfig> extends true
                ? InferInputOrViolationFromContracts<[...TTags[], ...TMiddleware[]]>
                : EnsureInputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TConfig>
            : TConfig,
        dependencies: ResourceDependencyValuesType<TDependencies>,
        context: TContext,
    ) => HasOutputContracts<[...TTags[], ...TMiddleware[]]> extends true
        ? EnsureOutputSatisfiesContracts<[...TTags[], ...TMiddleware[]], TValue>
        : TValue

    Initialize and return the resource value. Called once during boot.

    Isolates this resource boundary, restricting which external definitions can be referenced by this resource and its subtree.

    Why: this provides a fail-fast dependency boundary that prevents accidental cross-module wiring, even when visibility rules would otherwise allow it.

    meta?: TMeta

    Optional metadata used by docs and tooling.

    middleware?: TMiddleware

    Middleware applied around resource creation.

    This affects how initialization is performed and what value the resource resolves to. It does not wrap ready(), cooldown(), or dispose(), so shutdown behavior should still be modeled with lifecycle hooks.

    overrides?:
        | OverridableElements[]
        | ((config: TConfig, mode: RunnerMode) => OverridableElements[])

    Safe overrides to swap behavior while preserving identities. See README: Overrides.

    ready?: (
        this: unknown,
        value: TValue extends Promise<U> ? U : TValue,
        config: TConfig,
        dependencies: ResourceDependencyValuesType<TDependencies>,
        context: TContext,
    ) => Promise<void>

    Ready hook for the resource. This runs after initialization completes and right before Runner emits the global system ready event.

    Use this for startup ingress actions that should begin only after runtime internals are locked and all startup-initialized dependencies are ready.

    register?:
        | RegisterableItem[]
        | ((config: TConfig, mode: RunnerMode) => RegisterableItem[])

    Register other registerables (resources/tasks/middleware/events). Accepts a static array or a function of config to support dynamic wiring.

    resultSchema?: ValidationSchemaInput<TValue extends Promise<U> ? U : TValue>

    Optional validation schema for the resource's resolved value. When provided, the value will be validated immediately after init resolves, without considering middleware.

    Declares subtree policies for tasks/resources registered under this resource.

    tags?: TTags

    Tags attached to this resource definition.

    throws?: ThrowsList

    Declares which typed errors are part of this resource's contract.

    This is a declarative contract only:

    • It does not imply dependency injection
    • It does not enforce that only these errors can be thrown

    Use Runner error helpers only.