Skip to content

Conversation

@paula-stacho
Copy link
Collaborator

@paula-stacho paula-stacho commented May 19, 2025

Description

  • added zod definitions to the storage
  • types are derived from the zod definitions
  • zod also used for edit validation
  • added placeholders for add/remove relationship

TODO:

  • validation
  • tests

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@github-actions github-actions bot added the feat label May 19, 2025
@paula-stacho paula-stacho added the feature flagged PRs labeled with this label will not be included in the release notes of the next release label May 19, 2025
try {
const res = await this.userData.readAll();
return res.data;
return res.data as MongoDBDataModelDescription[];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How I ran into this: I felt like it's unnecessarily complex to go deep with the zod schemas and basically re-define MongoDBJsonSchema.
But having it typed in TS does make sense. So it has to be cast somehow. I suppose I could go into more detail here, but I figured this would be enough for the load. Let me know if you have a better idea

@paula-stacho paula-stacho marked this pull request as ready for review May 20, 2025 14:57
collections: z.array(
z.object({
ns: z.string(),
jsonSchema: z.unknown(), // skipped for simplicity
Copy link
Collaborator

@gribnoysup gribnoysup May 21, 2025

Choose a reason for hiding this comment

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

I understand that we probably don't want a full blown validation of MongoDBJSONSchema type implemented here, but I think we might want to consider using z.custom here, provide the MongoDBJSONSchema as a generic argument and maybe adding some very basic validation for the type matching. The purpose of these z.<type> helpers is not only to get the type definition after all, but to actually build a validator that makes sure that data, in our case, you're loading from disk (and at some point user will be passing to the app) is matching the shape that we need for this to function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh thank you! this makes it so much smoother 🫶

@mabaasit
Copy link
Collaborator

the test failure seems to be legit

@paula-stacho paula-stacho merged commit b42fae4 into main May 22, 2025
40 of 55 checks passed
@paula-stacho paula-stacho deleted the COMPASS-9312 branch May 22, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat feature flagged PRs labeled with this label will not be included in the release notes of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants