Handle compression of ai session logs

This commit is contained in:
Owen
2026-08-26 11:28:14 -04:00
parent 331fee24d4
commit a02d16fd58
5 changed files with 95 additions and 10 deletions
+15
View File
@@ -0,0 +1,15 @@
import { gzipSync, gunzipSync } from "zlib";
/**
* Gzip a string and return it as base64 so it can be stored in a TEXT column.
*/
export function compressText(value: string): string {
return gzipSync(Buffer.from(value, "utf8")).toString("base64");
}
/**
* Reverse of compressText - base64-decode and gunzip back to the original string.
*/
export function decompressText(value: string): string {
return gunzipSync(Buffer.from(value, "base64")).toString("utf8");
}