# @arbeidstilsynet/receiver-types 中文文档

规范地址：https://npmcn.com/package/%40arbeidstilsynet/receiver-types/

版本：1\.12\.2
npm 元数据更新时间：2026-11-02T15:43:16.233Z
中文译文更新时间：2026-11-06T16:52:28.381Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40arbeidstilsynet/receiver-types
原文对照：https://npmcn.com/package/%40arbeidstilsynet/receiver-types/?lang=original
项目主页：https://github.com/Arbeidstilsynet/receiver#readme
源码仓库：https://github.com/Arbeidstilsynet/receiver

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

- 包体积（解压后）：40.5 kB，4 个文件
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-06-18T11:47:28.750Z
- 最新版本发布：2026-11-02T15:43:15.888Z
- 近 30 天下载量：2689（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：45（近 12 个月 45 个）

## 中文简介

接收器 API 的脚本声明

## 安装

```sh
npm install @arbeidstilsynet/receiver-types
```

也可以使用：`pnpm add @arbeidstilsynet/receiver-types`、`yarn add @arbeidstilsynet/receiver-types`、`bun add @arbeidstilsynet/receiver-types`

## README

# @arbeidstilsynet/收件者类型

Arbeidstilsynet 的脚本类型 **接收器** API,从其 OpenAPI 规格 。 这个包裹船 **仅类型** - 没有运行时间 代码 - 所以它不会增加你的捆绑.

用起来 [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) 改为 获得一个完全类型安全的 HTTP 客户端: 请求路径、 查询参数、 请求 这些机构和答复都与API现场合同核对.

## 安装

```sh
npm install @arbeidstilsynet/receiver-types openapi-fetch
# or
pnpm add @arbeidstilsynet/receiver-types openapi-fetch
```

> 包与接收器同时发布并使用接收器 版本,所以一个新版本意味着API合同可能已经改变.

## 出口的东西

生成的模块显示标准 `openapi-typescript` 形状 :

-   `paths` - 每一个端点,以 URL 键入,及其方法、参数和响应.
-   `components` - 可再利用计划,根据 `components["schemas"]`。 。 。 .
-   `operations` - 操作按键 `operationId`。 。 。 .

## 创建客户端

```ts
import createClient from "openapi-fetch";
import type { paths } from "@arbeidstilsynet/receiver-types";

export const client = createClient<paths>({
  baseUrl: "/api/receiver",
});
```

## 退出计划类型

而不是你用的计谋 所以他们在你的代码中读得很好:

```ts
import type { components } from "@arbeidstilsynet/receiver-types";

export type Melding = components["schemas"]["Melding"];
export type ConsumerManifest = components["schemas"]["ConsumerManifest"];
export type GetAllMeldingerResponse =
  components["schemas"]["GetAllMeldingerResponse"];
```

## 用法实例

这些镜像是如何在Arbeidstilsynet前端内消耗类型.

### 第一个请求

起码 `meldinger` 请求 - 获取首页 :

```ts
const { data, error } = await client.GET("/meldinger", {
  params: {
    query: {
      pageNumber: 1,
      pageSize: 20,
    },
  },
});

if (error) throw new Error(JSON.stringify(error));
console.log(data?.items);
```

### 已键入、 可重复使用的订阅功能

用户端点显示注册的接收用户:

```ts
import type { components } from "@arbeidstilsynet/receiver-types";

type ConsumerManifest = components["schemas"]["ConsumerManifest"];

export async function getSubscriptions(): Promise<ConsumerManifest[]> {
  const { data, error } = await client.GET("/subscriptions");

  if (error) {
    throw new Error(`Failed to get subscriptions: ${JSON.stringify(error)}`);
  }
  if (!data) {
    throw new Error("Failed to get subscriptions: empty response");
  }
  return data;
}
```

因为 `ConsumerManifest` 是生成类型, 您的编辑器自动完成每个类型 编译时可用的字段和标记无效的组合。 更改 API 合同(并更新此软件包)表面的断裂变化相同.

## 许可证

麻省理工学院. 见 [自由主义](https://npmcn.com/package/%40arbeidstilsynet/receiver-types/LICENSE) 详细情况.

## 常见问题

### @arbeidstilsynet/receiver-types 是什么？

接收器 API 的脚本声明

### 如何安装 @arbeidstilsynet/receiver-types？

在项目目录运行 npm install @arbeidstilsynet/receiver-types，或使用 pnpm add / yarn add / bun add。

### @arbeidstilsynet/receiver-types 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @arbeidstilsynet/receiver-types 可以商用吗？

@arbeidstilsynet/receiver-types 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @arbeidstilsynet/receiver-types 的下载量有多少？

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

### @arbeidstilsynet/receiver-types 还在维护吗？

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

