Skip to content

Commit 6919c19

Browse files
committed
Changed the SDK to be runs.replay and runs.cancel
1 parent 110c269 commit 6919c19

File tree

10 files changed

+24
-20
lines changed

10 files changed

+24
-20
lines changed

docs/mint.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,13 @@
588588
]
589589
},
590590
{
591-
"group": "REST API",
591+
"group": "Management API",
592592
"pages": [
593-
"v3/rest-start-run",
594-
"v3/rest-get-run",
595-
"v3/rest-get-runs",
596-
"v3/rest-replay-run",
597-
"v3/rest-cancel-run"
593+
"v3/management-start-run",
594+
"v3/management-get-run",
595+
"v3/management-get-runs",
596+
"v3/management-replay-run",
597+
"v3/management-cancel-run"
598598
]
599599
}
600600
]

docs/v3-openapi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"x-codeSamples": [
9999
{
100100
"lang": "typescript",
101-
"source": "const handle = await replayRun(existingRun.id);"
101+
"source": "const handle = await runs.replay(existingRun.id);"
102102
},
103103
{
104104
"lang": "sh",
@@ -193,7 +193,7 @@
193193
"x-codeSamples": [
194194
{
195195
"lang": "typescript",
196-
"source": "await cancelRun(existingRun.id);"
196+
"source": "await runs.cancel(existingRun.id);"
197197
},
198198
{
199199
"lang": "sh",
File renamed without changes.

docs/v3/rest-get-run.mdx renamed to docs/v3/management-get-run.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
title: "REST API: Get run"
3-
sidebarTitle: "Get run"
2+
title: "Get run"
43
description: "Get a run using the Task id."
54
---
65

docs/v3/rest-get-runs.mdx renamed to docs/v3/management-get-runs.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
title: "REST API: Get runs"
3-
sidebarTitle: "Get runs"
2+
title: "Get runs"
43
description: "Get runs using a Task id."
54
---
65

File renamed without changes.

docs/v3/rest-start-run.mdx renamed to docs/v3/management-start-run.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
title: "REST API: Start run"
3-
sidebarTitle: "Start run"
2+
title: "Start run"
43
description: "Start a run using the Task id, payload and options."
54
---
65

packages/trigger-sdk/src/v3/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export type { Context };
99

1010
export { logger, type LogLevel } from "@trigger.dev/core/v3";
1111

12-
export { replayRun, cancelRun } from "./management";
12+
export { runs } from "./management";

packages/trigger-sdk/src/v3/management.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { CanceledRunResponse, ReplayRunResponse, apiClientManager } from "@trigger.dev/core/v3";
22
import { apiClientMissingError } from "./shared";
33

4-
export async function replayRun(runId: string): Promise<ReplayRunResponse> {
4+
export const runs = {
5+
replay: replayRun,
6+
cancel: cancelRun,
7+
};
8+
9+
async function replayRun(runId: string): Promise<ReplayRunResponse> {
510
const apiClient = apiClientManager.client;
611

712
if (!apiClient) {
@@ -17,7 +22,7 @@ export async function replayRun(runId: string): Promise<ReplayRunResponse> {
1722
return response.data;
1823
}
1924

20-
export async function cancelRun(runId: string): Promise<CanceledRunResponse> {
25+
async function cancelRun(runId: string): Promise<CanceledRunResponse> {
2126
const apiClient = apiClientManager.client;
2227

2328
if (!apiClient) {
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import { cancelRun, replayRun } from "@trigger.dev/sdk/v3";
1+
import { runs } from "@trigger.dev/sdk/v3";
22
import { simpleChildTask } from "./trigger/subtasks";
33
import dotenv from "dotenv";
44

55
dotenv.config();
66

77
export async function run() {
88
const run = await simpleChildTask.trigger({ payload: { message: "Hello, World!" } });
9-
const canceled = await cancelRun(run.id);
9+
const canceled = await runs.cancel(run.id);
1010
console.log("canceled run", canceled);
1111

12-
const replayed = await replayRun(run.id);
12+
const replayed = await runs.replay(run.id);
1313
console.log("replayed run", replayed);
14+
15+
//todo runs.cancel();
1416
}
1517

1618
run();

0 commit comments

Comments
 (0)