gotohuman
Version:
gotoHuman - The easiest way to review agent actions and AI‑generated content.
121 lines (119 loc) • 3.48 kB
TypeScript
type JsonValue = string | number | boolean | {
[key: string]: JsonValue;
} | JsonValue[];
type FormFields = {
[key: string]: JsonValue;
};
type FetchLike = typeof fetch;
type GotoHumanConfig = {
fetch?: FetchLike;
origin?: string;
originV?: string;
baseUrl?: string;
};
type ReviewResponse = {
reviewId: string;
gthLink?: string;
workflowRunId?: string;
};
declare class Review {
private readonly formId;
private readonly apiKey;
private readonly baseUrl;
private readonly fetchImpl;
private readonly origin;
private readonly originV;
private reviewData?;
private fields;
private meta;
private assignTo?;
private assignToGroups?;
private reviewIdToUpdate?;
private reviewConfig?;
private webhookUrl?;
private title?;
private autoApprove?;
private workflowInfo?;
constructor(formId: string, apiKey: string, baseUrl: string, fetchImpl: FetchLike, origin: string, originV: string);
/**
* Set the review data (arbitrary object passed to the reviewer)
*/
setReviewData(data: Record<string, JsonValue>): Review;
/**
* @deprecated Use setReviewData instead
*/
addFieldData(fieldName: string, value?: JsonValue): Review;
/**
* @deprecated Use setReviewData instead
*/
setFieldsData(fields?: FormFields): Review;
/**
* @deprecated Use setReviewData instead
*/
clearFieldData(): Review;
setWebhookUrl(webhookUrl: string): Review;
setTitle(title: string): Review;
setAutoApprove(autoApprove: boolean): Review;
setWorkflowInfo(workflowInfo: Record<string, JsonValue>): Review;
/**
* Set review configuration options (sent as `config` in API body)
*/
setReviewConfig(config: Record<string, JsonValue>): Review;
/**
* Add a field to the meta data
*/
addMetaData(attribute: string, value?: JsonValue): Review;
/**
* Set multiple meta field values at once
*/
setMetaData(fields?: FormFields): Review;
/**
* Assign the review request to specific users
*/
assignToUsers(userEmails: string[]): Review;
/**
* Assign the review request to specific user groups
*/
assignToUserGroups(groupIds: string[]): Review;
/**
* Update a review request
*/
updateForReview(reviewId: string): Review;
/**
* Send the review request to the API
*/
sendRequest(): Promise<ReviewResponse>;
}
declare class GotoHuman {
private baseUrl;
private apiKey;
private fetchImpl;
private origin;
private originV;
constructor(params?: {
apiKey?: string;
} & GotoHumanConfig);
/**
* Initialize a new review with a review template ID
*/
createReview(formId: string | undefined): Review;
/**
* Fetch all available review templates
*/
fetchReviewForms(): Promise<any>;
/**
* Fetch the schema for a specific review template's fields
*/
fetchSchemaForFormFields(formId: string): Promise<any>;
/**
* Retrieves the base URL from the environment variable.
* @returns The base URL if set, otherwise undefined.
*/
private static getBaseUrlFromEnv;
/**
* Retrieves the API key from the environment variable.
* @returns The API key if set, otherwise undefined.
*/
private static getApiKeyFromEnv;
}
export { type FormFields, GotoHuman, type JsonValue, Review, type ReviewResponse };