Alva.Resource.Transformers.DeriveLiveVueEncoder (Alva v0.1.2-dev)

Copy Markdown View Source

Automatically implements LiveVue.Encoder for resources using the Alva.Resource extension.

The generated implementation encodes exactly the resource's public fields (attributes, calculations, relationships and aggregates, as resolved by Alva.Registry.public_fields/1) and then re-encodes recursively, so nested Ash.NotLoaded/Ash.ForbiddenField/Ecto.Schema.Metadata values fall through to the default implementations in Alva.LiveView.Encoders. Internal struct fields (__metadata__, __meta__, __order__, ...) never cross the Vue boundary.

The implementation module is created with Module.create/3 and deliberately avoids any compile-time reference to the resource struct (no struct pattern), so it does not need to wait for the struct to be finalized. It also must not run in the after_compile?/after_verify phase: creating a module while the code server holds the verification lock deadlocks the parallel compiler.

A manually defined implementation (either defimpl or Protocol.derive in the host app) always wins and prevents the automatic derive.

Summary

Functions

after?(_)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(_)

Callback implementation for Spark.Dsl.Transformer.before?/1.

transform(dsl_state)

Callback implementation for Spark.Dsl.Transformer.transform/1.