@gathertown/webhook-object-types

中文文档
0.3.0发布于 2026/09/04MIT OR Apache-2.0TypeScript零依赖近 30 天下载 3.7万

Generated TypeScript types for Gather webhook-object (Smart Object) events. Types-only, zero runtime.

原始使用文档

@gathertown/webhook-object-types

Generated TypeScript types for Gather webhook-object (Smart Object) events: every wire type (e.g. counter.increment) and its data payload shape, plus preset → capability groupings. Types-only, zero runtime code, zero dependencies.

Usage

npm install --save-dev @gathertown/webhook-object-types
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"

Most integrators want @gathertown/webhook-object-sdk instead, which wraps these types in a signed, retrying client.

schemas/: the language-neutral contract

schemas/*.json holds one JSON Schema (draft-07) per event's data payload, named by wire type (counter.increment.json). The TypeScript in src/ is generated from these same schemas via quicktype, and integrators on other languages can do the exact same thing:

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

(Pass the files explicitly, as pointing quicktype at the directory makes it treat them as JSON samples and generate types of the schema documents themselves.)

The schemas also work with any JSON Schema validator (ajv etc.) for runtime validation of dynamically-built payloads, and are importable directly:

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

Everything here is generated from the same schemas that validate events server-side, so these types can never drift from the implementation.

版本与发布记录

@gathertown/webhook-object-types 共发布 4 个版本,首次发布于 2026/07/20;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.3.0latest2026/09/042 个月前
0.2.02026/07/293 个月前
0.1.12026/07/203 个月前
0.1.02026/07/203 个月前

关于 @gathertown/webhook-object-types 的常见问题

@gathertown/webhook-object-types 是什么?

Generated TypeScript types for Gather webhook-object (Smart Object) events. Types-only, zero runtime.

如何安装 @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 和提交记录判断。