@x1a0f3n9/dsh-typert-registry 0.1.5-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +131 -0
- package/README.zh.md +131 -0
- package/lib/client.js +1372 -0
- package/lib/index.js +562 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/index.js +12 -0
- package/lib/types/index.d.ts +18 -0
- package/lib/types/index.js +3 -0
- package/lib/types/service.d.ts +103 -0
- package/lib/types/service.js +600 -0
- package/lib/types/types.d.ts +100 -0
- package/lib/types/types.js +7 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/typert/registry/README.md
|
|
5
|
+
README.md: c1ab98ae8ebe720a29eb4fb339f39e00ce593120
|
|
6
|
+
README.zh.md: 7bf90ff8fd02c4fb17c4f57d1af251a7a4bd3116
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "The runtime Typert registry: stores generated package reflection, live Zod schemas, and Remote invocation descriptors, and resolves them for consumers."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @x1a0f3n9/dsh-typert-registry
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`dsh-typert-registry` makes generated Typert artifacts queryable at runtime: each package's reflection — services, events, and objects — its live Zod schemas, and Remote invocation descriptors live under stable keys that consumers can query or resolve on demand. Registrations are atomic and fiber-scoped: a contribution lands whole or not at all and is withdrawn automatically when the registering component unloads. The same service hosts the lookup and scoped-Context provider registries that Remote calls resolve through. It performs no TypeScript analysis and generates no schemas; the generator and the loader handle those.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
27
|
+
|
|
28
|
+
Mount the registry in any Host or Client composition that stores or consumes generated Typert artifacts; it provides `ctx.typert`. There is no configuration.
|
|
29
|
+
|
|
30
|
+
### Minimal setup
|
|
31
|
+
|
|
32
|
+
Load the registry plugin; the Client face is installed the same way by the Client runtime's own metadata, and both faces run the same implementation:
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
- name: '@x1a0f3n9/dsh-typert-registry'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Querying schemas and reflection
|
|
39
|
+
|
|
40
|
+
Consumers read schemas with `get(key)`, `resolve(key)`, or `list(filter?)` and package reflection with `getPackage(name, face?)` or `listPackages(filter?)`. `resolve()` distinguishes a malformed key, an absent package, and a registered package that contributes no schema under that name, each with its own error. `toJSONSchema(key)` projects a live Zod schema to JSON Schema without caching.
|
|
41
|
+
|
|
42
|
+
### Registering a contribution
|
|
43
|
+
|
|
44
|
+
Generated artifacts register through the [loader](../loader/README.md) in Loader compositions; any other owner calls `ctx.typert.register(contribution)` directly and receives the exact disposer that withdraws it. Duplicate package-face identities, schema keys, invocation ids, or endpoints reject the whole batch before anything is committed.
|
|
45
|
+
|
|
46
|
+
### Lookup and Context providers
|
|
47
|
+
|
|
48
|
+
Remote calls resolve Host objects and scoped Contexts through `ctx.typert.lookups` and `ctx.typert.contexts`. `registerHost()` installs the Host wire declaration and its wire-to-Context resolver, while `configureHost()` replaces only that resolver. `registerClient()` installs the bidirectional Client adapter for the same merge-declared kind. Host-to-Client event sources carry their domain identity explicitly instead of projecting it back from a Context.
|
|
49
|
+
|
|
50
|
+
-----
|
|
51
|
+
|
|
52
|
+
<a id="understand-the-implementation"></a>
|
|
53
|
+
## Understand the implementation
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary>Implementation internals — click to expand</summary>
|
|
57
|
+
|
|
58
|
+
This section explains how the registry stores and owns contributions; the consumer API is covered in [Use this package](#use-this-package).
|
|
59
|
+
|
|
60
|
+
### Design concept
|
|
61
|
+
|
|
62
|
+
The registry is built on one principle: a contribution is one atomic, fiber-owned commit. `register()` validates the package-face identity, schemas, and invocation descriptors first, then commits everything under a single Cordis effect whose disposer withdraws exactly that contribution. Duplicate identities fail at the owning operation boundary before any state changes.
|
|
63
|
+
|
|
64
|
+
### Sub-registries
|
|
65
|
+
|
|
66
|
+
- `ctx.typert.local` — current-environment invocation definitions, including `hasSeen()` history for source-mode fallback.
|
|
67
|
+
- `ctx.typert.remotes` — consumer-selected contributions mounted in the calling fiber.
|
|
68
|
+
- `ctx.typert.lookups` — lookup providers plus composition-owned resolver overrides per key.
|
|
69
|
+
- `ctx.typert.contexts` — Host Context providers and Client Context binders per scoped key.
|
|
70
|
+
|
|
71
|
+
Each sub-registry publishes `TypertRegistryChange` events to subscribed listeners; a throwing listener is logged and does not stop later listeners.
|
|
72
|
+
|
|
73
|
+
### Identity and validation
|
|
74
|
+
|
|
75
|
+
Keys are stable: `<package>#<face>` for reflection, `<package>#<name>` for schemas, and `<namespace>/<method>` for endpoints. Validation rejects names containing `#`, wire names outside the RPC segment grammar, duplicate keys, and lookup definitions whose wire declaration changes during the registry lifetime; strict codecs must carry a parseable schema.
|
|
76
|
+
|
|
77
|
+
### Source map
|
|
78
|
+
|
|
79
|
+
| File | Role |
|
|
80
|
+
|---|---|
|
|
81
|
+
| [`src/service.ts`](src/service.ts) | `TypertRegistry` service, stores, validation, effect wiring |
|
|
82
|
+
| [`src/types.ts`](src/types.ts) | Contribution, record, and filter types |
|
|
83
|
+
| [`src/client/index.ts`](src/client/index.ts) | Client face installing the same registry |
|
|
84
|
+
| — | No runtime invariant companion is published; schema and package-reflection records mutate together inside register/dispose, with no independent event or second data source to cross-check; duplicate identities fail at the owning operation boundary. |
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
-----
|
|
89
|
+
|
|
90
|
+
<a id="further-exploration"></a>
|
|
91
|
+
## Further Exploration
|
|
92
|
+
|
|
93
|
+
Read these pages when the package-level contract is not enough; they move from the registry to what feeds it and what consumes it.
|
|
94
|
+
|
|
95
|
+
- [Typert loader](../loader/README.md) — automatic registration of generated host artifacts.
|
|
96
|
+
- [Typert generator](../generator/README.md) — what produces the contributions the registry stores.
|
|
97
|
+
- [Typert protocol](../protocol/README.md) — the descriptors, codecs, and provider contracts the registry serves.
|
|
98
|
+
- [Typert subsystem reference](../../../docs/subsystems/typert.md) — the literal `ctx.typert` contract.
|
|
99
|
+
- [API Gateway reference](../../../docs/api-gateway.md) — the main consumer of invocation descriptors and providers.
|
|
100
|
+
|
|
101
|
+
-----
|
|
102
|
+
|
|
103
|
+
<a id="model-experience"></a>
|
|
104
|
+
## Model Experience
|
|
105
|
+
|
|
106
|
+
None, as this runtime type registry's consumers (cordis_inspect, wire faces, gates) own any model-visible projection of registry contents.
|
|
107
|
+
|
|
108
|
+
#### KV Cache effect
|
|
109
|
+
|
|
110
|
+
No direct effect; a consumer that places reflection or schemas in a request owns the resulting prefix change.
|
|
111
|
+
|
|
112
|
+
## Known Limitations and Deferred Work
|
|
113
|
+
|
|
114
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
These limits define what the registry stores and rejects; they are current package constraints, not a task backlog.
|
|
118
|
+
|
|
119
|
+
- **No graph merging** — the registry stores generated reflection per face but does not merge host and client graphs or resolve TypeScript references; those are analyzer and emitter concerns.
|
|
120
|
+
- **Schema keys omit the face** — host and client run in separate contexts, so registering same-named schemas from both faces into one context is rejected as a duplicate.
|
|
121
|
+
- **JSON Schema projection is uncached** — `toJSONSchema()` returns a fresh document per call; consumers that project repeatedly own caching.
|
|
122
|
+
|
|
123
|
+
<a id="dev-note"></a>
|
|
124
|
+
### Dev Note
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
128
|
+
|
|
129
|
+
None.
|
|
130
|
+
|
|
131
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "运行时 Typert 注册表:保存生成的包反射、实时 Zod schema 与 Remote 调用描述符,并按需为消费方解析。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @x1a0f3n9/dsh-typert-registry
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-typert-registry` 让生成的 Typert 产物在运行时可按需查询:每个包的反射——服务、事件与对象——其实时 Zod schema 与 Remote 调用描述符都保存在稳定键下,消费方可以按需查询或解析。注册是原子且按 fiber 作用域的:贡献要么整体落地要么完全不落地,并在注册组件卸载时自动撤销。同一服务还托管 Remote 调用所经由的 lookup 与作用域 Context 提供方注册表。它不执行 TypeScript 分析,也不生成 schema;这些由生成器与 loader 负责。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
27
|
+
|
|
28
|
+
在存储或消费生成 Typert 产物的任何 Host 或 Client 组合中挂载本注册表;它提供 `ctx.typert`。没有配置。
|
|
29
|
+
|
|
30
|
+
### 最小设置
|
|
31
|
+
|
|
32
|
+
加载注册表插件;Client face 由 Client 运行时自身的元数据以同样方式安装,两个 face 运行同一实现:
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
- name: '@x1a0f3n9/dsh-typert-registry'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 查询 schema 与反射
|
|
39
|
+
|
|
40
|
+
消费方用 `get(key)`、`resolve(key)` 或 `list(filter?)` 读取 schema,用 `getPackage(name, face?)` 或 `listPackages(filter?)` 读取包反射。`resolve()` 能区分格式错误的键、未注册的包,以及已注册但未以该名称提供 schema 的包,各自给出不同的错误。`toJSONSchema(key)` 把实时 Zod schema 投影为 JSON Schema,且不缓存结果。
|
|
41
|
+
|
|
42
|
+
### 注册贡献
|
|
43
|
+
|
|
44
|
+
生成产物在 Loader 组合中通过 [loader](../loader/README.zh.md) 注册;其他所有者直接调用 `ctx.typert.register(contribution)`,并获得撤销它的同一资源释放函数。重复的包与 face 组合键、schema 键、调用 id 或端点会在提交任何内容之前拒绝整个批次。
|
|
45
|
+
|
|
46
|
+
### Lookup 与 Context 提供方
|
|
47
|
+
|
|
48
|
+
Remote 调用通过 `ctx.typert.lookups` 与 `ctx.typert.contexts` 解析 Host 对象与作用域 Context。`registerHost()` 安装 Host wire 声明及其 wire 到 Context 的 resolver,`configureHost()` 只替换该 resolver。`registerClient()` 为同一个 merge-declared kind 安装双向 Client adapter。Host 到 Client 的事件源显式携带领域 identity,而不从 Context 反向投影。
|
|
49
|
+
|
|
50
|
+
-----
|
|
51
|
+
|
|
52
|
+
<a id="understand-the-implementation"></a>
|
|
53
|
+
## 理解实现
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary>实现细节——点击展开</summary>
|
|
57
|
+
|
|
58
|
+
本节解释注册表如何存储与拥有贡献;消费方 API 已在[使用本包](#use-this-package)中说明。
|
|
59
|
+
|
|
60
|
+
### 设计理念
|
|
61
|
+
|
|
62
|
+
注册表建立在一个原则之上:贡献是一次原子、由 fiber 拥有的提交。`register()` 先校验包与 face 组合键、schema 与调用描述符,再在单个 Cordis effect 下提交全部内容,该 effect 的资源释放函数精确撤销这一贡献。重复标识在拥有该操作的所有权边界失败,此时任何状态都未改变。
|
|
63
|
+
|
|
64
|
+
### 子注册表
|
|
65
|
+
|
|
66
|
+
- `ctx.typert.local`——当前环境的调用定义,含供源码模式回退使用的 `hasSeen()` 历史。
|
|
67
|
+
- `ctx.typert.remotes`——在调用方 fiber 中挂载的、由消费方选中的贡献。
|
|
68
|
+
- `ctx.typert.lookups`——lookup 提供方,以及按键配置的组合方解析器覆盖。
|
|
69
|
+
- `ctx.typert.contexts`——按作用域键配置的 Host Context 提供方与 Client Context 绑定器。
|
|
70
|
+
|
|
71
|
+
每个子注册表都会向已订阅的监听器发布 `TypertRegistryChange` 事件;抛异常的监听器会被记录日志,且不会阻止后续监听器。
|
|
72
|
+
|
|
73
|
+
### 标识与校验
|
|
74
|
+
|
|
75
|
+
键是稳定的:反射用 `<package>#<face>`,schema 用 `<package>#<name>`,端点用 `<namespace>/<method>`。校验会拒绝含 `#` 的名称、超出 RPC 端点段文法的 wire 名称、重复键,以及在其注册表生命周期内改变 wire 声明的 lookup 定义;严格编解码器必须携带可解析的 schema。
|
|
76
|
+
|
|
77
|
+
### 源码地图
|
|
78
|
+
|
|
79
|
+
| 文件 | 职责 |
|
|
80
|
+
|---|---|
|
|
81
|
+
| [`src/service.ts`](src/service.ts) | `TypertRegistry` 服务、存储、校验、effect 接线 |
|
|
82
|
+
| [`src/types.ts`](src/types.ts) | 贡献、记录与过滤器类型 |
|
|
83
|
+
| [`src/client/index.ts`](src/client/index.ts) | 安装同一注册表的 Client face |
|
|
84
|
+
| — | 不发布运行时不变式伴生入口;schema 与 package-reflection record 在 register/dispose 内一起变更,没有独立 event 或第二数据源可供交叉核对;重复 identity 在所属操作处失败。 |
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
-----
|
|
89
|
+
|
|
90
|
+
<a id="further-exploration"></a>
|
|
91
|
+
## 进一步探索
|
|
92
|
+
|
|
93
|
+
当包级约定不够用时阅读以下页面;它们从注册表逐步进入供给它与消费它的内容。
|
|
94
|
+
|
|
95
|
+
- [Typert loader](../loader/README.zh.md)——生成宿主产物的自动注册。
|
|
96
|
+
- [Typert 生成器](../generator/README.zh.md)——产生注册表所存贡献的包。
|
|
97
|
+
- [Typert 协议](../protocol/README.zh.md)——注册表所服务的描述符、编解码器与提供方约定。
|
|
98
|
+
- [Typert 子系统参考](../../../docs/subsystems/typert.zh.md)——字面的 `ctx.typert` 约定。
|
|
99
|
+
- [API Gateway 参考](../../../docs/api-gateway.zh.md)——调用描述符与提供方的主要消费方。
|
|
100
|
+
|
|
101
|
+
-----
|
|
102
|
+
|
|
103
|
+
<a id="model-experience"></a>
|
|
104
|
+
## 模型体验
|
|
105
|
+
|
|
106
|
+
无,因为该运行时类型注册表的消费方(cordis_inspect、wire faces、门禁)拥有注册表内容的任何模型可见投影。
|
|
107
|
+
|
|
108
|
+
#### KV Cache 影响
|
|
109
|
+
|
|
110
|
+
无直接影响;把反射或 schema 放入请求的消费方负责由此产生的前缀变化。
|
|
111
|
+
|
|
112
|
+
## 已知限制与延期工作
|
|
113
|
+
|
|
114
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
这些限制说明注册表存储与拒绝什么;它们是当前包约束,不是任务积压。
|
|
118
|
+
|
|
119
|
+
- **不合并图**——注册表按 face 存储生成的反射,但不合并宿主侧与客户端侧的图,也不解析 TypeScript 引用;这些是分析器与生成器的事。
|
|
120
|
+
- **schema 键不含 face**——宿主侧与客户端侧在不同上下文中运行,因此在同一上下文中注册来自两个 face 的同名 schema 会被作为重复项拒绝。
|
|
121
|
+
- **JSON Schema 投影不缓存**——`toJSONSchema()` 每次调用都返回全新文档;需要重复投影的消费方自行负责缓存。
|
|
122
|
+
|
|
123
|
+
<a id="dev-note"></a>
|
|
124
|
+
### 开发备注
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
128
|
+
|
|
129
|
+
无。
|
|
130
|
+
|
|
131
|
+
</details>
|