Repository navigation
feat(sdk): add Date fields to AIP TypeScript client - #4655
Conversation
📝 WalkthroughWalkthroughThis PR updates date-time handling across the JavaScript SDK and generator so public types use ChangesDate mapping feature
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Greptile SummaryThis PR adds native date handling to the generated AIP TypeScript client. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "feat(sdk): add Date fields to AIP TypeSc..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
api/spec/AGENTS.md (1)
186-212: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDocs 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 ofz.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 winWire-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-levelz.iso.datetime()(same reasoning already documented a few lines up for why.url()is avoided in favor ofz.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 thezodMemberExpr/idPart/callParthelpers used elsewhere in this file (e.g. via a quick search of howzodnamespace refs are constructed for nested members likez.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
📒 Files selected for processing (33)
api/spec/.prettierignoreapi/spec/AGENTS.mdapi/spec/packages/aip-client-javascript/README.mdapi/spec/packages/aip-client-javascript/src/index.tsapi/spec/packages/aip-client-javascript/src/lib/wire.tsapi/spec/packages/aip-client-javascript/src/models/operations/addons.tsapi/spec/packages/aip-client-javascript/src/models/operations/apps.tsapi/spec/packages/aip-client-javascript/src/models/operations/billing.tsapi/spec/packages/aip-client-javascript/src/models/operations/currencies.tsapi/spec/packages/aip-client-javascript/src/models/operations/customers.tsapi/spec/packages/aip-client-javascript/src/models/operations/defaults.tsapi/spec/packages/aip-client-javascript/src/models/operations/events.tsapi/spec/packages/aip-client-javascript/src/models/operations/features.tsapi/spec/packages/aip-client-javascript/src/models/operations/governance.tsapi/spec/packages/aip-client-javascript/src/models/operations/invoices.tsapi/spec/packages/aip-client-javascript/src/models/operations/llmCost.tsapi/spec/packages/aip-client-javascript/src/models/operations/meters.tsapi/spec/packages/aip-client-javascript/src/models/operations/planAddons.tsapi/spec/packages/aip-client-javascript/src/models/operations/plans.tsapi/spec/packages/aip-client-javascript/src/models/operations/subscriptions.tsapi/spec/packages/aip-client-javascript/src/models/operations/tax.tsapi/spec/packages/aip-client-javascript/src/models/schemas.tsapi/spec/packages/aip-client-javascript/src/models/types.tsapi/spec/packages/aip-client-javascript/tests/meters.spec.tsapi/spec/packages/aip-client-javascript/tests/wire-helpers.tsapi/spec/packages/aip-client-javascript/tests/wire.spec.tsapi/spec/packages/typespec-typescript/src/readme.tsapi/spec/packages/typespec-typescript/src/request-types.tsapi/spec/packages/typespec-typescript/src/runtime-templates.tsapi/spec/packages/typespec-typescript/src/runtime/wire.tsapi/spec/packages/typespec-typescript/src/sdk-files.tsapi/spec/packages/typespec-typescript/src/ts-types.tsapi/spec/packages/typespec-typescript/src/zodBaseSchema.tsx
Summary by CodeRabbit
Dateobjects in responses, and many requests accept eitherDatevalues or RFC 3339 strings.DateString,AcceptDateStrings) and applied them across request types.Date-based surface types.Greptile Summary
This PR adds native Date handling to the TypeScript AIP client. The main changes are:
Dateobjects.Datevalues or RFC 3339 strings.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
z.date()while keeping wire schemas as RFC 3339 strings.Datein generated TypeScript surface types.Reviews (3): Last reviewed commit: "feat(sdk): update types" | Re-trigger Greptile
Context used (3)