# @defra/lis-hubs-infra-registry 中文文档

规范地址：https://npmcn.com/package/%40defra/lis-hubs-infra-registry/

版本：0\.13\.8
npm 元数据更新时间：2026-11-10T10:06:14.598Z
中文译文更新时间：2026-11-11T21:11:16.427Z
软件包许可：OGL-UK-3\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40defra/lis-hubs-infra-registry
原文对照：https://npmcn.com/package/%40defra/lis-hubs-infra-registry/?lang=original
项目主页：https://github.com/DEFRA/lis-hubs-infra-registry#readme
源码仓库：https://github.com/DEFRA/lis-hubs-infra-registry

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：16.5 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：\>=24
- 运行依赖：0 个
- 首次发布：2026-08-10T09:16:52.602Z
- 最新版本发布：2026-11-10T10:06:14.056Z
- 近 30 天下载量：8864（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：40（近 12 个月 40 个）

## 中文简介

牲畜平台共享下级登记元数据.

## 安装

```sh
npm install @defra/lis-hubs-infra-registry
```

也可以使用：`pnpm add @defra/lis-hubs-infra-registry`、`yarn add @defra/lis-hubs-infra-registry`、`bun add @defra/lis-hubs-infra-registry`

## README

# 登记

畜牧信息服务(LIS)的一部分,它允许牲畜饲养者、所有者、代理商和牲畜饲养者使用 代表们记录和管理他们的动物.

`@defra/lis-hubs-infra-registry` 是一个共享 npm 软件包, 持有 LIS 模块的注册 (说话的应用软件及其路径、港口、物种、分类和枢纽),加上支持的物种 和分类学, 和小帮手寻找它们.

它只持有事实。 它不作出许可或能力决定(见 [下层访问](https://github.com/DEFRA/lis-hubs-infra-access)) (中文(简体) ).

用于:

-   中枢 : [lis-hubs-前台办公室](https://github.com/DEFRA/lis-hubs-front-office), (中文(简体) ), [后办公室](https://github.com/DEFRA/lis-hubs-back-office)
-   发言: [丽丝-苹果-牛-家](https://github.com/DEFRA/lis-apps-cattle-home), (中文(简体) ), [lis -apps - crattle - register (英语)](https://github.com/DEFRA/lis-apps-cattle-register), (中文(简体) ), [百花齐放](https://github.com/DEFRA/lis-apps-cattle-move), (中文(简体) ), [鼠类动物死亡](https://github.com/DEFRA/lis-apps-cattle-death)
-   软件包 : [双核](https://github.com/DEFRA/lis-hubs-infra-core), (中文(简体) ), [下层访问](https://github.com/DEFRA/lis-hubs-infra-access), (中文(简体) ), [服务](https://github.com/DEFRA/lis-infra-ui-services)

这是Lis-hubs-infra-core、Lis-hubs-infra-access和Lis-infra-ui-services的同龄依赖.

## 安装

```bash
npm install @defra/lis-hubs-infra-registry
```

如果您的应用程序使用将它列为对等依赖的软件包之一, 请同时安装 .

## 使用量

所有出口都来自包根.

### 常数

```js
import {
  HUBS,
  TAXONOMIES,
  SPECIES,
  MODULES
} from '@defra/lis-hubs-infra-registry'

HUBS // ['front-office', 'back-office']
TAXONOMIES // [{ id: 'register', label: 'Register', summary: '...' }, ...]
SPECIES // [{ id: 'cattle', code: 'ctt', label: 'Cattle', summary: '...' }, ...]
MODULES // every module entry from src/modules.json
```

支持的分类是: `register`, (中文(简体) ), `move`, (中文(简体) ), `death`, (中文(简体) ), `status` 财务报告和审定财务报表 `home`。获得支持者 品种为牛(`ctt`),绵羊(`shp`),相机(`cml`)鸡肉(`chk`)和山羊(英语:`gt`) (中文(简体) ).

### 查询

每个查询返回 `null` 时,除了 `getMountsForModule` 财务报告和审定财务报表 `getMountPath`,该扔出.

```js
import {
  getTaxonomyById,
  getSpeciesByCode,
  getModuleById,
  getModulesForHub,
  hydrateModuleMetadata
} from '@defra/lis-hubs-infra-registry'

getTaxonomyById('move') // { id: 'move', label: 'Move', summary: '...' }
getSpeciesByCode('ctt') // { id: 'cattle', code: 'ctt', label: 'Cattle', ... }
getModuleById('cattle-move') // { id: 'cattle-move', mounts: { holding: ..., assets: ... }, port: 3204, ... }
getMountsForModule('cattle-home') // { holding: '/holdings/{cph*3}/cattle', animal: '/animals/cattle', assets: '/assets/cattle-home' }
getMountPath('cattle-home', 'holding', { cph: '12/345/0001' }) // '/holdings/12/345/0001/cattle'
getModulesForHub('front-office') // every module whose `hubs` includes 'front-office'

hydrateModuleMetadata(getModuleById('cattle-move'))
// the module plus `taxonomyLabel: 'Move'` and `speciesLabel: 'Cattle'`
// (falls back to the raw id or code if there is no match; returns null for null)
```

### 模块条目

`src/modules.json` 是一个数组。 每个条目都有这些字段:

| 外地 | 类型 | 含义 |
| --- | --- | --- |
| `id` | 字符串 | 模块编号。 匹配说话的重播名称,而不包含 `lis-apps-` 前缀. |
| `label` | 字符串 | 向用户显示名称 . |
| `mounts` | 对象 | 用挂载名称键入的 URL 中枢挂载发言的图案( 见下文) . |
| `port` | 编号 | 在本地开发中. |
| `taxonomy` | 字符串 | `id` 条目 `src/supported-taxonomies.json`。 。 。 . |
| `species` | 字符串 | `code` 条目 `src/supported-species.json`。 。 。 . |
| `hubs` | 字符串 \[\] | 服务于模块的枢纽. 每一个必须是一个 `HUBS`。 。 。 . |

例如:

```json
{
  "id": "cattle-move",
  "label": "Move for Cattle",
  "mounts": {
    "holding": "/holdings/{cph*3}/cattle/move",
    "assets": "/assets/cattle-move"
  },
  "port": 3204,
  "taxonomy": "move",
  "species": "ctt",
  "hubs": ["front-office", "back-office"]
}
```

#### 挂载

一个挂载是一个 URL 模式, 以 hopi 参数语法表示, 枢机服务于所讲的 。 URL 网络 树把牵引物放在首位,把物种放在下方, 所以每个说话的人都能够从一个 动物也可以到达一个物种的家:

| 挂载 | 图案 | 服务于 |
| --- | --- | --- |
| `holding` | `/holdings/{cph*3}/<species>` | 该物种的家园 |
| `holding` | `/holdings/{cph*3}/<species>/<taxonomy>` | 每个动词说话 |
| `animal` | `/animals/<species>` | 该物种的家园 |

`<species>` 是物种 `id` (单位:千美元)`cattle`),而不是它的代码. 通话人员将线路与 完全图案`/holdings/{cph*3}/cattle/animals`),中枢转发请求路径不变, 并同时与 `getMountPath`。一个发言服务于其已建成的CSS和JavaScript `assets` 挂载, 它没有参数, 这样浏览器就可以在控股之间缓存它们 .

### 添加模块

1.  创建已发言的应用程序 。 命名还原 `lis-apps-<id>`。 。 。 .
2.  将条目添加到 `src/modules.json`。使用一个独特的 `id`, (中文(简体) ), `mounts` 财务报告和审定财务报表 `port`。 。 。 .
3.  如果物种或分类学是新的,请加入 `src/supported-species.json` 或者说 `src/supported-taxonomies.json` 先说.
4.  在下方添加已发言的作曲文件 `.tools/compose` 内 [净值](https://github.com/DEFRA/lis-dev),在同一端口上发表.
5.  发布这个包,然后在枢纽和其他消费者中撞出.

中心站不需要改变路线. `createProxyPlugin` 内 [双核](https://github.com/DEFRA/lis-hubs-infra-core) 读取 `getModulesForHub` 财务报告和审定财务报表 为每个模块的挂载添加代理路由, 转发到服务 `lis-apps-<id>` 联 合 国 `port` (地方发展)路径不变. 演讲者也读过他们从这里到这里 [服务](https://github.com/DEFRA/lis-infra-ui-services)。 。 。 .

## 先决条件

-   节点.js 24(见 `.nvmrc`,使用时 `nvm use`(中文(简体) )
-   对照一个消费的应用程序检查更改: [净值](https://github.com/DEFRA/lis-dev) 一次性设置完成

## 设置

### 发展

```bash
nvm use
npm install
```

### 测试

无法安装工具 `npm install`测试 [维特](https://vitest.dev/)。 。 。 .

## 正在发展中

这是一个库,所以它没有自己的服务器. 尝试改变一个消费应用 没有 发布, 将本地副本链接到 lis- dev 堆栈 :

```bash
cd lis-dev
.bin/sideload link hubs/infra-registry # every installed copy now points at this repo
.bin/sideload up front-office           # optional: run a consumer locally with hot reload
.bin/sideload unlink hubs/infra-registry # when done
```

## 正在测试

```bash
npm test                 # unit tests
npm run test:coverage    # with coverage
npm run lint             # ESLint
npm run format:check     # Prettier
```

在释放出一个变化之前,还要对连接包进行每个消耗回波的测试.

## 管道

GitHub 动作中运行的构建、版本和出版(`.github/workflows`)使用蛋糕脚本(`*.cake`:

-   **将请求拉到 `main`**: 校验(格式、林特、测试),声纳分析,版本检查
-   **推到一个 `feature/` 或者说 `hotfix/` 分支**: 预发版本和标签
-   **合并到 `main`**: 释放标签,然后发布到 [无](https://www.npmjs.com/package/@defra/lis-hubs-infra-registry)

版本来自git标签 (SemVer). 合并后, 等待出版工作完成后, 才将套件撞入消耗回购中 .

## 分支政策

Repo采用干线开发. 分行从 `main` 并命名分支:

-   `feature/LREG-<ticket>-<short-kebab-description>`
-   `hotfix/LREG-<ticket>-<short-kebab-description>`

`LREG` 必须是大写,因为 GitHub 规则拒绝其他分支名称。 重置为 `main` 而不是合并 `main` 进去.

## 协助这一项目

-   跟着 [Defra软件开发标准](https://github.com/DEFRA/software-development-standards)。 。 。 .
-   `npm install` 设置一个承诺前钩子(Husky),运行安全审计,格式检查和lint.
-   地物分枝会撞倒小版本而热补丁分枝. 虽然包裹在0.x上,但对于公共API或模块条目外形的突破性改变,船舶作为小版本,所以在PR中叫出它,让消费者可以更新.
-   打开拉动请求 `main` 使用 PR 模板。 CI必须通过而声纳质量门在合并前必须是绿色.

## 许可证

本资料系根据下列公开政府规定公布:

[http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3 互联网档案馆的存檔,存档日期2013-12-21](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)

在使用此信息时, 您的产品和应用程序中引用以下的归属声明 MUST .

> 载有根据开放政府许可证颁发的公共部门信息v3

### 关于许可证

开放政府许可证(OGL)由陛下文具办公室(HMSO)的主计长制定,使公共部门的信息提供者能够根据共同开放许可证许可其信息的使用和再使用.

它旨在鼓励自由和灵活地使用和再使用信息,仅附带一些条件.

## 常见问题

### @defra/lis-hubs-infra-registry 是什么？

牲畜平台共享下级登记元数据\.

### 如何安装 @defra/lis-hubs-infra-registry？

在项目目录运行 npm install @defra/lis-hubs-infra-registry，或使用 pnpm add / yarn add / bun add。

### @defra/lis-hubs-infra-registry 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/defra\_\_lis-hubs-infra-registry 是否存在。

### @defra/lis-hubs-infra-registry 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @defra/lis-hubs-infra-registry 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=24。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @defra/lis-hubs-infra-registry 可以商用吗？

@defra/lis-hubs-infra-registry 使用 OGL-UK-3\.0 许可。声明的许可为 OGL-UK-3\.0，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### @defra/lis-hubs-infra-registry 的下载量有多少？

根据 npm 官方下载统计，@defra/lis-hubs-infra-registry 在 2026/10/12 – 2026/11/10 这 30 天内被下载 8,864 次，日均约 295 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @defra/lis-hubs-infra-registry 还在维护吗？

最新版本 0\.13\.8 发布于 2026/11/10（1 天前）；至今共发布 40 个版本，其中过去 12 个月发布了 40 个；首次发布于 2026/08/10。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

