MCPcopy
hub / github.com/triggerdotdev/trigger.dev / Replicate

Class Replicate

integrations/replicate/src/index.ts:28–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26export type ReplicateRunTask = InstanceType<typeof Replicate>["runTask"];
27
28export class Replicate implements TriggerIntegration {
29 private _options: ReplicateIntegrationOptions;
30 private _client?: any;
31 private _io?: IO;
32 private _connectionKey?: string;
33
34 constructor(private options: ReplicateIntegrationOptions) {
35 if (Object.keys(options).includes("apiKey") && !options.apiKey) {
36 throw `Can't create Replicate integration (${options.id}) as apiKey was undefined`;
37 }
38
39 this._options = options;
40 }
41
42 get authSource() {
43 return "LOCAL" as const;
44 }
45
46 get id() {
47 return this.options.id;
48 }
49
50 get metadata() {
51 return { id: "replicate", name: "Replicate" };
52 }
53
54 cloneForRun(io: IO, connectionKey: string, auth?: ConnectionAuth) {
55 const replicate = new Replicate(this._options);
56 replicate._io = io;
57 replicate._connectionKey = connectionKey;
58 replicate._client = this.createClient(auth);
59 return replicate;
60 }
61
62 createClient(auth?: ConnectionAuth) {
63 return new ReplicateClient({
64 auth: this._options.apiKey,
65 });
66 }
67
68 runTask<T, TResult extends Json<T> | void>(
69 key: IntegrationTaskKey,
70 callback: (client: ReplicateClient, task: IOTask, io: IO) => Promise<TResult>,
71 options?: RunTaskOptions,
72 errorCallback?: RunTaskErrorCallback
73 ): Promise<TResult> {
74 if (!this._io) throw new Error("No IO");
75 if (!this._connectionKey) throw new Error("No connection key");
76
77 return this._io.runTask(
78 key,
79 (task, io) => {
80 if (!this._client) throw new Error("No client");
81 return callback(this._client, task, io);
82 },
83 {
84 icon: "replicate",
85 retry: retry.standardBackoff,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…