Functions to parse and extract idempotency key options from run records.
// Source: https://github.com/triggerdotdev/trigger.dev | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { IdempotencyKeyOptionsSchema } from "../schemas/api.js";
/**
* Safely parses idempotencyKeyOptions from a database record and extracts the user-provided key.
* Returns the user-provided key if valid options exist, otherwise falls back to the hash.
*
* @param run - Object containing idempotencyKey (the hash) and idempotencyKeyOptions (JSON from DB)
* @returns The user-provided key, the hash as fallback, or null if neither exists
*/
export function getUserProvidedIdempotencyKey(run: {
idempotencyKey: string | null | undefined;
idempotencyKeyOptions: unknown;
}):
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key