feat: add standard schema support for schemaTask#3058
feat: add standard schema support for schemaTask#3058Shaik-Sirajuddin wants to merge 2 commits intotriggerdotdev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 8609ffd The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @Shaik-Sirajuddin, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. WalkthroughThis PR adds support for the Standard Schema specification (v1) as a new validation library option for Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| | SchemaMyZodEsque<TInput> | ||
| | SchemaScaleEsque<TInput> | ||
| | SchemaSuperstructEsque<TInput> | ||
| | SchemaYupEsque<TInput>; | ||
| | SchemaYupEsque<TInput> | ||
| | StandardSchemaV1<TInput>; | ||
|
|
||
| export type SchemaWithInputOutput<TInput, TParsedInput> = | ||
| | SchemaZodEsque<TInput, TParsedInput> | ||
| | SchemaValibotEsque<TInput, TParsedInput> | ||
| | SchemaArkTypeEsque<TInput, TParsedInput>; | ||
| | SchemaArkTypeEsque<TInput, TParsedInput> | ||
| | StandardSchemaV1<TInput, TParsedInput>; |
There was a problem hiding this comment.
🚩 StandardSchemaV1 added to both SchemaWithInputOutput and SchemaWithoutInput may cause ambiguous type inference
StandardSchemaV1<TInput, TParsedInput> is added to both SchemaWithInputOutput at line 82 and SchemaWithoutInput at line 76. The inferSchema type at line 86-98 first checks SchemaWithInputOutput then SchemaWithoutInput. Since StandardSchemaV1<TInput> (single type param) defaults Output = Input, it matches both unions.
This means TypeScript's conditional type resolution will always match SchemaWithInputOutput first for a StandardSchemaV1 schema, giving { in: TInput, out: TOutput }. The SchemaWithoutInput branch would only be reached if inference from SchemaWithInputOutput fails. In practice, StandardSchemaV1 carries its types via ~standard.types.input and ~standard.types.output, so the SchemaWithInputOutput match should infer correctly. However, the dual membership is redundant and could confuse contributors — the existing patterns (Zod, Valibot, ArkType) only appear in one union, not both.
(Refers to lines 70-82)
Was this helpful? React with 👍 or 👎 to provide feedback.
|
PTAL @ericallam |
Closes #1642
✅ Checklist
Testing
[Describe the steps you took to test this change]
Create a schema with validate.js in hello-world
validate.js is not natively supported by trigger.dev but implements standard-schema
Pass it to schemaTask with a logging behaviour for task
Example :
3.Run the json-schema-trigger-examples
4. call it inside triggerExamles once with valid type and perform another run with invalid type
Ex :
Changelog
Added support for standard schema
Screenshots
Code Example :

💯
Failed Validation :
