typed_llm_generator 0.2.0
typed_llm_generator: ^0.2.0 copied to clipboard
build_runner code generator that turns @LlmSchema-annotated classes into JSON Schemas and validated-JSON factories for the typed_llm package.
0.2.0 #
Requires typed_llm ^0.2.0.
Added #
- Every
@LlmSchema()class now also generates$<Class>, aconst LlmType<Class>binding<Class>Schemato_$<Class>FromValidatedJson. This is what you pass toExtractor.extract, and it is what makes the call type-safe — seetyped_llm's 0.2.0 changelog for the mismatch it rules out.
Changed #
<Class>Schemaand the generated members now carry dartdoc, so they no longer trippublic_member_api_docsin projects that lint generated code.
Existing output is otherwise unchanged: <Class>Schema and
_$<Class>FromValidatedJson keep their names and shapes, so a
fromValidatedJson wrapper you already wrote still compiles. It is now
redundant, though — $<Class> points at the factory directly.
0.1.0 #
Initial release.
-
Requires Dart 3.9 or newer, and builds on the analyzer 2.0 element model (
analyzer >=9.0.0 <15.0.0,source_gen ^4,build ^4). The analyzer range is deliberately wide so this generator co-resolves with whatever other codegen packages —freezed,json_serializable— pin in the same app. Verified against analyzer 10.2.0 and 12.1.0, including a resolve alongsidefreezed3.x. -
LlmSchemaGenerator(build.yamlkeyllm_schema): turns an@LlmSchema()-annotated class into a<Class>SchemaJSON Schema constant and a_$<Class>FromValidatedJsonfactory function. -
Supports primitives (
String,int,double,num,bool),DateTime(as an ISO-8601date-timestring), enums (as a stringenum), nullable fields,List<T>, and nested@LlmSchemaclasses — all resolved recursively and inlined into both the schema and the factory. -
Works on freezed classes: reads constructor parameters from a redirecting
const factoryconstructor the same way it reads a plain generative one. -
Clear, actionable build-time errors for unsupported field types, positional constructor parameters, and
@LlmField(optional: true)on a non-nullable field.