feat: diagram edit handling COMPASS-9312#6932
Conversation
| try { | ||
| const res = await this.userData.readAll(); | ||
| return res.data; | ||
| return res.data as MongoDBDataModelDescription[]; |
There was a problem hiding this comment.
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.
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.
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