File tree Expand file tree Collapse file tree 6 files changed +46
-1
lines changed Expand file tree Collapse file tree 6 files changed +46
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @trigger.dev/sdk " : patch
3
+ " @trigger.dev/core " : patch
4
+ ---
5
+
6
+ Added replayRun function to the SDK
Original file line number Diff line number Diff line change 9
9
BatchTriggerTaskRequestBody ,
10
10
BatchTriggerTaskResponse ,
11
11
CreateUploadPayloadUrlResponseBody ,
12
+ ReplayRunResponse ,
12
13
} from "../schemas" ;
13
14
14
15
export type TriggerOptions = {
@@ -88,6 +89,18 @@ export class ApiClient {
88
89
) ;
89
90
}
90
91
92
+ replayRun ( runId : string ) {
93
+ return zodfetch (
94
+ ReplayRunResponse ,
95
+ `${ this . baseUrl } /api/v1/runs/${ runId } /replay` ,
96
+ {
97
+ method : "POST" ,
98
+ headers : this . #getHeaders( false ) ,
99
+ } ,
100
+ zodFetchOptions
101
+ ) ;
102
+ }
103
+
91
104
#getHeaders( spanParentAsLink : boolean ) {
92
105
const headers : Record < string , string > = {
93
106
"Content-Type" : "application/json" ,
Original file line number Diff line number Diff line change @@ -198,3 +198,9 @@ export const CreateUploadPayloadUrlResponseBody = z.object({
198
198
} ) ;
199
199
200
200
export type CreateUploadPayloadUrlResponseBody = z . infer < typeof CreateUploadPayloadUrlResponseBody > ;
201
+
202
+ export const ReplayRunResponse = z . object ( {
203
+ id : z . string ( ) ,
204
+ } ) ;
205
+
206
+ export type ReplayRunResponse = z . infer < typeof ReplayRunResponse > ;
Original file line number Diff line number Diff line change @@ -8,3 +8,5 @@ import type { Context } from "./shared";
8
8
export type { Context } ;
9
9
10
10
export { logger , type LogLevel } from "@trigger.dev/core/v3" ;
11
+
12
+ export { replayRun } from "./management" ;
Original file line number Diff line number Diff line change
1
+ import { ReplayRunResponse , apiClientManager } from "@trigger.dev/core/v3" ;
2
+ import { apiClientMissingError } from "./shared" ;
3
+
4
+ export async function replayRun ( runId : string ) : Promise < ReplayRunResponse > {
5
+ const apiClient = apiClientManager . client ;
6
+
7
+ if ( ! apiClient ) {
8
+ throw apiClientMissingError ( ) ;
9
+ }
10
+
11
+ const response = await apiClient . replayRun ( runId ) ;
12
+
13
+ if ( ! response . ok ) {
14
+ throw new Error ( response . error ) ;
15
+ }
16
+
17
+ return response . data ;
18
+ }
Original file line number Diff line number Diff line change @@ -562,7 +562,7 @@ async function handleTaskRunExecutionResult<TOutput>(
562
562
}
563
563
}
564
564
565
- function apiClientMissingError ( ) {
565
+ export function apiClientMissingError ( ) {
566
566
const hasBaseUrl = ! ! apiClientManager . baseURL ;
567
567
const hasAccessToken = ! ! apiClientManager . accessToken ;
568
568
if ( ! hasBaseUrl && ! hasAccessToken ) {
You can’t perform that action at this time.
0 commit comments