Skip to content

Exported Types

Types exported from @grlt-hub/app-compose

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),
}

The type returned by compose().

import { type Composer, compose } from "@grlt-hub/app-compose"
const app: Composer = compose()

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.

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 }

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 }> = alpha

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 }

A Task’s final state: done, fail, or skip.

type TaskStatus = "done" | "fail" | "skip"