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

    Interface IResource<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>

    interface IResource<
        TConfig = void,
        TValue extends Promise<any> = Promise<any>,
        TDependencies extends DependencyMapType = any,
        TContext = any,
        TMeta extends IResourceMeta = any,
        TTags extends TagType[] = TagType[],
        TMiddleware extends
            ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[],
    > {
        "[symbolFilePath]": string;
        "[symbolForkedFrom]"?: ResourceForkInfo;
        "[symbolResource]": true;
        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;
        optional: () => IOptionalDependency<
            IResource<
                TConfig,
                TValue,
                TDependencies,
                TContext,
                TMeta,
                TTags,
                TMiddleware,
            >,
        >;
        overrides: OverridableElements[];
        register: RegisterableItems[]
        | ((config: TConfig) => RegisterableItems[]);
        resultSchema?: IValidationSchema<TValue extends Promise<U> ? U : TValue>;
        tags: TTags;
        throws?: readonly string[];
        fork(
            newId: string,
            options?: ResourceForkOptions,
        ): IResource<
            TConfig,
            TValue,
            TDependencies,
            TContext,
            TMeta,
            TTags,
            TMiddleware,
        >;
        with(
            config: HasInputContracts<[...TTags[], ...TMiddleware[]]> extends true
                ? IsUnspecified<TConfig> extends true
                    ? InferInputOrViolationFromContracts<[...TTags[], ...TMiddleware[]]>
                    : TConfig
                : TConfig,
        ): IResourceWithConfig<
            TConfig,
            TValue,
            TDependencies,
            TContext,
            TMeta,
            TTags,
            TMiddleware,
        >;
    }

    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.

    "[symbolForkedFrom]"?: ResourceForkInfo

    Present only on forked resources.

    "[symbolResource]": true
    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[]

    Items visible outside this resource's subtree. When set, only listed items can be referenced from outside.

    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.

    optional: () => IOptionalDependency<
        IResource<
            TConfig,
            TValue,
            TDependencies,
            TContext,
            TMeta,
            TTags,
            TMiddleware,
        >,
    >

    Return an optional dependency wrapper for this resource.

    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?: readonly string[]

    Normalized list of error ids declared via throws.

    Methods