MCPcopy
hub / github.com/triggerdotdev/trigger.dev / generateIdempotencyKey

Function generateIdempotencyKey

packages/trigger-sdk/src/io.ts:1540–1554  ·  view source on GitHub ↗
(keyMaterial: any[])

Source from the content-addressed store, hash-verified

1538
1539// Generate a stable idempotency key for the key material, using a stable json stringification
1540async function generateIdempotencyKey(keyMaterial: any[]) {
1541 const keys = keyMaterial.map((key) => {
1542 if (typeof key === "string") {
1543 return key;
1544 }
1545
1546 return stableStringify(key);
1547 });
1548
1549 const key = keys.join(":");
1550
1551 const hash = await webcrypto.subtle.digest("SHA-256", Buffer.from(key));
1552
1553 return Buffer.from(hash).toString("hex");
1554}
1555
1556function stableStringify(obj: any): string {
1557 function sortKeys(obj: any): any {

Callers 1

runTaskMethod · 0.85

Calls 2

stableStringifyFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…