ciallo-gen

    Compile-time code generator for unmbt/ciallo (#ciallo.schema, OpenAPI Eden SDK, #orm.*, wire DI, and migrate CLI)

    codegen
    openapi
    rpc
    ciallo
    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    13 hours ago
    Downloads
    8

    #unmbt/ciallo-gen

    Compile-time code generator for unmbt/ciallo: #ciallo.schema -> impl @schema.Schema and OpenAPI 3.1 -> ciallo-eden TypeScript & MoonBit RPC SDKs.

    GenError

    pub(all) suberror GenError {
    InvalidSource(file~ : String, line~ : Int, message~ : String)
    UnsupportedConstruct(file~ : String, line~ : Int, message~ : String)
    InvalidOpenApi(String)
    DriftDetected(path~ : String)
    } derive(Eq,
    Debug
    )

    ProviderSpec

    pub(all) struct ProviderSpec {
    file : String
    line : Int
    fn_name : String
    is_async : Bool
    params : Array[(String, String)]
    return_type : String
    } derive(Eq,
    Debug
    )

    extract_orm_snapshot

    fn extract_orm_snapshot(source : String, file_name? : String) ->
    SchemaSnapshot
    raise GenError

    从带 #orm.table 注解的 MoonBit 源码提取 SchemaSnapshot(供 ciallo-gen migrate diff 使用)

    generate_eden_mbt

    fn generate_eden_mbt(openapi_json :
    Json
    ) -> String raise GenError

    generate_eden_ts

    fn generate_eden_ts(openapi_json :
    Json
    ) -> String raise GenError

    generate_orm_source

    fn generate_orm_source(source : String, file_name? : String) -> String raise GenError

    编译期生成 #orm.table 与 #orm.sql 对应的零反射 ORM 绑定代码(TableRef / Col / FromRow / UserQueries[E] / 防 N+1 预加载 / 参数校验)

    generate_schema_source

    fn generate_schema_source(source : String, file_name? : String) -> String raise GenError

    generate_wire_source

    fn generate_wire_source(files : Array[(String, String)], wire_fn_name? : String) -> String raise GenError

    编译期静态 DI 依赖图拓扑排序 + 环依赖检测 + 零反射装配代码生成

    introspect_snapshot_to_mbt

    fn introspect_snapshot_to_mbt(snapshot :
    SchemaSnapshot
    ) -> String

    DB-first 逆向建模:将 SchemaSnapshot 反向生成干净的带 #orm.table 注解的 MoonBit Struct(严格遵守 ADR-013 规范拼写)

    parse_wire_providers

    fn parse_wire_providers(files : Array[(String, String)]) -> Array[ProviderSpec] raise GenError

    确定性按文件字典序扫描包内所有 #ciallo.provider 函数(自动跳过 *_test.mbt 与 *.gen.mbt)