Skip to content

feat(sdk): add Date fields to AIP TypeScript client - #4655

Merged
tothandras merged 2 commits into
mainfrom
feat/date-sdk
Jul 8, 2026
Merged

tothandras merged 2 commits into
mainfrom
feat/date-sdk

Conversation

@tothandras

@tothandras tothandras commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Date-time handling in the JavaScript SDK now surfaces native Date objects in responses, and many requests accept either Date values or RFC 3339 strings.
    • Added/expanded exported helper types (DateString, AcceptDateStrings) and applied them across request types.
  • Bug Fixes
    • Improved wire↔SDK date conversions, including stricter handling for unions and deeper structures.
    • Updated date-time schema validation to align with the new Date-based surface types.
  • Documentation
    • Updated SDK and spec documentation to clarify date/request/response behavior and mapping semantics.
  • Tests
    • Expanded wire and typecheck coverage for date mapping behavior.

Greptile Summary

This PR adds native Date handling to the TypeScript AIP client. The main changes are:

  • Date-time response fields now surface as Date objects.
  • Request types now accept either Date values or RFC 3339 strings.
  • Wire helpers now serialize and revive dates at the SDK boundary.
  • The TypeSpec generator now emits matching public and wire date schemas.
  • SDK tests and docs now cover the new date behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
api/spec/packages/typespec-typescript/src/runtime/wire.ts Adds the shared date widening types and runtime date mapping used by the generated SDK.
api/spec/packages/aip-client-javascript/src/lib/wire.ts Updates the generated SDK wire mapper to serialize request Dates and revive response date strings.
api/spec/packages/typespec-typescript/src/request-types.ts Wraps body and query request aliases so date fields also accept RFC 3339 strings.
api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx Emits public date-time schemas as z.date() while keeping wire schemas as RFC 3339 strings.
api/spec/packages/typespec-typescript/src/ts-types.ts Maps date-time scalars to Date in generated TypeScript surface types.
api/spec/packages/aip-client-javascript/tests/wire.spec.ts Adds coverage for Date serialization, response revival, union handling, and request string pass-through.

Reviews (3): Last reviewed commit: "feat(sdk): update types" | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)
  • Context used - api/spec/AGENTS.md (source)

@tothandras
tothandras requested a review from a team as a code owner July 7, 2026 10:48
@tothandras tothandras added the release-note/feature Release note: Exciting New Features label Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates date-time handling across the JavaScript SDK and generator so public types use Date, wire conversion handles RFC 3339 strings, request aliases accept date strings, and docs/tests/build config reflect the new behavior.

Changes

Date mapping feature

Layer / File(s) Summary
Core wire mapper Date support
api/spec/packages/aip-client-javascript/src/lib/wire.ts, api/spec/packages/aip-client-javascript/src/models/schemas.ts, api/spec/packages/typespec-typescript/src/runtime/wire.ts, api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx, api/spec/packages/typespec-typescript/src/request-types.ts, api/spec/packages/typespec-typescript/src/ts-types.ts, api/spec/packages/typespec-typescript/src/sdk-files.ts, api/spec/packages/typespec-typescript/src/runtime-templates.ts
Adds date-aware walking and Date↔RFC 3339 conversion hooks, union revival rules, request-side widening, schema validation changes, and generator request-type selection/output wiring.
Public model types moved to Date
api/spec/packages/aip-client-javascript/src/models/types.ts
Exported interfaces and input types switch timestamp, range, and audit fields from string to Date across the SDK surface.
SDK request aliases widened with AcceptDateStrings
api/spec/packages/aip-client-javascript/src/models/operations/*.ts, api/spec/packages/aip-client-javascript/src/index.ts
Operation request aliases now wrap request shapes with AcceptDateStrings, and the package entrypoint re-exports DateString.
Generator wiring, docs, and tests
api/spec/packages/typespec-typescript/src/readme.ts, api/spec/packages/aip-client-javascript/tests/*, api/spec/packages/aip-client-javascript/README.md, api/spec/packages/aip-client-javascript/package.json, api/spec/packages/aip-client-javascript/tsconfig.tests.json, api/spec/packages/aip-client-javascript/.npmignore, api/spec/AGENTS.md, api/spec/.prettierignore
Generator metadata and emitted files now track AcceptDateStrings, docs describe Date/RFC 3339 behavior, tests assert date revival/serialization, typechecking includes tests, and ignore/package config is updated.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested labels: release-note/feature

Suggested reviewers: solkimicreb

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding native Date handling to the AIP TypeScript client SDK.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/date-sdk

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.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds native date handling to the generated AIP TypeScript client. The main changes are:

  • Date-time model fields now use Date on the public SDK surface.
  • Wire schemas keep RFC3339 strings for request and response validation.
  • Request aliases accept either Date or RFC3339 strings through AcceptDateStrings.
  • The wire mapper serializes request dates and revives response dates.
  • Tests and README content were updated for the new date behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
api/spec/packages/aip-client-javascript/src/lib/wire.ts Adds date serialization, response revival, date-aware record walking, and request-side date string widening.
api/spec/packages/typespec-typescript/src/runtime/wire.ts Mirrors the generated client wire runtime so future SDK output keeps the same date mapping behavior.
api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx Emits public date-time schemas as z.date() while keeping wire-mode schemas as RFC3339 strings.
api/spec/packages/typespec-typescript/src/ts-types.ts Maps RFC3339 date-time scalars to Date in generated public TypeScript interfaces.
api/spec/packages/typespec-typescript/src/request-types.ts Wraps body and query request aliases in AcceptDateStrings while leaving path-only requests unchanged.
api/spec/packages/typespec-typescript/src/sdk-files.ts Emits the new type-only imports and barrel export for AcceptDateStrings.
api/spec/packages/aip-client-javascript/src/models/schemas.ts Regenerates public schemas so date-time fields use z.date().
api/spec/packages/aip-client-javascript/src/models/types.ts Regenerates model and filter interfaces so date-time fields use Date.
api/spec/packages/aip-client-javascript/tests/wire.spec.ts Adds coverage for date serialization, revival, unions, filters, records, validation, and request string passthrough.

Reviews (1): Last reviewed commit: "feat(sdk): add Date fields to AIP TypeSc..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
api/spec/AGENTS.md (1)

186-212: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Docs look solid, one small optional heads-up on the zod reference.

The doc calls out z.string().datetime() for the wire schemas. Zod 4 still supports this but has deprecated it in favor of z.iso.datetime(). Not urgent since it's still functional, but worth keeping in mind if/when the underlying schemas get migrated off deprecated string-format methods, so the doc doesn't drift.

As per path instructions, "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness."

🤖 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 `@api/spec/AGENTS.md` around lines 186 - 212, The Date/time documentation is
slightly stale because it references z.string().datetime() as the wire-schema
validator, which is deprecated in Zod 4. Update the AGENTS.md wording around the
wire schemas in the Date section to either mention z.iso.datetime() or note that
the current helper is deprecated, keeping the guidance aligned with the actual
zod API used by the schema code. Use the DateTime, …Wire schemas, and
validate/wire validation description as the anchors when revising the text.

Source: Path instructions

api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx (1)

194-206: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Wire-mode datetime schema uses a deprecated Zod 4 API.

z.string().datetime() is the Zod 3-style chained method; Zod 4 deprecated it in favor of the top-level z.iso.datetime() (same reasoning already documented a few lines up for why .url() is avoided in favor of z.url()). It still works today, but it's slated for removal in a future major version.

♻️ Proposed fix
 function dateTimeBaseType() {
   if (useWireMode()) {
-    return zodMemberExpr(callPart('string'), callPart('datetime'))
+    return zodMemberExpr(idPart('iso'), callPart('datetime'))
   }
   return zodMemberExpr(callPart('date'))
 }

Since this touches an external library API, please confirm the exact z.iso.datetime() member-expression shape works with the zodMemberExpr/idPart/callPart helpers used elsewhere in this file (e.g. via a quick search of how zod namespace refs are constructed for nested members like z.iso.*).

🤖 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 `@api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx` around lines 194
- 206, The wire-mode branch in dateTimeBaseType still builds the deprecated Zod
3-style string datetime schema, so update it to use the Zod 4 top-level iso
datetime API instead. Keep the public pass returning z.date(), but change the
useWireMode() path to construct the z.iso.datetime member expression using the
existing zodMemberExpr/idPart/callPart helpers, and verify the nested namespace
shape matches how other z.iso references are formed in this file.
🤖 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
`@api/spec/packages/aip-client-javascript/src/models/operations/subscriptions.ts`:
- Around line 47-51: The request/response types using AcceptDateStrings are
widening the timing field too far by turning the mixed literal/Date union into
any string. Update the relevant models around SubscriptionCancelInput,
SubscriptionChange, and CreateSubscriptionAddonRequest so timing still allows
only the intended literals plus a date string representation, and adjust the
AcceptDateStrings usage or its definition to preserve literal members instead of
broadening them to string.

---

Nitpick comments:
In `@api/spec/AGENTS.md`:
- Around line 186-212: The Date/time documentation is slightly stale because it
references z.string().datetime() as the wire-schema validator, which is
deprecated in Zod 4. Update the AGENTS.md wording around the wire schemas in the
Date section to either mention z.iso.datetime() or note that the current helper
is deprecated, keeping the guidance aligned with the actual zod API used by the
schema code. Use the DateTime, …Wire schemas, and validate/wire validation
description as the anchors when revising the text.

In `@api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx`:
- Around line 194-206: The wire-mode branch in dateTimeBaseType still builds the
deprecated Zod 3-style string datetime schema, so update it to use the Zod 4
top-level iso datetime API instead. Keep the public pass returning z.date(), but
change the useWireMode() path to construct the z.iso.datetime member expression
using the existing zodMemberExpr/idPart/callPart helpers, and verify the nested
namespace shape matches how other z.iso references are formed in this file.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ce42d01-83b2-46eb-b573-0209d37d2a20

📥 Commits

Reviewing files that changed from the base of the PR and between 50d7ae9 and a0ba500.

📒 Files selected for processing (33)
  • api/spec/.prettierignore
  • api/spec/AGENTS.md
  • api/spec/packages/aip-client-javascript/README.md
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/lib/wire.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/addons.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/apps.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/billing.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/currencies.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/customers.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/defaults.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/events.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/features.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/governance.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/invoices.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/llmCost.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/meters.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/planAddons.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/plans.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/subscriptions.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/tax.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip-client-javascript/tests/meters.spec.ts
  • api/spec/packages/aip-client-javascript/tests/wire-helpers.ts
  • api/spec/packages/aip-client-javascript/tests/wire.spec.ts
  • api/spec/packages/typespec-typescript/src/readme.ts
  • api/spec/packages/typespec-typescript/src/request-types.ts
  • api/spec/packages/typespec-typescript/src/runtime-templates.ts
  • api/spec/packages/typespec-typescript/src/runtime/wire.ts
  • api/spec/packages/typespec-typescript/src/sdk-files.ts
  • api/spec/packages/typespec-typescript/src/ts-types.ts
  • api/spec/packages/typespec-typescript/src/zodBaseSchema.tsx

@tothandras
tothandras enabled auto-merge (squash) July 7, 2026 14:29
@tothandras
tothandras merged commit 4ccc0e8 into main Jul 8, 2026
28 checks passed
@tothandras
tothandras deleted the feat/date-sdk branch July 8, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants