feat(projections): expose event creation timestamp#238
feat(projections): expose event creation timestamp#238
Conversation
yordis
commented
May 8, 2026
- Let JS projections make timestamp-aware decisions without requiring metadata workarounds.
- Keep the documented handler event shape aligned with the runtime envelope.
PR SummaryMedium Risk Overview Updates the runtime envelope construction to carry Reviewed by Cursor Bugbot for commit 3e818b1. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR surfaces an event's creation timestamp to JavaScript projection handlers via a new ChangesEvent Created Timestamp Exposure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
a5755be to
d7b50cf
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/EventStore.Projections.Core.Tests/Services/Jint/when_accessing_event_created_property.cs (2)
48-48: 💤 Low valueUse
Assert.Thatinstead ofAssert.AreEqualfor idiomatic NUnit 3.- Assert.AreEqual(ExpectedTimestamp.ToString("o"), state.RootElement.GetProperty("created").GetString()); + Assert.That(state.RootElement.GetProperty("created").GetString(), Is.EqualTo(ExpectedTimestamp.ToString("o")));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/EventStore.Projections.Core.Tests/Services/Jint/when_accessing_event_created_property.cs` at line 48, Replace the NUnit assertion to use Assert.That for idiomatic NUnit3: change the assertion that compares ExpectedTimestamp.ToString("o") with state.RootElement.GetProperty("created").GetString() to use Assert.That(actual, Is.EqualTo(expected)) referencing the existing symbols (ExpectedTimestamp and state.RootElement.GetProperty("created").GetString()) and ensure the order is Assert.That(state.RootElement.GetProperty("created").GetString(), Is.EqualTo(ExpectedTimestamp.ToString("o"))).
13-13: ⚡ Quick winTest only covers
DateTimeKind.Utc— add aDateTimeKind.Unspecifiedcase.Given the
DateTime.ToString("o")format-specifier behavior, a test withDateTimeKind.Unspecifiedwould confirm (or reveal) the ambiguity described in the implementation concern above. A single additional[TestCase]-style variant would be sufficient.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/EventStore.Projections.Core.Tests/Services/Jint/when_accessing_event_created_property.cs` at line 13, The test only exercises DateTimeKind.Utc; add a second test variant that constructs the same timestamp with DateTimeKind.Unspecified and asserts the projection/js-access behavior matches expectations. Update the test in when_accessing_event_created_property.cs to include a new [TestCase] (or duplicate the existing test) that uses a DateTime like the existing ExpectedTimestamp but with DateTimeKind.Unspecified (or add a new ExpectedTimestampUnspecified constant) and verify the string produced by the code under test (the projection/Jint access path referenced in the test) for ToString("o")/serialization is asserted the same way as the Utc case. Ensure the test name/existing method that references ExpectedTimestamp is reused or duplicated so both DateTimeKind.Utc and DateTimeKind.Unspecified are covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/EventStore.Projections.Core/Services/Interpreted/JintProjectionStateHandler.cs`:
- Around line 1124-1127: The Created property serializes a DateTime using
ToString("o") which yields unqualified timestamps for DateTimeKind.Unspecified;
change the setter in JintProjectionStateHandler (the Created property that calls
SetOwnProperty("created", ...)) to convert the incoming DateTime to UTC before
formatting (e.g., use value.ToUniversalTime() or otherwise ensure
DateTimeKind.Utc) so the generated ISO-8601 string includes the Z offset;
alternatively consider switching to DateTimeOffset handling for explicit
offsets.
---
Nitpick comments:
In
`@src/EventStore.Projections.Core.Tests/Services/Jint/when_accessing_event_created_property.cs`:
- Line 48: Replace the NUnit assertion to use Assert.That for idiomatic NUnit3:
change the assertion that compares ExpectedTimestamp.ToString("o") with
state.RootElement.GetProperty("created").GetString() to use Assert.That(actual,
Is.EqualTo(expected)) referencing the existing symbols (ExpectedTimestamp and
state.RootElement.GetProperty("created").GetString()) and ensure the order is
Assert.That(state.RootElement.GetProperty("created").GetString(),
Is.EqualTo(ExpectedTimestamp.ToString("o"))).
- Line 13: The test only exercises DateTimeKind.Utc; add a second test variant
that constructs the same timestamp with DateTimeKind.Unspecified and asserts the
projection/js-access behavior matches expectations. Update the test in
when_accessing_event_created_property.cs to include a new [TestCase] (or
duplicate the existing test) that uses a DateTime like the existing
ExpectedTimestamp but with DateTimeKind.Unspecified (or add a new
ExpectedTimestampUnspecified constant) and verify the string produced by the
code under test (the projection/Jint access path referenced in the test) for
ToString("o")/serialization is asserted the same way as the Utc case. Ensure the
test name/existing method that references ExpectedTimestamp is reused or
duplicated so both DateTimeKind.Utc and DateTimeKind.Unspecified are covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e8232b58-08c9-4dc7-9ce3-04dff1eef68f
📒 Files selected for processing (3)
docs/projections.mdsrc/EventStore.Projections.Core.Tests/Services/Jint/when_accessing_event_created_property.cssrc/EventStore.Projections.Core/Services/Interpreted/JintProjectionStateHandler.cs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
d7b50cf to
3e818b1
Compare