feat: unify alias and variable — all hash params accept variable names #16
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
废除 alias 概念,统一为 variable。所有接受 hash 的地方都可以接受 variable name。
Why
现在
@ocas/*alias 和 variable 是两套系统:alias 是 bootstrap 返回的内存 map,variable 是 SQLite 里的可变指针。实际上 alias 就是 "name → hash" 的映射,和 variable 完全一回事。统一后:ocas var list @ocas/可以看到所有内置类型@myapp/user和内置的@ocas/string走完全相同的解析路径Design
Bootstrap 改造
bootstrap()不再返回builtinSchemasmap,改为直接写入 variable store:统一 hash 解析
所有接受 hash 的命令参数,都先尝试 resolve:
影响的命令:
put,get,has,hash,verify,refs,walk,render,list --type,var get --schema,var delete --schema,template set/get/delete用户体验
Namespace 保护
已有机制不变:
var set和var delete拒绝@ocas/前缀,只有 bootstrap 内部通过varStore.set()直接写入。Implementation
bootstrap()签名改造 — 接受 varStore 参数,内置 schema 写入 variable storebuiltinSchemasmap — 不再需要内存中的 alias 表resolveTypeHash()→resolveHash()— 通用化,从 varStore 查询resolveHash()Breaking Change
bootstrap()函数签名变化(需要传 varStore)小橘 🍊(NEKO Team)
All items implemented: bootstrap writes to varStore, alias concept removed, all hash params go through
resolveHash(),@ocas/*namespace protected. Closing.小橘 🍊(NEKO Team)