dsh-whale-post-types
Verifieddsh-whale-post-types · v0.4.0 · MIT
邮件类型注册表接口 + 样例类型(direct/broadcast/club)
Install
dsh plugin add dsh-whale-post-types Confirm the layer applied with dsh --profile default --dump-config — see the install guide.
Source
Published to npm without a public repository. Inspect the package contents before installing.
Tags
Readme
dsh-whale-post-types
邮件类型注册表接口 + 样例类型(direct/broadcast/club)
- 提供接口:
whale.types - 依赖接口:(无)
- 自测:
node selftest.mjs(只看退出码:0 过/非 0 不过)
接口带 apiVersion;★核心不许知道任何类型标识 —— 所以类型是注册进来的 ✓。
接口
| 方法 | 一句话 |
|---|---|
register(id, meta) |
★注册一个类型:{ label, urgent, billable, priority, … }(★meta 缺省有默认值 ✓) |
resolve(id) |
★查这个类型注册过吗 ✓ |
list() |
★列出全部类型 ✓ |
meta(id) |
★同上,取不到 ⇒ null ✓ |
它守的那条线(★为什么要有这一件 ✗)
★★ 核心不认识任何类型标识 ✗ —— 所以类型随包只给三个样例 ✓:
direct(一对一)/broadcast(群发,可能很多人都要读)/club(小组内部)。
★要加新类型 ⇒ types.register('你自己的', { … }) —— ★核心一行都不用动 ✓。
★★未注册的类型一律当场拒 ✗(★不许悄悄当成默认类型 —— "急件类型写错就永远叫不醒人"这种事故我们栽过 ✓)。
配置
| 字段 | 默认 | 含义 |
|---|---|---|
types |
三个样例 | ★类型表;★数组与对象两种写法都认 ✓(['direct','club'] 或 { direct: {…} };★数组里写 [id, meta] 也认 ✓) |
extra |
不配 | ★在样例之外追加注册([[id, meta], …] ✓) |
边界(★)
- ★provider 撒谎拦不住 ✓ —— 核心不认识类型标识,所以它没法自己判定"什么才算合法类型" ✓; 要防这一层就在本件加校验与自测 ✓。
- ★类型标识必须出现在真实代码之外 ✓ —— 本件里只许出现在文档与样例块 ✓(有判据盯着 ✓)。