Skip to content

Commit 7449708

Browse files
Rayan PalRayan Pal
authored andcommitted
feat(runs): add clientConfig support to runs.retrieve() and runs.poll()
- Change requestOptions type from ApiRequestOptions to TriggerApiRequestOptions - Pass clientConfig to apiClientManager.clientOrThrow() for per-request auth - Enables multi-project scenarios with different access tokens per request Fixes #2769
1 parent 839d5e8 commit 7449708

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
---
4+
5+
feat(runs): add clientConfig support to runs.retrieve() and runs.poll()
6+
7+
This change updates `runs.retrieve()` and `runs.poll()` to accept `TriggerApiRequestOptions` instead of `ApiRequestOptions`, enabling per-request client configuration via the `clientConfig` property.
8+
9+
This aligns `runs.retrieve()` with other SDK methods like `tasks.trigger()` that already support `clientConfig` for multi-project scenarios where different access tokens are needed per request.
10+
11+
Fixes #2769

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
AsyncIterableStream,
1717
ApiPromise,
1818
RealtimeRunSkipColumns,
19+
TriggerApiRequestOptions,
1920
} from "@trigger.dev/core/v3";
2021
import {
2122
CanceledRunResponse,
@@ -167,9 +168,9 @@ type RunId<TRunId> = TRunId extends AnyRunHandle | AnyBatchedRunHandle
167168

168169
function retrieveRun<TRunId extends AnyRunHandle | AnyBatchedRunHandle | AnyTask | string>(
169170
runId: RunId<TRunId>,
170-
requestOptions?: ApiRequestOptions
171+
requestOptions?: TriggerApiRequestOptions
171172
): ApiPromise<RetrieveRunResult<TRunId>> {
172-
const apiClient = apiClientManager.clientOrThrow();
173+
const apiClient = apiClientManager.clientOrThrow(requestOptions?.clientConfig);
173174

174175
const $requestOptions = mergeRequestOptions(
175176
{
@@ -316,7 +317,7 @@ const MAX_POLL_ATTEMPTS = 500;
316317
async function poll<TRunId extends AnyRunHandle | AnyTask | string>(
317318
runId: RunId<TRunId>,
318319
options?: { pollIntervalMs?: number },
319-
requestOptions?: ApiRequestOptions
320+
requestOptions?: TriggerApiRequestOptions
320321
) {
321322
let attempts = 0;
322323

0 commit comments

Comments
 (0)