mobile
lib/mobile.vklib/mobile.vk
Pure-Veko homoiconic mobile bridge specification (BridgeSpec), typed model/endpoint builders,
quote [...] bridge dialect parser (parse-bridge-quote), .secret wire redactor (redact-model),
and safe C-ABI / JNI / Swift JSON RPC dispatcher (dispatch-json).
Zero capabilities required.
FieldDef = struct { name str, typ str, default_lit str = ..., is_secret bool = ... }
Field descriptor for a mobile bridge model, state, or endpoint parameter list.
ModelDef = struct { name str, fields block[FieldDef] }
Data model or root AppState schema shared across Veko and Swift / Kotlin bindings.
EndpointDef = struct { kind enum, name str, params block[FieldDef], ret_type str }
Typed RPC endpoint descriptor (kind in .command or .query).
BridgeSpec = struct { name str, pkg_id str = ..., state_model ModelDef, models block[ModelDef] = ..., endpoints block[EndpointDef] = ... }
Complete mobile core bridge specification driving Swift/Kotlin binding generation and runtime dispatch.
field = fn [name str, typ str] FieldDef
Creates a non-secret FieldDef without a default value.
field-default = fn [name str, typ str, def_lit str] FieldDef
Creates a non-secret FieldDef with default literal def_lit.
secret-field = fn [name str, typ str] FieldDef
Creates a .secret-protected FieldDef (is_secret = true, automatically redacted across FFI/JSON).
model = fn [name str, fields block[FieldDef]] ModelDef
Creates a ModelDef schema from name and fields.
command = fn [name str, params block[FieldDef], ret_type str] EndpointDef
Creates a mutating .command EndpointDef.
query = fn [name str, params block[FieldDef], ret_type str] EndpointDef
Creates a read-only .query EndpointDef.
bridge-spec = fn [name str, pkg_id str, state_model ModelDef, models block[ModelDef], endpoints block[EndpointDef]] BridgeSpec
Assembles a complete BridgeSpec.
parse-bridge-quote = fn [name str, qblock block] BridgeSpec
Parses a homoiconic quote [...] mobile bridge specification block into a typed BridgeSpec.
use [mob = mobile]
spec = mob/parse-bridge-quote 'FieldSyncCore' (quote [
package 'dev.veko.fieldsync'
model VaultSession [
field user_id str
secret access_token str
]
state AppState [
field online bool true
]
command add-item [title str] bool
query list-pending [] block
])
if spec.pkg_id != 'dev.veko.fieldsync' or (len spec.models) != 1 or (not spec.models[0].fields[1].is_secret) or (len spec.endpoints) != 2 [
err 'parse-bridge-quote'
] else [ .ok ]
redact-model = fn [val any, spec BridgeSpec] any
Walks maps, structs, and blocks recursively, replacing any field marked is_secret == true in spec
(as well as any runtime .secret-tainted value) with '<secret>' prior to wire serialization.
dispatch-json = fn [handlers map, spec BridgeSpec, op str, payload_json str] str
Decodes payload_json, invokes op in handlers (map of op_name -> fn [map] any), catches Veko err
values as {"ok":false,"error":"..."}, redacts .secret fields per spec, and returns {"ok":true,"data":...}.
use [mob = mobile]
spec = mob/parse-bridge-quote 'Core' (quote [
model Session [ field uid str secret token str ]
state AppState [ field ready bool true ]
query current-session [] Session
])
handlers = {
'current-session' = fn [req map] any [ { uid = 'u1', token = 'live_secret_xyz' } ]
}
resp = mob/dispatch-json handlers spec 'current-session' '{}'
if (not (str/contains? resp '"ok":true')) or (not (str/contains? resp '"<secret>"')) or (str/contains? resp 'live_secret_xyz') [
err 'dispatch-json'
] else [ .ok ]