@bluelibs/runner - v5.5.0
    Preparing search index...

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

    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 TagType[] = TagType[],
        TMiddleware extends
            ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[],
    > {
        "[symbolFilePath]"?: string;
        configSchema?: IValidationSchema<TConfig>;
        context?: () => TContext;
        dependencies?: TDependencies | ((config: TConfig) => TDependencies);
        dispose?: (
            this: unknown,
            value: TValue extends Promise<U> ? U : TValue,
            config: TConfig,
            dependencies: ResourceDependencyValuesType<TDependencies>,
            context: TContext,
        ) => Promise<void>;
        exports?: RegisterableItems[];
        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;
        meta?: TMeta;
        middleware?: TMiddleware;
        overrides?: OverridableElements[];
        register?: RegisterableItems[] | ((config: TConfig) => RegisterableItems[]);
        resultSchema?: IValidationSchema<TValue extends Promise<U> ? U : TValue>;
        tags?: TTags;
        throws?: ThrowsList;
    }

    Type Parameters

    Hierarchy (View Summary)

    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.

    configSchema?: IValidationSchema<TConfig>

    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 and dispose.

    dependencies?: TDependencies | ((config: TConfig) => 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

    exports?: RegisterableItems[]

    Declares which registered items are visible outside this resource's registration subtree. When present, only listed items (and items registered by child resources that also export them) are accessible from outside. Omitting exports means everything is public (default).

    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.

    meta?: TMeta
    middleware?: TMiddleware

    Middleware applied around init/dispose.

    overrides?: OverridableElements[]

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

    register?: RegisterableItems[] | ((config: TConfig) => RegisterableItems[])

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

    resultSchema?: IValidationSchema<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.

    tags?: TTags
    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 string ids or Error helpers.