From 7bfec7f549f49233a26d8e3519ef195e7c897469 Mon Sep 17 00:00:00 2001 From: Sri Manaswi Chirumamilla Date: Thu, 28 May 2026 22:49:38 -0700 Subject: [PATCH 1/6] feat: add computeTTL and sanitizeValue utilities --- lib/utils.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index bf4ad04..d7019bd 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -117,8 +117,40 @@ function formatAjvErrors (errors) { return stringErrors } +/** + * Computes the TTL in seconds from an expiry date or a number of seconds. + * Returns undefined if no expiry is provided. + * + * @private + * @param {Date|number} expiry a Date object or seconds from now + * @returns {number|undefined} TTL in seconds + */ +function computeTTL (expiry) { + if (expiry === undefined || expiry === null) return undefined + if (expiry instanceof Date) { + return Math.floor((expiry.getTime() - Date.now()) / 1000) + } + return expiry +} + +/** + * Truncates a value to the max allowed byte size for state storage. + * + * @private + * @param {string} value the value to sanitize + * @param {number} maxBytes max allowed size in bytes + * @returns {string} the value, truncated if necessary + */ +function sanitizeValue (value, maxBytes) { + const encoded = Buffer.from(value) + if (encoded.length <= maxBytes) return value + return encoded.slice(0, maxBytes).toString() +} + module.exports = { withHiddenFields, isInternalToAdobeRuntime, - formatAjvErrors + formatAjvErrors, + computeTTL, + sanitizeValue } From 5a87479edc53e5239240d32fb7b836b000260079 Mon Sep 17 00:00:00 2001 From: Sri Manaswi Chirumamilla Date: Fri, 29 May 2026 13:13:45 -0700 Subject: [PATCH 2/6] test: point pr-review workflow at feature branch for testing --- .github/workflows/pr-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index df219b4..66c61eb 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -54,7 +54,7 @@ jobs: review: needs: check if: needs.check.outputs.allowed == 'true' - uses: adobe/aio-reusable-workflows/.github/workflows/pr-review.yml@main + uses: adobe/aio-reusable-workflows/.github/workflows/pr-review.yml@fix/pr-review-pedantic-and-human-replies with: pr_number: ${{ needs.check.outputs.pr_number }} head_sha: ${{ needs.check.outputs.head_sha }} From 6f9e249b9ad06375f392f155b407f85b86a30fd3 Mon Sep 17 00:00:00 2001 From: Sri Manaswi Chirumamilla Date: Fri, 29 May 2026 14:13:25 -0700 Subject: [PATCH 3/6] chore: trigger pr-review CI From 58424a387c2842eb5e128f043ef2b8c904f87734 Mon Sep 17 00:00:00 2001 From: Sri Manaswi Chirumamilla Date: Fri, 29 May 2026 14:18:50 -0700 Subject: [PATCH 4/6] chore: trigger pr-review CI From bb6f8c293530533595b245faeb80b6dfc075f0c2 Mon Sep 17 00:00:00 2001 From: Sri Manaswi Chirumamilla Date: Fri, 29 May 2026 14:26:54 -0700 Subject: [PATCH 5/6] chore: trigger pr-review CI From 8bfd359a8b03c739f8a1f2997c1cb23dfd9e7a08 Mon Sep 17 00:00:00 2001 From: Sri Manaswi Chirumamilla Date: Fri, 29 May 2026 14:33:05 -0700 Subject: [PATCH 6/6] chore: trigger pr-review CI