Skip to content

feat: DateTime maps to DateFromInput dual-boundary schema#24

Merged
samuelho-dev merged 1 commit into
mainfrom
feat/datetime-dual-input
May 8, 2026
Merged

feat: DateTime maps to DateFromInput dual-boundary schema#24
samuelho-dev merged 1 commit into
mainfrom
feat/datetime-dual-input

Conversation

@samuelho-dev

@samuelho-dev samuelho-dev commented May 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • DateTime columns now generate DateFromInput (Encoded = Date | string) instead of Schema.DateFromSelf (Encoded = Date). Decode accepts both native Date (Kysely) and ISO strings (RPC wire). Encode picks the first union member (DateFromSelf identity) so existing Kysely-bound paths keep working.
  • Mirrors the JsonValue dual-boundary discipline (Schema<JsonValue, JsonValue> is wire-safe by construction).
  • Consolidates the duplicated PRISMA_TO_EFFECT_SCHEMA / PRISMA_SCALAR_MAP constants — src/effect/type.ts now imports from src/utils/type-mappings.ts.

Why minor (not major)

Selectable<T> / Insertable<T> / Updateable<T> Type sides unchanged. Decode now accepts MORE inputs (Date AND string), not fewer. Encode still produces Date. Existing call sites continue to work — that's why consumers can drop their Schema.extend Date-override workarounds.

Test plan

  • bun run prepublishOnly passes (lint + typecheck + 344 tests + build)
  • Runtime validation: full RPC wire roundtrip (Date → JSON.stringify → JSON.parse → decode → Date) works
  • Runtime validation: Kysely DA roundtrip (pg Date → decode → Date → encode → Date) works
  • Integration test asserts generator emits generated(DateFromInput) and the new package import line
  • All existing Selectable/Insertable/Updateable tests still pass

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • DateTime fields now accept both Date objects and ISO date strings, providing flexibility for handling data from various sources (in-memory vs. JSON/HTTP transport).

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Rate limit exceeded

@samuelho-dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 36 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2bbd19a7-4fa8-4d35-b585-a14cb3b56141

📥 Commits

Reviewing files that changed from the base of the PR and between 45e120f and c49cf6c.

📒 Files selected for processing (17)
  • .changeset/datetime-dual-input.md
  • CLAUDE.md
  • README.md
  • src/__tests__/brand-preservation.test.ts
  • src/__tests__/deep-type-instantiation.test.ts
  • src/__tests__/effect-schema.test.ts
  • src/__tests__/generated-update-type.test.ts
  • src/__tests__/json-value.test.ts
  • src/__tests__/kysely-native-integration.test.ts
  • src/__tests__/kysely-values-type-inference.test.ts
  • src/__tests__/ts2589-insertable-regression.test.ts
  • src/__tests__/type-level.test.ts
  • src/__tests__/type-utilities.test.ts
  • src/effect/generator.ts
  • src/effect/type.ts
  • src/kysely/helpers.ts
  • src/utils/type-mappings.ts
📝 Walkthrough

Walkthrough

This PR introduces DateFromInput, a new dual-boundary DateTime schema for prisma-effect-kysely that accepts both native Date instances and ISO strings, consolidates type mappings, updates all generated code headers and tests to use the new schema, and documents the change across README and changelog files.

Changes

DateFromInput Dual-Boundary DateTime

Layer / File(s) Summary
Schema Definition
src/kysely/helpers.ts
New DateFromInput schema combines Schema.DateFromSelf and Schema.Date union to decode Date | string inputs while normalizing output to Date.
Type Mapping Updates
src/utils/type-mappings.ts
PRISMA_TO_EFFECT_SCHEMA.DateTime remapped from Schema.DateFromSelf to DateFromInput with documentation of dual-boundary wire/memory boundary handling.
Code Generation & Consolidation
src/effect/generator.ts, src/effect/type.ts
Generator import header now includes DateFromInput in generated code; scalar mapping constants consolidated to import canonical PRISMA_TO_EFFECT_SCHEMA.
Documentation
.changeset/datetime-dual-input.md, README.md, CLAUDE.md
Examples, type mappings tables, and changelog updated to show generated(DateFromInput) usage and document migration impact for Schema.DateFromSelf consumers.
Test Schemas
src/__tests__/{brand-preservation,deep-type-instantiation,effect-schema,generated-update-type,json-value,kysely-values-type-inference,type-level,type-utilities,ts2589-insertable-regression}.test.ts
All test schemas updated: imports include DateFromInput, timestamp fields use generated(DateFromInput) instead of generated(Schema.DateFromSelf).
Test Assertions
src/__tests__/{effect-schema,json-value,kysely-native-integration,type-level}.test.ts
Test inputs changed to ISO strings for wire-side date fields; decoding assertions updated to expect Date output; new test added for dual-input encoding/decoding behavior; type-level Insertable expectations adjusted.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through time's twin door,
Where dates arrive as strings and more,
No longer split by wire and core—
DateFromInput bridges lore!
ISO strings and Dates galore,
One schema bounds them evermore! 🕐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: DateTime columns now map to a new DateFromInput dual-boundary schema instead of Schema.DateFromSelf.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/datetime-dual-input

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Generated DateTime columns previously used Schema.DateFromSelf
(Encoded = Date) which broke RPC/HTTP wire decode where JSON-parsed
input is a string. Adds a new exported DateFromInput schema —
Schema.Union(Schema.DateFromSelf, Schema.Date) — wired into the
codegen, so decode accepts native Date instances (Kysely DA layer)
AND ISO strings (RPC wire layer). Encode picks the first union member
(DateFromSelf, identity) so Kysely-bound encode keeps producing Date
instances.

Mirrors the JsonValue dual-boundary discipline already in this package
(Schema<JsonValue, JsonValue> is wire-safe by construction).

Internal: consolidated duplicated PRISMA_TO_EFFECT_SCHEMA /
PRISMA_SCALAR_MAP constants. src/effect/type.ts now imports the
canonical map from src/utils/type-mappings.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samuelho-dev samuelho-dev force-pushed the feat/datetime-dual-input branch from 45e120f to c49cf6c Compare May 8, 2026 04:37
@samuelho-dev samuelho-dev merged commit bf7d87c into main May 8, 2026
5 checks passed
@samuelho-dev samuelho-dev deleted the feat/datetime-dual-input branch May 8, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant