Skip to content
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

[UXIT-1509] Enable strict mode for ecosystem entries [skip percy] #691

Merged
merged 11 commits into from
Oct 9, 2024

Conversation

CharlyMartin
Copy link
Collaborator

@CharlyMartin CharlyMartin commented Oct 2, 2024

📝 Description

This PR updates how we handle Zod validations, starting with ecosystem projects. I prioritized these updates over digest articles because the comms team is now merging PR on their own, so this will be a necessary safety net.

I had to rework our Zod Validations in order to enable strict mode, which throws an error when unrecognized keys are found in the object.

🛠️ Key Changes

  • Updated the EcosystemProjectFrontMatter schema - and the schemas it extended - to use kebab-case for property keys, aligning with the data format from the CMS.
  • Since the rest of the codebase uses camelCase, I installed the camelcase-keys package (npm) to convert the object keys to standard JavaScript format.

Some code duplication was required to maintain compatibility with the other Zod Schemas:

  • BaseDataSchemaKebabCase is a temporary duplicate of DynamicBaseDataSchema
  • getMarkdownData is a temporary duplicate of getData

🧪 How to Test

Add an extra field to any ecosystem entry, build the project, and ensure it fails as expected.

Copy link

vercel bot commented Oct 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
filecoin-foundation-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 9:53am

Copy link

sentry-io bot commented Oct 2, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: src/app/_utils/convertMarkdownToEventData.ts

Function Unhandled Issue
convertMarkdownToEventData Error: EventFrontMatterSchema is not defined /eve...
Event Count: 1 Affected Users: 1
convertMarkdownToEventData ReferenceError: EventFrontMatterSchema is not defined Page.generateMetadata (/events/[s...
Event Count: 1 Affected Users: 0
convertMarkdownToEventData ReferenceError: EventFrontMatterSchema is not defined Page Server Component (/events/[s...
Event Count: 1 Affected Users: 0

Did you find this useful? React with a 👍 or 👎

Copy link


import { CategorySchema, SubcategorySchema } from './CategorySchemas'

export const EcosystemProjectFrontMatter = DynamicBaseDataSchema.extend({
// email and full-name are required in the CMS but optional here because some entries still don't have them
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's change the data - If I remember correctly, Matt was putting in his own email address for the ones that don't have it.

Copy link
Collaborator Author

@CharlyMartin CharlyMartin Oct 9, 2024

Choose a reason for hiding this comment

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

Yes good point, let's do that.

Copy link
Collaborator

@mirhamasala mirhamasala left a comment

Choose a reason for hiding this comment

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

@CharlyMartin - Super happy about this! Looking good! I would prefer if we make the email and full-name required and address the data inconsistencies in this PR. Thank you.

@CharlyMartin
Copy link
Collaborator Author

CharlyMartin commented Oct 9, 2024

@mirhamasala I added name and full-name to all Markdown entries where they were missing. It was the case for most of them as you can see in the file diff. I used Matt's full name and email as the default.

I used a script to do this, it was a bit tricky due to the encryption step, but it worked :) I checked a handful of files locally via the CMS, and they show the right data.

@CharlyMartin CharlyMartin changed the title [UXIT-1509] Enable strict mode for ecosystem entries [UXIT-1509] Enable strict mode for ecosystem entries [skip percy] Oct 9, 2024
Copy link
Collaborator

@mirhamasala mirhamasala left a comment

Choose a reason for hiding this comment

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

@CharlyMartin - This is good to go! 🙌🏼🧀 Let's get the other ones sorted too! 🤩

Tag @barbaraperic for visibility~

@mirhamasala mirhamasala removed the request for review from barbaraperic October 9, 2024 14:20
@CharlyMartin CharlyMartin merged commit 458e0e7 into main Oct 9, 2024
5 checks passed
@CharlyMartin CharlyMartin deleted the cm/enable-zod-strict-for-md branch October 9, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants