@trigger.dev/react-hooks 0.0.0-deploy-fix-20250124173800

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -0
  3. package/dist/commonjs/contexts.d.ts +4 -0
  4. package/dist/commonjs/contexts.js +10 -0
  5. package/dist/commonjs/contexts.js.map +1 -0
  6. package/dist/commonjs/hooks/useApiClient.d.ts +39 -0
  7. package/dist/commonjs/hooks/useApiClient.js +43 -0
  8. package/dist/commonjs/hooks/useApiClient.js.map +1 -0
  9. package/dist/commonjs/hooks/useRealtime.d.ts +117 -0
  10. package/dist/commonjs/hooks/useRealtime.js +423 -0
  11. package/dist/commonjs/hooks/useRealtime.js.map +1 -0
  12. package/dist/commonjs/hooks/useRun.d.ts +22 -0
  13. package/dist/commonjs/hooks/useRun.js +40 -0
  14. package/dist/commonjs/hooks/useRun.js.map +1 -0
  15. package/dist/commonjs/hooks/useTaskTrigger.d.ts +101 -0
  16. package/dist/commonjs/hooks/useTaskTrigger.js +137 -0
  17. package/dist/commonjs/hooks/useTaskTrigger.js.map +1 -0
  18. package/dist/commonjs/index.d.ts +5 -0
  19. package/dist/commonjs/index.js +22 -0
  20. package/dist/commonjs/index.js.map +1 -0
  21. package/dist/commonjs/package.json +3 -0
  22. package/dist/commonjs/utils/createContextAndHook.d.ts +15 -0
  23. package/dist/commonjs/utils/createContextAndHook.js +39 -0
  24. package/dist/commonjs/utils/createContextAndHook.js.map +1 -0
  25. package/dist/commonjs/utils/throttle.d.ts +6 -0
  26. package/dist/commonjs/utils/throttle.js +50 -0
  27. package/dist/commonjs/utils/throttle.js.map +1 -0
  28. package/dist/commonjs/utils/trigger-swr.d.ts +19 -0
  29. package/dist/commonjs/utils/trigger-swr.js +28 -0
  30. package/dist/commonjs/utils/trigger-swr.js.map +1 -0
  31. package/dist/esm/contexts.d.ts +4 -0
  32. package/dist/esm/contexts.js +5 -0
  33. package/dist/esm/contexts.js.map +1 -0
  34. package/dist/esm/hooks/useApiClient.d.ts +39 -0
  35. package/dist/esm/hooks/useApiClient.js +40 -0
  36. package/dist/esm/hooks/useApiClient.js.map +1 -0
  37. package/dist/esm/hooks/useRealtime.d.ts +117 -0
  38. package/dist/esm/hooks/useRealtime.js +417 -0
  39. package/dist/esm/hooks/useRealtime.js.map +1 -0
  40. package/dist/esm/hooks/useRun.d.ts +22 -0
  41. package/dist/esm/hooks/useRun.js +37 -0
  42. package/dist/esm/hooks/useRun.js.map +1 -0
  43. package/dist/esm/hooks/useTaskTrigger.d.ts +101 -0
  44. package/dist/esm/hooks/useTaskTrigger.js +129 -0
  45. package/dist/esm/hooks/useTaskTrigger.js.map +1 -0
  46. package/dist/esm/index.d.ts +5 -0
  47. package/dist/esm/index.js +6 -0
  48. package/dist/esm/index.js.map +1 -0
  49. package/dist/esm/package.json +3 -0
  50. package/dist/esm/utils/createContextAndHook.d.ts +15 -0
  51. package/dist/esm/utils/createContextAndHook.js +31 -0
  52. package/dist/esm/utils/createContextAndHook.js.map +1 -0
  53. package/dist/esm/utils/throttle.d.ts +6 -0
  54. package/dist/esm/utils/throttle.js +47 -0
  55. package/dist/esm/utils/throttle.js.map +1 -0
  56. package/dist/esm/utils/trigger-swr.d.ts +19 -0
  57. package/dist/esm/utils/trigger-swr.js +6 -0
  58. package/dist/esm/utils/trigger-swr.js.map +1 -0
  59. package/package.json +77 -0
@@ -0,0 +1,423 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useRealtimeRun = useRealtimeRun;
5
+ exports.useRealtimeRunWithStreams = useRealtimeRunWithStreams;
6
+ exports.useRealtimeRunsWithTag = useRealtimeRunsWithTag;
7
+ exports.useRealtimeBatch = useRealtimeBatch;
8
+ const react_1 = require("react");
9
+ const trigger_swr_js_1 = require("../utils/trigger-swr.js");
10
+ const useApiClient_js_1 = require("./useApiClient.js");
11
+ const throttle_js_1 = require("../utils/throttle.js");
12
+ /**
13
+ * Hook to subscribe to realtime updates of a task run.
14
+ *
15
+ * @template TTask - The type of the task
16
+ * @param {string} [runId] - The unique identifier of the run to subscribe to
17
+ * @param {UseRealtimeSingleRunOptions} [options] - Configuration options for the subscription
18
+ * @returns {UseRealtimeRunInstance<TTask>} An object containing the current state of the run, error handling, and control methods
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import type { myTask } from './path/to/task';
23
+ * const { run, error } = useRealtimeRun<typeof myTask>('run-id-123');
24
+ * ```
25
+ */
26
+ function useRealtimeRun(runId, options) {
27
+ const hookId = (0, react_1.useId)();
28
+ const idKey = options?.id ?? hookId;
29
+ // Store the streams state in SWR, using the idKey as the key to share states.
30
+ const { data: run, mutate: mutateRun } = (0, trigger_swr_js_1.useSWR)([idKey, "run"], null);
31
+ const { data: error = undefined, mutate: setError } = (0, trigger_swr_js_1.useSWR)([idKey, "error"], null);
32
+ // Add state to track when the subscription is complete
33
+ const { data: isComplete = false, mutate: setIsComplete } = (0, trigger_swr_js_1.useSWR)([idKey, "complete"], null);
34
+ // Abort controller to cancel the current API call.
35
+ const abortControllerRef = (0, react_1.useRef)(null);
36
+ const stop = (0, react_1.useCallback)(() => {
37
+ if (abortControllerRef.current) {
38
+ abortControllerRef.current.abort();
39
+ abortControllerRef.current = null;
40
+ }
41
+ }, []);
42
+ const apiClient = (0, useApiClient_js_1.useApiClient)(options);
43
+ const triggerRequest = (0, react_1.useCallback)(async () => {
44
+ try {
45
+ if (!runId || !apiClient) {
46
+ return;
47
+ }
48
+ const abortController = new AbortController();
49
+ abortControllerRef.current = abortController;
50
+ await processRealtimeRun(runId, apiClient, mutateRun, setError, abortControllerRef, typeof options?.stopOnCompletion === "boolean" ? options.stopOnCompletion : true);
51
+ }
52
+ catch (err) {
53
+ // Ignore abort errors as they are expected.
54
+ if (err.name === "AbortError") {
55
+ abortControllerRef.current = null;
56
+ return;
57
+ }
58
+ setError(err);
59
+ }
60
+ finally {
61
+ if (abortControllerRef.current) {
62
+ abortControllerRef.current = null;
63
+ }
64
+ // Mark the subscription as complete
65
+ setIsComplete(true);
66
+ }
67
+ }, [runId, mutateRun, abortControllerRef, apiClient, setError]);
68
+ const hasCalledOnCompleteRef = (0, react_1.useRef)(false);
69
+ // Effect to handle onComplete callback
70
+ (0, react_1.useEffect)(() => {
71
+ if (isComplete && run && options?.onComplete && !hasCalledOnCompleteRef.current) {
72
+ options.onComplete(run, error);
73
+ hasCalledOnCompleteRef.current = true;
74
+ }
75
+ }, [isComplete, run, error, options?.onComplete]);
76
+ (0, react_1.useEffect)(() => {
77
+ if (typeof options?.enabled === "boolean" && !options.enabled) {
78
+ return;
79
+ }
80
+ if (!runId) {
81
+ return;
82
+ }
83
+ triggerRequest().finally(() => { });
84
+ return () => {
85
+ stop();
86
+ };
87
+ }, [runId, stop, options?.enabled]);
88
+ (0, react_1.useEffect)(() => {
89
+ if (run?.finishedAt) {
90
+ setIsComplete(true);
91
+ }
92
+ }, [run]);
93
+ return { run, error, stop };
94
+ }
95
+ /**
96
+ * Hook to subscribe to realtime updates of a task run with associated data streams.
97
+ *
98
+ * @template TTask - The type of the task
99
+ * @template TStreams - The type of the streams data
100
+ * @param {string} [runId] - The unique identifier of the run to subscribe to
101
+ * @param {UseRealtimeRunOptions} [options] - Configuration options for the subscription
102
+ * @returns {UseRealtimeRunWithStreamsInstance<TTask, TStreams>} An object containing the current state of the run, streams data, and error handling
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import type { myTask } from './path/to/task';
107
+ * const { run, streams, error } = useRealtimeRunWithStreams<typeof myTask, {
108
+ * output: string;
109
+ * }>('run-id-123');
110
+ * ```
111
+ */
112
+ function useRealtimeRunWithStreams(runId, options) {
113
+ const hookId = (0, react_1.useId)();
114
+ const idKey = options?.id ?? hookId;
115
+ const [initialStreamsFallback] = (0, react_1.useState)({});
116
+ // Store the streams state in SWR, using the idKey as the key to share states.
117
+ const { data: streams, mutate: mutateStreams } = (0, trigger_swr_js_1.useSWR)([idKey, "streams"], null, {
118
+ fallbackData: initialStreamsFallback,
119
+ });
120
+ // Keep the latest streams in a ref.
121
+ const streamsRef = (0, react_1.useRef)(streams ?? {});
122
+ (0, react_1.useEffect)(() => {
123
+ streamsRef.current = streams || {};
124
+ }, [streams]);
125
+ // Store the streams state in SWR, using the idKey as the key to share states.
126
+ const { data: run, mutate: mutateRun } = (0, trigger_swr_js_1.useSWR)([idKey, "run"], null);
127
+ // Add state to track when the subscription is complete
128
+ const { data: isComplete = false, mutate: setIsComplete } = (0, trigger_swr_js_1.useSWR)([idKey, "complete"], null);
129
+ const { data: error = undefined, mutate: setError } = (0, trigger_swr_js_1.useSWR)([idKey, "error"], null);
130
+ // Abort controller to cancel the current API call.
131
+ const abortControllerRef = (0, react_1.useRef)(null);
132
+ const stop = (0, react_1.useCallback)(() => {
133
+ if (abortControllerRef.current) {
134
+ abortControllerRef.current.abort();
135
+ abortControllerRef.current = null;
136
+ }
137
+ }, []);
138
+ const apiClient = (0, useApiClient_js_1.useApiClient)(options);
139
+ const triggerRequest = (0, react_1.useCallback)(async () => {
140
+ try {
141
+ if (!runId || !apiClient) {
142
+ return;
143
+ }
144
+ const abortController = new AbortController();
145
+ abortControllerRef.current = abortController;
146
+ await processRealtimeRunWithStreams(runId, apiClient, mutateRun, mutateStreams, streamsRef, setError, abortControllerRef, typeof options?.stopOnCompletion === "boolean" ? options.stopOnCompletion : true, options?.experimental_throttleInMs);
147
+ }
148
+ catch (err) {
149
+ // Ignore abort errors as they are expected.
150
+ if (err.name === "AbortError") {
151
+ abortControllerRef.current = null;
152
+ return;
153
+ }
154
+ setError(err);
155
+ }
156
+ finally {
157
+ if (abortControllerRef.current) {
158
+ abortControllerRef.current = null;
159
+ }
160
+ // Mark the subscription as complete
161
+ setIsComplete(true);
162
+ }
163
+ }, [runId, mutateRun, mutateStreams, streamsRef, abortControllerRef, apiClient, setError]);
164
+ const hasCalledOnCompleteRef = (0, react_1.useRef)(false);
165
+ // Effect to handle onComplete callback
166
+ (0, react_1.useEffect)(() => {
167
+ if (isComplete && run && options?.onComplete && !hasCalledOnCompleteRef.current) {
168
+ options.onComplete(run, error);
169
+ hasCalledOnCompleteRef.current = true;
170
+ }
171
+ }, [isComplete, run, error, options?.onComplete]);
172
+ (0, react_1.useEffect)(() => {
173
+ if (typeof options?.enabled === "boolean" && !options.enabled) {
174
+ return;
175
+ }
176
+ if (!runId) {
177
+ return;
178
+ }
179
+ triggerRequest().finally(() => { });
180
+ return () => {
181
+ stop();
182
+ };
183
+ }, [runId, stop, options?.enabled]);
184
+ (0, react_1.useEffect)(() => {
185
+ if (run?.finishedAt) {
186
+ setIsComplete(true);
187
+ }
188
+ }, [run]);
189
+ return { run, streams: streams ?? initialStreamsFallback, error, stop };
190
+ }
191
+ /**
192
+ * Hook to subscribe to realtime updates of task runs filtered by tag(s).
193
+ *
194
+ * @template TTask - The type of the task
195
+ * @param {string | string[]} tag - The tag or array of tags to filter runs by
196
+ * @param {UseRealtimeRunOptions} [options] - Configuration options for the subscription
197
+ * @returns {UseRealtimeRunsInstance<TTask>} An object containing the current state of the runs and any error encountered
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * import type { myTask } from './path/to/task';
202
+ * const { runs, error } = useRealtimeRunsWithTag<typeof myTask>('my-tag');
203
+ * // Or with multiple tags
204
+ * const { runs, error } = useRealtimeRunsWithTag<typeof myTask>(['tag1', 'tag2']);
205
+ * ```
206
+ */
207
+ function useRealtimeRunsWithTag(tag, options) {
208
+ const hookId = (0, react_1.useId)();
209
+ const idKey = options?.id ?? hookId;
210
+ // Store the streams state in SWR, using the idKey as the key to share states.
211
+ const { data: runs, mutate: mutateRuns } = (0, trigger_swr_js_1.useSWR)([idKey, "run"], null, {
212
+ fallbackData: [],
213
+ });
214
+ // Keep the latest streams in a ref.
215
+ const runsRef = (0, react_1.useRef)([]);
216
+ (0, react_1.useEffect)(() => {
217
+ runsRef.current = runs ?? [];
218
+ }, [runs]);
219
+ const { data: error = undefined, mutate: setError } = (0, trigger_swr_js_1.useSWR)([idKey, "error"], null);
220
+ // Abort controller to cancel the current API call.
221
+ const abortControllerRef = (0, react_1.useRef)(null);
222
+ const stop = (0, react_1.useCallback)(() => {
223
+ if (abortControllerRef.current) {
224
+ abortControllerRef.current.abort();
225
+ abortControllerRef.current = null;
226
+ }
227
+ }, []);
228
+ const apiClient = (0, useApiClient_js_1.useApiClient)(options);
229
+ const triggerRequest = (0, react_1.useCallback)(async () => {
230
+ try {
231
+ if (!apiClient) {
232
+ return;
233
+ }
234
+ const abortController = new AbortController();
235
+ abortControllerRef.current = abortController;
236
+ await processRealtimeRunsWithTag(tag, apiClient, mutateRuns, runsRef, setError, abortControllerRef);
237
+ }
238
+ catch (err) {
239
+ // Ignore abort errors as they are expected.
240
+ if (err.name === "AbortError") {
241
+ abortControllerRef.current = null;
242
+ return;
243
+ }
244
+ setError(err);
245
+ }
246
+ finally {
247
+ if (abortControllerRef.current) {
248
+ abortControllerRef.current = null;
249
+ }
250
+ }
251
+ }, [tag, mutateRuns, runsRef, abortControllerRef, apiClient, setError]);
252
+ (0, react_1.useEffect)(() => {
253
+ if (typeof options?.enabled === "boolean" && !options.enabled) {
254
+ return;
255
+ }
256
+ triggerRequest().finally(() => { });
257
+ return () => {
258
+ stop();
259
+ };
260
+ }, [tag, stop, options?.enabled]);
261
+ return { runs: runs ?? [], error, stop };
262
+ }
263
+ /**
264
+ * Hook to subscribe to realtime updates of a batch of task runs.
265
+ *
266
+ * @template TTask - The type of the task
267
+ * @param {string} batchId - The unique identifier of the batch to subscribe to
268
+ * @param {UseRealtimeRunOptions} [options] - Configuration options for the subscription
269
+ * @returns {UseRealtimeRunsInstance<TTask>} An object containing the current state of the runs, error handling, and control methods
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * import type { myTask } from './path/to/task';
274
+ * const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123');
275
+ * ```
276
+ */
277
+ function useRealtimeBatch(batchId, options) {
278
+ const hookId = (0, react_1.useId)();
279
+ const idKey = options?.id ?? hookId;
280
+ // Store the streams state in SWR, using the idKey as the key to share states.
281
+ const { data: runs, mutate: mutateRuns } = (0, trigger_swr_js_1.useSWR)([idKey, "run"], null, {
282
+ fallbackData: [],
283
+ });
284
+ // Keep the latest streams in a ref.
285
+ const runsRef = (0, react_1.useRef)([]);
286
+ (0, react_1.useEffect)(() => {
287
+ runsRef.current = runs ?? [];
288
+ }, [runs]);
289
+ const { data: error = undefined, mutate: setError } = (0, trigger_swr_js_1.useSWR)([idKey, "error"], null);
290
+ // Abort controller to cancel the current API call.
291
+ const abortControllerRef = (0, react_1.useRef)(null);
292
+ const stop = (0, react_1.useCallback)(() => {
293
+ if (abortControllerRef.current) {
294
+ abortControllerRef.current.abort();
295
+ abortControllerRef.current = null;
296
+ }
297
+ }, []);
298
+ const apiClient = (0, useApiClient_js_1.useApiClient)(options);
299
+ const triggerRequest = (0, react_1.useCallback)(async () => {
300
+ try {
301
+ if (!apiClient) {
302
+ return;
303
+ }
304
+ const abortController = new AbortController();
305
+ abortControllerRef.current = abortController;
306
+ await processRealtimeBatch(batchId, apiClient, mutateRuns, runsRef, setError, abortControllerRef);
307
+ }
308
+ catch (err) {
309
+ // Ignore abort errors as they are expected.
310
+ if (err.name === "AbortError") {
311
+ abortControllerRef.current = null;
312
+ return;
313
+ }
314
+ setError(err);
315
+ }
316
+ finally {
317
+ if (abortControllerRef.current) {
318
+ abortControllerRef.current = null;
319
+ }
320
+ }
321
+ }, [batchId, mutateRuns, runsRef, abortControllerRef, apiClient, setError]);
322
+ (0, react_1.useEffect)(() => {
323
+ if (typeof options?.enabled === "boolean" && !options.enabled) {
324
+ return;
325
+ }
326
+ triggerRequest().finally(() => { });
327
+ return () => {
328
+ stop();
329
+ };
330
+ }, [batchId, stop, options?.enabled]);
331
+ return { runs: runs ?? [], error, stop };
332
+ }
333
+ async function processRealtimeBatch(batchId, apiClient, mutateRunsData, existingRunsRef, onError, abortControllerRef) {
334
+ const subscription = apiClient.subscribeToBatch(batchId, {
335
+ signal: abortControllerRef.current?.signal,
336
+ onFetchError: onError,
337
+ });
338
+ for await (const part of subscription) {
339
+ mutateRunsData(insertRunShapeInOrder(existingRunsRef.current, part));
340
+ }
341
+ }
342
+ // Inserts and then orders by the run number, and ensures that the run is not duplicated
343
+ function insertRunShapeInOrder(previousRuns, run) {
344
+ const existingRun = previousRuns.find((r) => r.id === run.id);
345
+ if (existingRun) {
346
+ return previousRuns.map((r) => (r.id === run.id ? run : r));
347
+ }
348
+ const runNumber = run.number;
349
+ const index = previousRuns.findIndex((r) => r.number > runNumber);
350
+ if (index === -1) {
351
+ return [...previousRuns, run];
352
+ }
353
+ return [...previousRuns.slice(0, index), run, ...previousRuns.slice(index)];
354
+ }
355
+ async function processRealtimeRunsWithTag(tag, apiClient, mutateRunsData, existingRunsRef, onError, abortControllerRef) {
356
+ const subscription = apiClient.subscribeToRunsWithTag(tag, {
357
+ signal: abortControllerRef.current?.signal,
358
+ onFetchError: onError,
359
+ });
360
+ for await (const part of subscription) {
361
+ mutateRunsData(insertRunShape(existingRunsRef.current, part));
362
+ }
363
+ }
364
+ // Replaces or inserts a run shape, ordered by the createdAt timestamp
365
+ function insertRunShape(previousRuns, run) {
366
+ const existingRun = previousRuns.find((r) => r.id === run.id);
367
+ if (existingRun) {
368
+ return previousRuns.map((r) => (r.id === run.id ? run : r));
369
+ }
370
+ const createdAt = run.createdAt;
371
+ const index = previousRuns.findIndex((r) => r.createdAt > createdAt);
372
+ if (index === -1) {
373
+ return [...previousRuns, run];
374
+ }
375
+ return [...previousRuns.slice(0, index), run, ...previousRuns.slice(index)];
376
+ }
377
+ async function processRealtimeRunWithStreams(runId, apiClient, mutateRunData, mutateStreamData, existingDataRef, onError, abortControllerRef, stopOnCompletion = true, throttleInMs) {
378
+ const subscription = apiClient.subscribeToRun(runId, {
379
+ signal: abortControllerRef.current?.signal,
380
+ closeOnComplete: stopOnCompletion,
381
+ onFetchError: onError,
382
+ });
383
+ const streamQueue = (0, throttle_js_1.createThrottledQueue)(async (updates) => {
384
+ const nextStreamData = { ...existingDataRef.current };
385
+ // Group updates by type
386
+ const updatesByType = updates.reduce((acc, update) => {
387
+ if (!acc[update.type]) {
388
+ acc[update.type] = [];
389
+ }
390
+ acc[update.type].push(update.chunk);
391
+ return acc;
392
+ }, {});
393
+ // Apply all updates
394
+ for (const [type, chunks] of Object.entries(updatesByType)) {
395
+ // @ts-ignore
396
+ nextStreamData[type] = [...(existingDataRef.current[type] || []), ...chunks];
397
+ }
398
+ mutateStreamData(nextStreamData);
399
+ }, throttleInMs);
400
+ for await (const part of subscription.withStreams()) {
401
+ if (part.type === "run") {
402
+ mutateRunData(part.run);
403
+ }
404
+ else {
405
+ streamQueue.add({
406
+ type: part.type,
407
+ // @ts-ignore
408
+ chunk: part.chunk,
409
+ });
410
+ }
411
+ }
412
+ }
413
+ async function processRealtimeRun(runId, apiClient, mutateRunData, onError, abortControllerRef, stopOnCompletion = true) {
414
+ const subscription = apiClient.subscribeToRun(runId, {
415
+ signal: abortControllerRef.current?.signal,
416
+ closeOnComplete: stopOnCompletion,
417
+ onFetchError: onError,
418
+ });
419
+ for await (const part of subscription) {
420
+ mutateRunData(part);
421
+ }
422
+ }
423
+ //# sourceMappingURL=useRealtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRealtime.js","sourceRoot":"","sources":["../../../src/hooks/useRealtime.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AA2Db,wCAqGC;AAuCD,8DA4HC;AA6BD,wDAgFC;AAiBD,4CAgFC;AA9gBD,iCAAwE;AACxE,4DAA+D;AAC/D,uDAAsE;AACtE,sDAA4D;AAsC5D;;;;;;;;;;;;;GAaG;AAEH,SAAgB,cAAc,CAC5B,KAAc,EACd,OAA4C;IAE5C,MAAM,MAAM,GAAG,IAAA,aAAK,GAAE,CAAC;IACvB,MAAM,KAAK,GAAG,OAAO,EAAE,EAAE,IAAI,MAAM,CAAC;IAEpC,8EAA8E;IAC9E,MAAM,EAAE,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CAAC;IACtB,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { AnyTask, RetrieveRunResult } from "@trigger.dev/core/v3";
2
+ import { CommonTriggerHookOptions } from "../utils/trigger-swr.js";
3
+ /**
4
+ * Custom hook to retrieve and manage the state of a run by its ID.
5
+ *
6
+ * @template TTask - The type of the task associated with the run.
7
+ * @param {string} runId - The unique identifier of the run to retrieve.
8
+ * @param {CommonTriggerHookOptions} [options] - Optional configuration for the hook's behavior.
9
+ * @returns {Object} An object containing the run data, error, loading state, validation state, and error state.
10
+ * @returns {RetrieveRunResult<TTask> | undefined} run - The retrieved run data.
11
+ * @returns {Error | undefined} error - The error object if an error occurred.
12
+ * @returns {boolean} isLoading - Indicates if the run data is currently being loaded.
13
+ * @returns {boolean} isValidating - Indicates if the run data is currently being validated.
14
+ * @returns {boolean} isError - Indicates if an error occurred during the retrieval of the run data.
15
+ */
16
+ export declare function useRun<TTask extends AnyTask>(runId: string, options?: CommonTriggerHookOptions): {
17
+ run: RetrieveRunResult<TTask> | undefined;
18
+ error: Error | undefined;
19
+ isLoading: boolean;
20
+ isValidating: boolean;
21
+ isError: boolean;
22
+ };
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useRun = useRun;
5
+ const trigger_swr_js_1 = require("../utils/trigger-swr.js");
6
+ const useApiClient_js_1 = require("./useApiClient.js");
7
+ /**
8
+ * Custom hook to retrieve and manage the state of a run by its ID.
9
+ *
10
+ * @template TTask - The type of the task associated with the run.
11
+ * @param {string} runId - The unique identifier of the run to retrieve.
12
+ * @param {CommonTriggerHookOptions} [options] - Optional configuration for the hook's behavior.
13
+ * @returns {Object} An object containing the run data, error, loading state, validation state, and error state.
14
+ * @returns {RetrieveRunResult<TTask> | undefined} run - The retrieved run data.
15
+ * @returns {Error | undefined} error - The error object if an error occurred.
16
+ * @returns {boolean} isLoading - Indicates if the run data is currently being loaded.
17
+ * @returns {boolean} isValidating - Indicates if the run data is currently being validated.
18
+ * @returns {boolean} isError - Indicates if an error occurred during the retrieval of the run data.
19
+ */
20
+ function useRun(runId, options) {
21
+ const apiClient = (0, useApiClient_js_1.useApiClient)(options);
22
+ const { data: run, error, isLoading, isValidating, } = (0, trigger_swr_js_1.useSWR)(runId, () => {
23
+ if (!apiClient) {
24
+ throw new Error("Could not call useRun: Missing access token");
25
+ }
26
+ return apiClient.retrieveRun(runId);
27
+ }, {
28
+ revalidateOnReconnect: options?.revalidateOnReconnect,
29
+ refreshInterval: (run) => {
30
+ if (!run)
31
+ return options?.refreshInterval ?? 0;
32
+ if (run.isCompleted)
33
+ return 0;
34
+ return options?.refreshInterval ?? 0;
35
+ },
36
+ revalidateOnFocus: options?.revalidateOnFocus,
37
+ });
38
+ return { run, error, isLoading, isValidating, isError: !!error };
39
+ }
40
+ //# sourceMappingURL=useRun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRun.js","sourceRoot":"","sources":["../../../src/hooks/useRun.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAmBb,wBAuCC;AAvDD,4DAA2E;AAC3E,uDAAiD;AAEjD;;;;;;;;;;;;GAYG;AACH,SAAgB,MAAM,CACpB,KAAa,EACb,OAAkC;IAQlC,MAAM,SAAS,GAAG,IAAA,8BAAY,EAAC,OAAO,CAAC,CAAC;IACxC,MAAM,EACJ,IAAI,EAAE,GAAG,EACT,KAAK,EACL,SAAS,EACT,YAAY,GACb,GAAG,IAAA,uBAAM,EACR,KAAK,EACL,GAAG,EAAE;QACH,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,EACD;QACE,qBAAqB,EAAE,OAAO,EAAE,qBAAqB;QACrD,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,IAAI,CAAC,GAAG;gBAAE,OAAO,OAAO,EAAE,eAAe,IAAI,CAAC,CAAC;YAE/C,IAAI,GAAG,CAAC,WAAW;gBAAE,OAAO,CAAC,CAAC;YAE9B,OAAO,OAAO,EAAE,eAAe,IAAI,CAAC,CAAC;QACvC,CAAC;QACD,iBAAiB,EAAE,OAAO,EAAE,iBAAiB;KAC9C,CACF,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AACnE,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { type AnyTask, type TaskIdentifier, type TaskPayload, InferRunTypes, RunHandleFromTypes, type TriggerOptions } from "@trigger.dev/core/v3";
2
+ import { UseApiClientOptions } from "./useApiClient.js";
3
+ import { UseRealtimeRunInstance, UseRealtimeRunWithStreamsInstance } from "./useRealtime.js";
4
+ /**
5
+ * Base interface for task trigger instances.
6
+ *
7
+ * @template TTask - The type of the task
8
+ */
9
+ export interface TriggerInstance<TTask extends AnyTask> {
10
+ /** Function to submit the task with a payload */
11
+ submit: (payload: TaskPayload<TTask>, options?: TriggerOptions) => void;
12
+ /** Whether the task is currently being submitted */
13
+ isLoading: boolean;
14
+ /** The handle returned after successful task submission */
15
+ handle?: RunHandleFromTypes<InferRunTypes<TTask>>;
16
+ /** Any error that occurred during submission */
17
+ error?: Error;
18
+ }
19
+ export type UseTaskTriggerOptions = UseApiClientOptions;
20
+ /**
21
+ * Hook to trigger a task and manage its initial execution state.
22
+ *
23
+ * @template TTask - The type of the task
24
+ * @param {TaskIdentifier<TTask>} id - The identifier of the task to trigger
25
+ * @param {UseTaskTriggerOptions} [options] - Configuration options for the task trigger
26
+ * @returns {TriggerInstance<TTask>} An object containing the submit function, loading state, handle, and any errors
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import type { myTask } from './path/to/task';
31
+ * const { submit, isLoading, handle, error } = useTaskTrigger<typeof myTask>('my-task-id');
32
+ *
33
+ * // Submit the task with payload
34
+ * submit({ foo: 'bar' });
35
+ * ```
36
+ */
37
+ export declare function useTaskTrigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>, options?: UseTaskTriggerOptions): TriggerInstance<TTask>;
38
+ /**
39
+ * Configuration options for task triggers with realtime updates.
40
+ */
41
+ export type UseRealtimeTaskTriggerOptions = UseTaskTriggerOptions & {
42
+ /** Whether the realtime subscription is enabled */
43
+ enabled?: boolean;
44
+ /** Optional throttle time in milliseconds for stream updates */
45
+ experimental_throttleInMs?: number;
46
+ };
47
+ export type RealtimeTriggerInstanceWithStreams<TTask extends AnyTask, TStreams extends Record<string, any> = Record<string, any>> = UseRealtimeRunWithStreamsInstance<TTask, TStreams> & {
48
+ submit: (payload: TaskPayload<TTask>, options?: TriggerOptions) => void;
49
+ isLoading: boolean;
50
+ handle?: RunHandleFromTypes<InferRunTypes<TTask>>;
51
+ };
52
+ /**
53
+ * Hook to trigger a task and subscribe to its realtime updates including stream data.
54
+ *
55
+ * @template TTask - The type of the task
56
+ * @template TStreams - The type of the streams data
57
+ * @param {TaskIdentifier<TTask>} id - The identifier of the task to trigger
58
+ * @param {UseRealtimeTaskTriggerOptions} [options] - Configuration options for the task trigger and realtime updates
59
+ * @returns {RealtimeTriggerInstanceWithStreams<TTask, TStreams>} An object containing the submit function, loading state,
60
+ * handle, run state, streams data, and error handling
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import type { myTask } from './path/to/task';
65
+ * const { submit, run, streams, error } = useRealtimeTaskTriggerWithStreams<
66
+ * typeof myTask,
67
+ * { output: string }
68
+ * >('my-task-id');
69
+ *
70
+ * // Submit and monitor the task with streams
71
+ * submit({ foo: 'bar' });
72
+ * ```
73
+ */
74
+ export declare function useRealtimeTaskTriggerWithStreams<TTask extends AnyTask, TStreams extends Record<string, any> = Record<string, any>>(id: TaskIdentifier<TTask>, options?: UseRealtimeTaskTriggerOptions): RealtimeTriggerInstanceWithStreams<TTask, TStreams>;
75
+ export type RealtimeTriggerInstance<TTask extends AnyTask> = UseRealtimeRunInstance<TTask> & {
76
+ submit: (payload: TaskPayload<TTask>, options?: TriggerOptions) => void;
77
+ isLoading: boolean;
78
+ handle?: RunHandleFromTypes<InferRunTypes<TTask>>;
79
+ };
80
+ /**
81
+ * Hook to trigger a task and subscribe to its realtime updates.
82
+ *
83
+ * @template TTask - The type of the task
84
+ * @param {TaskIdentifier<TTask>} id - The identifier of the task to trigger
85
+ * @param {UseRealtimeTaskTriggerOptions} [options] - Configuration options for the task trigger and realtime updates
86
+ * @returns {RealtimeTriggerInstance<TTask>} An object containing the submit function, loading state,
87
+ * handle, run state, and error handling
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import type { myTask } from './path/to/task';
92
+ * const { submit, run, error, stop } = useRealtimeTaskTrigger<typeof myTask>('my-task-id');
93
+ *
94
+ * // Submit and monitor the task
95
+ * submit({ foo: 'bar' });
96
+ *
97
+ * // Stop monitoring when needed
98
+ * stop();
99
+ * ```
100
+ */
101
+ export declare function useRealtimeTaskTrigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>, options?: UseRealtimeTaskTriggerOptions): RealtimeTriggerInstance<TTask>;