@e-mc/task

Interface

import type { IFileManager, IHost, ModuleConstructor } from "./index";
import type { ExternalAsset, IFileThread } from "./asset";
import type { ClientConstructor, IClient } from "./core";
import type { TaskModule } from "./settings";
import type { Command, SpawnResult } from "./task";

interface ITask extends IClient<IHost, TaskModule> {
    using?(data: IFileThread): Promise<unknown>;
    collect?(items: unknown[], preceding?: boolean): Promise<SpawnResult>[];
    map?(tasks: Command[]): Promise<SpawnResult | void>[];
    series?(tasks: Command[]): Promise<unknown>;
    parallel?(tasks: Command[]): Promise<unknown>;
    spawn?(task: PlainObject, callback: (result?: SpawnResult) => void): void;
    execute?(manager: IFileManager, task: PlainObject, callback: (value?: unknown) => void): void;
}

interface TaskConstructor extends ClientConstructor {
    finalize(this: IHost, instance: ITask, assets: ExternalAsset[]): Promise<void>;
    readonly prototype: ITask;
    new(module?: TaskModule, ...args: unknown[]): ITask;
}

Changelog

Changed in version 0.10.0:

  • TaskConstructor function finalize return value was changed to Promise<void>.

Settings

import type { PermittedDirectories } from "./core";

interface TaskModule {
    // handler: "@pi-r/gulp";
    settings?: {
        broadcast_id?: string | string[];
        users?: Record<string, Record<string, unknown>>;
        exec?: {
            uid?: number;
            gid?: number;
        };
    };
    permission?: PermittedDirectories;
}

Example usage

Note

Usage without a Host is conducted through static methods. The using class method is called by the Host to perform the transformation.

References