Skip to content

Migrate date string fields to Date objects across all schemas #536

@scottlovegrove

Description

@scottlovegrove

Summary

All Zod schemas in the SDK currently define date/timestamp fields (e.g. createdAt, updatedAt, completedAt, addedAt, postedAt) as z.string(), meaning consumers receive raw ISO strings rather than Date objects.

These should be migrated to use z.coerce.date() so consumers get proper Date objects.

Affected fields (~32 across 15 files)

Sync resources (src/types/sync/resources/):

  • workspace-goals.tscreatedAt, updatedAt
  • workspace-filters.tscreatedAt, updatedAt
  • workspaces.tscreatedAt, dateCreated
  • live-notifications.tscreatedAt
  • notes.tspostedAt
  • user.tsjoinedAt, premiumUntil, freeTrailExpires, resetDate

Entity types (src/types/):

  • tasks/types.tsaddedAt, completedAt, updatedAt
  • projects/types.tscreatedAt, updatedAt
  • sections/types.tsaddedAt, updatedAt
  • comments/types.tspostedAt
  • activity/types.tseventDate
  • insights/types.tsdate, createdAt, updatedAt, completedAt

Breaking change

This is a breaking change — all affected fields change their TypeScript type from string to Date. Any consumer code that does string operations on these fields (e.g. task.createdAt.startsWith(...), template literals, comparisons) will fail to compile. This should be released as a major version bump.

Proposed approach

Use z.coerce.date() on each field, which accepts ISO date strings and coerces them to Date objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions