Skip to content
Trigora
Start building →

TypeScript client

@trigora/client talks to Trigora. It does not embed TCC Engine and it does not compile Programs.

import { createClient } from "@trigora/client";
const trigora = createClient({
token: process.env.TRIGORA_TOKEN,
});

createClient() with no arguments:

  • If TRIGORA_TOKEN is set, uses TRIGORA_API_BASE_URL or https://api.trigora.dev.
  • Otherwise uses TRIGORA_RUNTIME_URL or http://localhost:3477.

Optional projectId sends X-Trigora-Project-Id. Optional url overrides the base URL.

const run = await trigora.start("approval", {});
await run.send("approved", { ok: true });
const value = await run.result();

start posts { programId, input }. input is the ordered argument vector. See Programs.

result() polls until completed, failed, or cancelled. Failure rejects with the execution error. Network and HTTP failures throw TrigoraRuntimeError (status, code).

Other methods: whoAmI, listProjects, createProject, deployProgram, listPrograms, getProgram, listProgramVersions, getExecution, listExecutions, sendEvent, cancelExecution, getResult. listPrograms, listProgramVersions, and listExecutions take an optional { limit?, cursor? }.

Deploy from application code is deployProgram with an already built artifact. Day to day, use trigora deploy, which compiles and then uploads.

See TypeScript client.