deterministicKey function
Compute a deterministic, request-shape-stable idempotency key. Use this instead of a random UUID when the goal is "the same logical request must yield the same result" across crashes / restarts.
Implementation
String deterministicKey(String method, String path, [Object? body]) {
final text = '$method|$path|${body == null ? '' : jsonEncode(body)}';
final digest = sha256.convert(utf8.encode(text));
return digest.toString().substring(0, 32);
}