@google/events

中文文档
5.4.0发布于 2022/02/18Apache-2.0CommonJS零依赖近 30 天下载 17.6万

Client library for CloudEvents issued by Google.

原始使用文档
文档目录7 节
  1. Prerequisites
  2. Install
  3. Features
  4. Example Usage
  5. JS
  6. TS
  7. Reference

Google CloudEvents – Node.js npm version github ci

This repository contains types for CloudEvents issued by Google, enabling you to have autocompletion in JavaScript or TypeScript projects.

Note: This repo is auto-generated from schemas in https://github.com/googleapis/google-cloudevents

Prerequisites

  • Node 10+

Install

Install the library from npm:

npm i @google/events

Features

This library is meant to provide types for Node projects accepting CloudEvent data, typically sent through a HTTP request's POST body.

For every event type, this library contains:

  • Exports a JavaScript function to[DataType].
  • Exports a TypeScript type interface DataType.

This provides autocompletion and inline IDE documentation for event types.

Example Usage

Require or import the module. Here is an example JS and TS file:

JS

const {toLogEntryData} = require('@google/events/cloud/audit/v1/LogEntryData');

const data = {
  // ...
};

const jsExample = toLogEntryData(data);
console.log(jsExample);

TS

import {LogEntryData} from '@google/events/cloud/audit/v1/LogEntryData';

const data = {
  // ...
};

const tsExample: LogEntryData = data;
console.log(tsExample);

Reference

The reference.md file has detailed examples for how to use every event data type.

版本与发布记录

@google/events 共发布 22 个版本,首次发布于 2020/08/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.4.0latest2022/02/184 年前
5.3.02021/12/154 年前
5.2.02021/10/165 年前
5.1.12021/09/045 年前
5.1.02021/07/125 年前
5.0.02021/06/165 年前

关于 @google/events 的常见问题

@google/events 是什么?

Client library for CloudEvents issued by Google.

如何安装 @google/events?

在项目目录运行 npm install @google/events,或使用 pnpm add / yarn add / bun add。

@google/events 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/google__events 是否存在。

@google/events 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@google/events 需要什么版本的 Node.js?

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

@google/events 可以商用吗?

@google/events 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@google/events 的下载量有多少?

根据 npm 官方下载统计,@google/events 在 2026/10/17 – 2026/11/15 这 30 天内被下载 176,244 次,日均约 5,875 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@google/events 还在维护吗?

最新版本 5.4.0 发布于 2022/02/18(4 年前);至今共发布 22 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/08/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。