-
-
Notifications
You must be signed in to change notification settings - Fork 741
feat: add effect schema as part of the standard and JSON schema implementation #3662
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
base: main
Are you sure you want to change the base?
Conversation
|
Someone is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
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.
Additional Suggestion:
The Effect Schema implementation is never registered in the validators context, so it will never be used even when the package is installed. The actual toJSONSchema implementation will never be called.
View Details
π Patch Details
diff --git a/src/utils/dependencies.ts b/src/utils/dependencies.ts
index fd5eb804..fde3d6d3 100644
--- a/src/utils/dependencies.ts
+++ b/src/utils/dependencies.ts
@@ -76,4 +76,7 @@ export async function initiateValidatorsContext() {
nuxtContentContext().set('zod3', await import('./schema/zod3'))
nuxtContentContext().set('zod4', await import('./schema/zod4'))
}
+ if (await isPackageInstalled('effect')) {
+ nuxtContentContext().set('effect', await import('./schema/effect'))
+ }
}
Analysis
Effect Schema handler not registered in initiateValidatorsContext()
What fails: The initiateValidatorsContext() function in src/utils/dependencies.ts (lines 71-79) only registers handlers for Valibot and Zod schema validators, but does not register the Effect schema handler. This causes the default error handler to be used instead of the actual Effect implementation, preventing Effect Schema from working.
How to reproduce:
- Install the
effectpackage in a project using @nuxt/content - Create a collection with an Effect schema:
import { Schema as S } from 'effect'
import { defineCollection } from '@nuxt/content'
export const posts = defineCollection({
type: 'page',
source: 'posts/**',
schema: S.Struct({
title: S.String,
author: S.String,
})
})- Try to use the collection - it will fail with "Effect is not installed" error even though the package IS installed
Result: When defineCollection() calls nuxtContentContext().get('effect'), it receives the default error handler from src/utils/context.ts that throws: "It seems you are using Effect Schema for collection schema, but Effect is not installed"
Expected: Should return the actual implementation from src/utils/schema/effect.ts which uses JSONSchema.make() to convert the schema
Fix applied: Added Effect schema registration to initiateValidatorsContext():
if (await isPackageInstalled('effect')) {
nuxtContentContext().set('effect', await import('./schema/effect'))
}This matches the same pattern used for Valibot and Zod registration, ensuring the real Effect schema handler is properly registered when the package is installed.
π Linked issue
Related to #3524 - only adding implementation for Effect Schema since #3524 only support valibot and zod
β Type of change
π Description
Nuxt Content only currently support Zod and Valibot for the StandardSchemaV1 and JSON Schema. Effect Schema both support the StandardSchemaV1 and JSON Schema but it is not supported by Nuxt Content
π Checklist