# @gathertown/webhook-object-types 中文文档

规范地址：https://npmcn.com/package/%40gathertown/webhook-object-types/

版本：0\.3\.0
npm 元数据更新时间：2026-09-04T10:11:38.578Z
中文译文更新时间：2026-11-16T00:00:08.965Z
软件包许可：MIT OR Apache-2\.0

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

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

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

- 包体积（解压后）：25.3 kB，21 个文件
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-07-20T13:27:49.808Z
- 最新版本发布：2026-09-04T10:11:38.431Z
- 近 30 天下载量：36888（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 4 个）

## 中文简介

为 Gather webhook-object(Smart Object)事件生成类型脚本. 只有类型,零运行时间.

## 安装

```sh
npm install @gathertown/webhook-object-types
```

也可以使用：`pnpm add @gathertown/webhook-object-types`、`yarn add @gathertown/webhook-object-types`、`bun add @gathertown/webhook-object-types`

## README

# @gathertown/webhook-对象类型

为 Gather webhook-object( Smart Object) 事件生成类型脚本: 每条线 `type` (例如:. `counter.increment`) 及其定义 `data` 有效载荷外形,外加预设能力 分组。 只类型,零运行时代码,零依赖.

## 使用量

```sh
npm install --save-dev @gathertown/webhook-object-types
```

```ts
import type {
  DataFor,
  EventTypeForPreset,
  WebhookEventEnvelope,
  WebhookEventType,
  WebhookWireErrorCode,
} from "@gathertown/webhook-object-types"

// The HTTP request body for any event, fully typed per event type:
const event: WebhookEventEnvelope<"counter.increment"> = {
  type: "counter.increment",
  timestamp: new Date().toISOString(),
  data: { by: 1 }, // DataFor<"counter.increment">
}

// What a given preset accepts:
type InboxEvent = EventTypeForPreset<"inbox"> // "activity.add" | "counter.set" | …

// Error codes the receiver returns in `{ "error": "<code>" }` bodies:
const code: WebhookWireErrorCode = "token_revoked"
```

大多数整形师想要 [`@gathertown/webhook-object-sdk`](https://www.npmjs.com/package/@gathertown/webhook-object-sdk) 相反,它将这些类型包裹在一个签名的重试客户端中.

## `schemas/`: 语文中立合同

`schemas/*.json` 每场赛事拥有1个JSON Schema(草案07) `data` 由电线命名的有效载荷 类型(`counter.increment.json`) (中文(简体) ). 类型脚本在 `src/` 由这些相同的 通过快取型的策略, 和其他语言上的集成器可以做同样的事情:

```sh
npx quicktype -s schema schemas/*.json --lang go --just-types
npx quicktype -s schema schemas/*.json --lang python
```

(明确输入文件,以快速指向 _目录_ 令其视之为 JSON样本并生成图案文件本身的类型. )

计划还和任何JSON Schema 校验器(jav等)合作进行运行时间校验 动态制造的有效载荷,可直接导入:

```ts
import counterIncrement from "@gathertown/webhook-object-types/schemas/counter.increment.json"
```

这里的一切都是由同一计划产生的 验证事件服务器侧,所以 这些类型永远不会从执行中消失.

## 常见问题

### @gathertown/webhook-object-types 是什么？

为 Gather webhook-object\(Smart Object\)事件生成类型脚本\. 只有类型,零运行时间\.

### 如何安装 @gathertown/webhook-object-types？

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

### @gathertown/webhook-object-types 支持 TypeScript 吗？

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

### @gathertown/webhook-object-types 可以商用吗？

@gathertown/webhook-object-types 使用 MIT OR Apache-2\.0 许可。可在 MIT、Apache-2\.0 中任选其一遵守。选择 MIT 时，宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @gathertown/webhook-object-types 的下载量有多少？

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

### @gathertown/webhook-object-types 还在维护吗？

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

