@deepseek-ai/dsh-typert-registry 0.2.1-alpha.2 → 0.2.1-alpha.4
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/README.i18n.yaml +10 -10
- package/README.md +8 -1
- package/README.zh.md +8 -1
- package/lib/client.browser.js +656 -0
- package/lib/client.node.js +646 -0
- package/lib/index.js +55 -0
- package/lib/types/service.d.ts +4 -1
- package/lib/types/service.js +49 -0
- package/locale/en.json +5 -0
- package/locale/zh.json +6 -0
- package/package.json +13 -8
- package/lib/client.js +0 -1387
package/README.i18n.yaml
CHANGED
|
@@ -15,20 +15,20 @@
|
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
17
17
|
/deepseek-ai-dsh-typert-registry/use-this-package:
|
|
18
|
-
en:
|
|
19
|
-
zh:
|
|
18
|
+
en: eeeaecf7800bcb6b
|
|
19
|
+
zh: 2562380c15cb2428
|
|
20
20
|
/deepseek-ai-dsh-typert-registry/use-this-package/minimal-setup:
|
|
21
21
|
en: 1ec4b304a024bb3c
|
|
22
22
|
zh: f17e796c26faabab
|
|
23
23
|
/deepseek-ai-dsh-typert-registry/use-this-package/querying-schemas-and-reflection:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: 254d265a3e5b1638
|
|
25
|
+
zh: bfa325ec79afbc72
|
|
26
26
|
/deepseek-ai-dsh-typert-registry/use-this-package/registering-a-contribution:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: 9ca425515904d5c9
|
|
28
|
+
zh: b251226ecfa32002
|
|
29
29
|
/deepseek-ai-dsh-typert-registry/use-this-package/lookup-and-context-providers:
|
|
30
|
-
en:
|
|
31
|
-
zh:
|
|
30
|
+
en: 937dfd14d9e18a5c
|
|
31
|
+
zh: 6cf6aa352c8825c6
|
|
32
32
|
/deepseek-ai-dsh-typert-registry/understand-the-implementation:
|
|
33
33
|
en: 1a78dfbae50a8b0d
|
|
34
34
|
zh: dc10b4b3f3d832ed
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
en: 4d50f3efeb45eaa4
|
|
37
37
|
zh: ec3575d29d5a040b
|
|
38
38
|
/deepseek-ai-dsh-typert-registry/understand-the-implementation/sub-registries:
|
|
39
|
-
en:
|
|
40
|
-
zh:
|
|
39
|
+
en: d6007eef4d33f3a4
|
|
40
|
+
zh: 499ff578453d5cc0
|
|
41
41
|
/deepseek-ai-dsh-typert-registry/understand-the-implementation/identity-and-validation:
|
|
42
42
|
en: 4764fc33a7e16e60
|
|
43
43
|
zh: 1ddf03cbe16197da
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ English | [中文](README.zh.md)
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## Use this package
|
|
27
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.
|
|
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. Node resolves `/client` to the standalone ESM `lib/client.node.js` bundle for programmatic Cordis composition; browsers use the `lib/client.browser.js` loader factory through the logical `/plugins/.../client.js` URL. Both bundles use the same registry implementation, separate from the Host package root.
|
|
29
29
|
|
|
30
30
|
### Minimal setup
|
|
31
31
|
|
|
@@ -39,14 +39,20 @@ Load the registry plugin; the Client face is installed the same way by the Clien
|
|
|
39
39
|
|
|
40
40
|
Consumers read schemas with `get(key)`, `resolve(key)`, or `list(filter?)` and package reflection with `getPackage(name, face?)` or `listPackages(filter?)`. The first schema read materializes one process-realm instance; later reads reuse it. `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 the materialized Zod schema to JSON Schema without caching the projection.
|
|
41
41
|
|
|
42
|
+
Invocation information is available through existing `ctx.typert.local.get/list` and `ctx.typert.remotes.get/list` queries. They return the registered descriptor objects, including generated direct methods with `input(options?)`, `result`, and `invoke`; there is no separate metadata store or RPC API. Consumers select `method.input({ strict: true })` for matching strict parsing and JSON Schema without changing registration or Host dispatch. Use `isTypertRemoteMethod(descriptor)` from `@deepseek-ai/dsh-typert-protocol/remote-info` to narrow the base descriptor. This guard exposes inputs as `object` and outputs as `unknown`, not endpoint-dependent generics. The [ordinary generated `TYPERT_REMOTE.methods` index](<../generator/README.md#ordinary-remote-metadata>) supplies precise per-method static types and aliases those same descriptors within its artifact instance.
|
|
43
|
+
|
|
42
44
|
### Registering a contribution
|
|
43
45
|
|
|
44
46
|
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
47
|
|
|
48
|
+
Harness offline integrations register an ordinary `TYPERT_REMOTE` contribution with `ctx.typert.remotes.register(contribution)` in their profile Context. `$mount(contribution)` already performs that registration, so registering and mounting the same contribution in the same registry duplicates it and fails. Keep offline metadata ownership separate from the live connection-and-mount Context. Independent offline consumers may instead read `TYPERT_REMOTE.methods` without any Registry. Registry state belongs to its Context and process, is not shared across processes, and neither registration nor querying opens a connection.
|
|
49
|
+
|
|
46
50
|
### Lookup and Context providers
|
|
47
51
|
|
|
48
52
|
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
53
|
|
|
54
|
+
`ctx.typert.resources` holds the default wire field of each resource kind declared in `TypertResourceMap`. The domain that owns a kind registers it with `register(kind, { field })` as a Cordis effect of the calling fiber; a second registration of one kind throws, and so does `global`, the built-in identity-less resource kind. `get(kind)` reads one declaration, and `entries()` lists every registered `{ kind, field }` in registration order. A lookup provider and a Host Context adapter may name the resource kind of their wire identity through `resource`, and a configured resolver keeps it. The Gateway reads all three when it resolves the resources of a non-owner call.
|
|
55
|
+
|
|
50
56
|
-----
|
|
51
57
|
|
|
52
58
|
<a id="understand-the-implementation"></a>
|
|
@@ -67,6 +73,7 @@ The registry is built on one principle: a contribution is one atomic, fiber-owne
|
|
|
67
73
|
- `ctx.typert.remotes` — consumer-selected contributions mounted in the calling fiber.
|
|
68
74
|
- `ctx.typert.lookups` — lookup providers plus composition-owned resolver overrides per key.
|
|
69
75
|
- `ctx.typert.contexts` — Host Context providers and Client Context binders per scoped key.
|
|
76
|
+
- `ctx.typert.resources` — the default wire field per resource kind.
|
|
70
77
|
|
|
71
78
|
Each sub-registry publishes `TypertRegistryChange` events to subscribed listeners; a throwing listener is logged and does not stop later listeners.
|
|
72
79
|
|
package/README.zh.md
CHANGED
|
@@ -25,7 +25,7 @@ kind: "package-reference"
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## 使用本包
|
|
27
27
|
|
|
28
|
-
在存储或消费生成 Typert 产物的任何 Host 或 Client 组合中挂载本注册表;它提供 `ctx.typert`。没有配置。
|
|
28
|
+
在存储或消费生成 Typert 产物的任何 Host 或 Client 组合中挂载本注册表;它提供 `ctx.typert`。没有配置。Node 将 `/client` 解析为供程序化 Cordis 组合使用的独立 ESM bundle `lib/client.node.js`;浏览器通过逻辑 URL `/plugins/.../client.js` 使用 `lib/client.browser.js` loader factory。两个 bundle 使用相同的注册表实现,且与 Host 包根入口分离。
|
|
29
29
|
|
|
30
30
|
### 最小设置
|
|
31
31
|
|
|
@@ -39,14 +39,20 @@ kind: "package-reference"
|
|
|
39
39
|
|
|
40
40
|
消费方用 `get(key)`、`resolve(key)` 或 `list(filter?)` 读取 schema,用 `getPackage(name, face?)` 或 `listPackages(filter?)` 读取包反射。首次读取会物化一个进程 realm 内的 schema 实例,后续读取复用该实例。`resolve()` 能区分格式错误的键、未注册的包,以及已注册但未以该名称提供 schema 的包,各自给出不同的错误。`toJSONSchema(key)` 把已物化的 Zod schema 投影为 JSON Schema,但不缓存该投影。
|
|
41
41
|
|
|
42
|
+
调用信息可通过现有的 `ctx.typert.local.get/list` 与 `ctx.typert.remotes.get/list` 查询读取。它们返回已注册的描述符对象,包括带有 `input(options?)`、`result` 和 `invoke` 的生成直接方法;不存在独立的元数据存储或 RPC API。消费方选择 `method.input({ strict: true })`,即可取得匹配的严格解析与 JSON Schema,而不改变注册或 Host 分发。使用 `@deepseek-ai/dsh-typert-protocol/remote-info` 提供的 `isTypertRemoteMethod(descriptor)` 收窄基础描述符。该守卫将输入暴露为 `object`、输出暴露为 `unknown`,不提供依赖端点的泛型。[普通生成产物的 `TYPERT_REMOTE.methods` 索引](<../generator/README.zh.md#ordinary-remote-metadata>)提供精确的各方法静态类型,并在该产物实例内引用同一批描述符。
|
|
43
|
+
|
|
42
44
|
### 注册贡献
|
|
43
45
|
|
|
44
46
|
生成产物在 Loader 组合中通过 [loader](../loader/README.zh.md) 注册;其他所有者直接调用 `ctx.typert.register(contribution)`,并获得撤销它的同一资源释放函数。重复的包与 face 组合键、schema 键、调用 id 或端点会在提交任何内容之前拒绝整个批次。
|
|
45
47
|
|
|
48
|
+
Harness 离线集成在各自的 profile Context 中通过 `ctx.typert.remotes.register(contribution)` 注册普通 `TYPERT_REMOTE` 贡献。`$mount(contribution)` 已执行该注册,因此在同一个注册表中先注册再挂载同一贡献会因重复而失败。离线元数据所有权应与建立实际连接及挂载的 Context 分离。独立离线消费方也可以直接读取 `TYPERT_REMOTE.methods`,无需任何 Registry。注册表状态归所属 Context 与进程所有,不跨进程共享;注册和查询都不会打开连接。
|
|
49
|
+
|
|
46
50
|
### Lookup 与 Context 提供方
|
|
47
51
|
|
|
48
52
|
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
53
|
|
|
54
|
+
`ctx.typert.resources` 保存 `TypertResourceMap` 中每个资源种类的默认 wire 字段。拥有该种类的领域以 `register(kind, { field })` 登记,登记是调用方 fiber 的 Cordis effect;同一种类重复登记即抛错,登记内置的无身份资源种类 `global` 同样抛错。`get(kind)` 读取一个种类的声明,`entries()` 按登记顺序列出全部已登记的 `{ kind, field }`。lookup provider 与 Host Context adapter 可经 `resource` 声明其 wire 身份所属的资源种类,配置的 resolver 保留该声明。Gateway 解析非 owner 调用的资源时读取这三者。
|
|
55
|
+
|
|
50
56
|
-----
|
|
51
57
|
|
|
52
58
|
<a id="understand-the-implementation"></a>
|
|
@@ -67,6 +73,7 @@ Remote 调用通过 `ctx.typert.lookups` 与 `ctx.typert.contexts` 解析 Host
|
|
|
67
73
|
- `ctx.typert.remotes`——在调用方 fiber 中挂载的、由消费方选中的贡献。
|
|
68
74
|
- `ctx.typert.lookups`——lookup 提供方,以及按键配置的组合方解析器覆盖。
|
|
69
75
|
- `ctx.typert.contexts`——按作用域键配置的 Host Context 提供方与 Client Context 绑定器。
|
|
76
|
+
- `ctx.typert.resources`——每个资源种类的默认 wire 字段。
|
|
70
77
|
|
|
71
78
|
每个子注册表都会向已订阅的监听器发布 `TypertRegistryChange` 事件;抛异常的监听器会被记录日志,且不会阻止后续监听器。
|
|
72
79
|
|