-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix action attempt poll condition, log the updated action attempt
- Loading branch information
1 parent
d6f00eb
commit 7942a2d
Showing
2 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import prompts from "prompts" | ||
import { getSeam } from "./get-seam" | ||
import { ActionAttemptsGetResponse } from "@seamapi/http/connect" | ||
|
||
export const interactForActionAttemptPoll = async ( | ||
action_attempt: ActionAttemptsGetResponse["action_attempt"] | ||
) => { | ||
if (action_attempt.status === "pending") { | ||
const { poll_for_action_attempt } = await prompts({ | ||
name: "poll_for_action_attempt", | ||
message: "Would you like to poll the action attempt until it's ready?", | ||
type: "toggle", | ||
initial: true, | ||
active: "yes", | ||
inactive: "no", | ||
}) | ||
|
||
if (poll_for_action_attempt) { | ||
const seam = await getSeam() | ||
const { action_attempt_id } = action_attempt | ||
|
||
const updated_action_attempt = await seam.actionAttempts.get( | ||
{ action_attempt_id }, | ||
{ waitForActionAttempt: { pollingInterval: 240, timeout: 10_000 } } | ||
) | ||
|
||
console.dir(updated_action_attempt, { depth: null }) | ||
} | ||
} | ||
} |