ciallo

    Cross-runtime MoonBit web framework with explicit 9-stage lifecycle, scoped encapsulation, typed routes, schema normalization, and OpenAPI 3.1

    web
    framework
    router
    openapi
    serverless
    wintertc
    Download zip
    Author
    Version
    0.3.0
    License
    MIT
    Last updated
    5 hours ago
    Downloads
    26

    #unmbt/ciallo

    Cross-runtime MoonBit Web framework with Radix routing, explicit 9-stage lifecycle pipeline, scoped plugin encapsulation, ContextKey[T], Nullable[T]/Base64Bytes/SchemaRef contracts, RFC 9457 ProblemDetails, OpenAPI 3.1 + Scalar UI, and queue-isolated SSE heartbeats.

    See SKILL.md and ../../README.mbt.md.

    App

    using @unmbt/ciallo/core { type App }

    ciallo 应用引擎(组装期可变 Builder,首次调用 App::fetch 或显式 App::freeze 后拍平冻结为只读结构,此后篡改抛 AppBuildError::AlreadyFrozen)

    AppBuildError

    统一应用组装期受检异常(覆盖路由冲突、重复依赖注册、重复 operation_id 与运行期冻结后篡改)

    AppOptions

    Base64Bytes

    基于标准库 moonbitlang/core/encoding/base64 的一等公民 Base64 二进制载荷包装器(替代标准库 \xHH 转义的裸 Bytes,OpenAPI 映射为 format: "byte")

    Body

    using @unmbt/webstd/http { type Body }

    ByteStream

    异步流式载荷抽象(语言级 async 协程签名,生产代码零 core/async 依赖,四目标均可编译)

    CapabilityBundle

    Clock

    可移植单调/墙钟微秒与毫秒时钟抽象(真实时间戳保留 Int64)

    CompiledSchema

    Precompiled, cycle-safe JSON Schema validator & normalizer. Resolves SchemaRef once and pre-builds immutable Object field lookup maps so validating large arrays or hot route payloads allocates zero intermediate maps.

    Context

    请求级上下文(内部采用 Unread | Buffered(Bytes, Json?) | StreamConsumed 三态缓存与头/Cookie 操作队列)

    ContextKey

    零反射、零 unsafe 强类型上下文键(支持在定义 Key 时绑定 ctx.require 缺失状态码,如鉴权 401、租户头 400)
    using @unmbt/webstd/http { type Cookie }

    一等公民结构化 Cookie(支撑 ciallo-native 1:1 零重解析映射至 @std_http.Cookie,及 ciallo-js append("set-cookie");序列化时严格拒绝含 \r / \n / ; 控制字符以防头注入)

    CookieOptions

    CursorPage

    Env

    using @unmbt/ciallo/runtime { type Env }

    运行期纯只读环境变量与宿主绑定容器(Native 启动构建一次零拷贝共享,JS Workers 按请求零开销包装宿主 env)

    EnvBuilder

    组装期环境变量与宿主绑定构建器(构建完成后生成运行期纯只读 Env,根除 Native 多协程跨请求状态污染)

    ExecutionContext

    请求级异步任务托管上下文(Native 走任务组收尾,JS Workers 透传 ctx.waitUntil)

    FieldMask

    稀疏字段掩码(支持逗号分隔与点分嵌套路径,如 "id,name,profile.avatar")

    FixedClock

    FromParam

    Strongly-typed URL path parameter decoder shared across unmbt/ciallo/schema, unmbt/ciallo/core (Context::param_as), and 4-target pure ID packages like unmbt/ciallo-id.

    Headers

    大小写不敏感的多值 HTTP 头集合(保留同键多值顺序)

    HealthCheck

    HealthStatus

    标准就绪探针契约(供 CapabilityBundle 注册与 ciallo-actuator /readyz 并行聚合)

    HttpClient

    可移植出站 HTTP 客户端抽象

    HttpError

    IntoResponse

    KvStore

    可移植键值存储抽象

    Lifecycle

    统一拓扑启停生命周期契约(Native 收到 SIGTERM 按依赖逆序优雅释放;Workers 模式可被 Tree-shake)

    LifecyclePhase

    MemoryKv

    Method

    using @unmbt/webstd/http { type Method }

    MockHttpClient

    NdjsonDecoder

    纯同步增量 NDJSON 解码状态机(支持有界行缓冲与首帧 UTF-8 BOM 剥离,四目标全通测试)

    NoContent

    204 No Content 强类型零开销哨兵(schema_id = "ciallo.NoContent",OpenAPI 生成无 content 的 204,Eden 映射为 void/Unit)

    Nullable

    一等公民标准 JSON 可空包装器(编码为标准 null | T,打通顶层/容器可空值与 PATCH field : Nullable[T]? 三态语义;严禁误用标准库单元素数组 [v] 编码的通用 T?)

    ObjectField

    OpenApiDocument

    OpenApiError

    OpenApiInfo

    OperationSpec

    Page

    using @unmbt/ciallo/schema { type Page }

    统一分页契约(定居于 v0.1 四目标纯核,total : Int64 自动按 Int64String 导出至 OpenAPI 3.1 / ciallo-eden)

    PluginMeta

    ProblemDetails

    RFC 9457 (Problem Details) 标准化错误输出(application/problem+json)

    Request

    Response

    ResponseKind

    代数响应载荷分类(同时驱动 OpenAPI 3.1、x-ciallo-eden MoonBit/TS 流式 SDK 与 v0.3 ciallo-mcp)

    ResponseSpec

    RouteConflict

    RouteMatch

    RouteOptions

    RouteParams

    Router

    Radix/Trie 路由表(不透明类型,分段匹配完成后再对单段参数做 RFC 3986 解码以防 %2F 穿越)

    RuntimeError

    SameSite

    Schema

    以内置 Self? 作为零分配类型锚点,规避无关联类型限制与多 Trait 约束分派警告(Warning 0083 / Error 4018)

    SchemaMeta

    通用 Schema 元数据(支撑 OpenAPI 3.1 文档、TypeScript JSDoc 注释与 MCP Tool 描述)

    SchemaNode

    SchemaRef

    惰性自引用断环包装器(自定义按 id 判等的 Eq/Debug,既支持 SchemaNode #derive(Debug, Eq),又杜绝递归类型爆栈并自动聚拢至 #/components/schemas/) 内部持单次求值缓存槽,避免数组批量校验时重复展开整棵 SchemaNode 树。

    Scope

    using @unmbt/ciallo/core { type Scope }

    SseDecoder

    纯同步增量 SSE 解码状态机(支持有界缓冲防 OOM、WHATWG lastEventId 持久状态、首帧 UTF-8 BOM 剥离与跨 chunk 拆包,四目标全通测试)

    SseEvent

    一等公民 Server-Sent Events(SSE)结构化事件帧、泛型强类型事件帧与四目标纯同步增量解码器

    StreamError

    流式读写与载荷上限标准错误(防断连静默与 OOM)

    SystemClock

    跨平台真实墙钟时钟(Native / JS / Wasm 三目标开箱即用,底层复用 @async.now() 毫秒时间戳)

    TraceContext

    W3C Trace Context (traceparent / tracestate) 全链路贯通上下文

    TraceEvent

    TraceSummary

    TypedSseEvent

    Url

    using @unmbt/webstd/url { type Url }

    UrlError

    ValidationError

    ValidationIssue

    WsCloseCode

    WsError

    WsHandler

    First-class WebSocket route handler receiving the authenticated request Context (with path params, DI state, and TraceContext) and the upgraded &@runtime.WsPeer.

    WsMessage

    WsPeer

    Platform-neutral WebSocket peer contract shared across Native (core/async/websocket), Cloudflare Workers (WebSocketPair), Bun (ServerWebSocket), and Node.js (RFC 6455).

    WsUpgradeCallback

    type WsUpgradeCallback = async (&
    WsPeer
    ) -> Unit

    Adapter-invoked upgrade callback receiving the established &WsPeer.

    WsUpgradeSlot

    Per-request upgrade handoff slot populated by App::ws after all pipeline guards succeed.

    normalize_json

    响应脱敏(Exact Mirror Normalization):按 SchemaNode 树递归剔除未在 Object Schema 声明的多余字段(如 passwordHash)

    project_json

    安全稀疏字段投影:严格求 FieldMask ∩ response_schema 交集,绝不透出未在 Schema 声明的敏感字段; 对 Page[T] / CursorPage[T] 分页包装器,若未显式指定 items 路径且请求了元素字段,则自动保留分页元数据并将掩码下推至 items 元素。

    remote_addr_key

    let remote_addr_key :
    ContextKey
    [String]

    scalar_html

    fn scalar_html(title~ : String, spec_url? : String, script_url? : String, custom_css? : String) -> String

    生成内置 Scalar 交互式 API 文档 HTML(支持内网离线替换 script_url 与 custom_css,注入属性严格 HTML 转义防 XSS)

    schema_of

    供业务与 ciallo-gen 生成代码以 @schema.schema_ref_of((None : FieldType?)) 零反射委托给 moonc 消解类型

    status_reason

    fn status_reason(code : Int) -> String

    RFC 9110 标准 HTTP 状态短语(未知状态码回退 "",供 ciallo-native send_response 零分配调用)

    ws_upgrade_slot_key

    Context binding key used by HTTP adapters to pass a per-request WsUpgradeSlot into App::fetch.

    Source Files