Exported Types
Types exported from @grlt-hub/app-compose
ComposeHookMap
Section titled “ComposeHookMap”Type for compose lifecycle hooks: onStart, onComplete, onTaskFail.
import { type ComposeHookMap } from "@grlt-hub/app-compose"
const hookMap: ComposeHookMap = { onStart: (event) => console.log(event.meta), onComplete: (event) => console.log(event.meta), onTaskFail: (event) => console.log(event.task, event.error),}Composer
Section titled “Composer”The type returned by compose().
import { type Composer, compose } from "@grlt-hub/app-compose"
const app: Composer = compose()Spot<T>
Section titled “Spot<T>”The type of a value source — created by literal, optional, shape, or exposed as task.result, task.status, task.error, and tag.value. T is the value type.
SpotValue<T>
Section titled “SpotValue<T>”Extracts the value type from a Spot — T is the Spot type.
import { type SpotValue, createTask, literal, optional } from "@grlt-hub/app-compose"
const apiUrl = literal("https://api.example.com")type ApiUrlValue = SpotValue<typeof apiUrl> // => "https://api.example.com"
const port = optional(literal(8080))type PortValue = SpotValue<typeof port> // => 8080 | undefined
const fetchUser = createTask({ name: "fetchUser", run: { fn: () => ({ id: 1 }) },})type FetchUserResult = SpotValue<typeof fetchUser.result> // => { id: string; name: string }Task<T>
Section titled “Task<T>”The type of a Task — T is its return type. Use it for parameters and variables that hold a Task.
import { type Task, createTask } from "@grlt-hub/app-compose"
const alpha = createTask({ name: "alpha", run: { fn: () => ({ value: "hello" }) },})
const ref: Task<{ value: string }> = alphaTaskResult<T>
Section titled “TaskResult<T>”Extracts the return type from a Task — T is the Task type.
import { type TaskResult, createTask } from "@grlt-hub/app-compose"
const alpha = createTask({ name: "alpha", run: { fn: () => ({ value: "hello" }) },})
type AlphaResult = TaskResult<typeof alpha> // => { value: string }TaskStatus
Section titled “TaskStatus”A Task’s final state: done, fail, or skip.
type TaskStatus = "done" | "fail" | "skip"