-
Notifications
You must be signed in to change notification settings - Fork 247
feat: diagram edit handling COMPASS-9312 #6932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| try { | ||
| const res = await this.userData.readAll(); | ||
| return res.data; | ||
| return res.data as MongoDBDataModelDescription[]; |
There was a problem hiding this comment.
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
packages/compass-data-modeling/src/services/data-model-storage.ts
Outdated
Show resolved
Hide resolved
8cb592a to
e1175c3
Compare
| collections: z.array( | ||
| z.object({ | ||
| ns: z.string(), | ||
| jsonSchema: z.unknown(), // skipped for simplicity |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🫶
packages/compass-data-modeling/src/services/data-model-storage.ts
Outdated
Show resolved
Hide resolved
packages/compass-data-modeling/src/services/data-model-storage.ts
Outdated
Show resolved
Hide resolved
packages/compass-data-modeling/src/services/data-model-storage.ts
Outdated
Show resolved
Hide resolved
|
the test failure seems to be legit |
Description
TODO:
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes