@basetime/a2w-api-ts
Version:
Client library that communicates with the addtowallet API.
94 lines (93 loc) • 2.96 kB
TypeScript
import { Requester } from '../http/Requester';
import { SnippetLibrary } from '../types/SnippetLibrary';
import { Workflow } from '../types/Workflow';
import { WorkflowJob } from '../types/WorkflowJob';
import Endpoint from './Endpoint';
import WorkflowJobsEndpoint from './workflows/JobsEndpoint';
/**
* Body accepted by {@link WorkflowsEndpoint.run}.
*
* `workflowId` selects the workflow to execute; `code` is an optional override that lets
* callers run an edited copy of the workflow without persisting the change.
* `campaign` and `pass` populate the workflow's runtime context.
*/
export interface WorkflowRunBody {
/**
* The ID of the workflow to run.
*/
workflowId: string;
/**
* Optional code override. When omitted the workflow's stored code is used.
*/
code?: string;
/**
* Optional campaign ID to inject into the workflow context.
*/
campaign?: string;
/**
* Optional pass ID to inject into the workflow context. Requires `campaign`.
*/
pass?: string;
}
/**
* Communicate with the workflows endpoints.
*
* Per-job operations (read, update, status polling, log appending) have moved to
* `client.workflows.jobs.*` in v2 — see {@link WorkflowJobsEndpoint}.
*/
export default class WorkflowsEndpoint extends Endpoint {
/**
* Job operations for workflows (`/workflows/jobs/*` and the workflow-scoped
* `/workflows/:workflowId/jobs` listing).
*/
readonly jobs: WorkflowJobsEndpoint;
/**
* Constructor.
*
* @param req The object to use to make requests.
*/
constructor(req: Requester);
/**
* Returns all of the workflows for authenticated organization.
*/
getAll: () => Promise<Workflow[]>;
/**
* Returns the details of a workflow.
*
* @param id The ID of the workflow.
*/
getById: (id: string) => Promise<Workflow>;
/**
* Creates a new workflow.
*
* @param workflow The workflow to create.
*/
create: (workflow: Omit<Workflow, "id" | "createdDate">) => Promise<Workflow>;
/**
* Updates a workflow.
*
* @param workflowId The ID of the workflow.
* @param workflow The workflow to update.
*/
update: (workflowId: string, workflow: Partial<Workflow>) => Promise<Workflow>;
/**
* Deletes a workflow.
*
* @param workflowId The ID of the workflow.
*/
delete: (workflowId: string) => Promise<void>;
/**
* Returns the snippets for the authenticated organization.
*/
getSnippets: () => Promise<SnippetLibrary[]>;
/**
* Runs a workflow.
*
* Creates a new {@link WorkflowJob} and dispatches it to the workflow runner. The returned
* job will be in the `pending` status; poll `client.workflows.jobs.getStatus(jobId)`
* to track progress.
*
* @param body The run request.
*/
run: (body: WorkflowRunBody) => Promise<WorkflowJob>;
}