@bufbuild/cel-spec

中文文档
0.6.2发布于 2026/11/04Apache-2.0ESM + CJS零依赖构建来源已验证近 30 天下载 368.2万

CEL definitions and test data

原始使用文档

@bufbuild/cel-spec

This package provides CEL definitions and test data from the CEL specification (v0.25.1).

CEL uses Protocol Buffer definitions for parsed expressions. For example, the message cel.expr.ParsedExpr provides an abstract representation of a parsed CEL expression. The message types and schemas can be imported from @bufbuild/cel-spec:

import type { ParsedExpr } from "@bufbuild/cel-spec/cel/expr/syntax_pb.js";

CEL's conformance test suite also uses Protocol Buffers to define test cases. All messages from the cel.expr.conformance namespace are exported from this package as well, and the function getConformanceSuite provides conformance test data:

import { getConformanceSuite } from "@bufbuild/cel-spec/testdata/tests.js";
import { getTestRegistry } from "@bufbuild/cel-spec/testdata/registry.js";

In addition to CEL's conformance test data, this package also exports parser tests extracted from cel-go:

import { getParsingSuite, getComprehensionSuite } from "@bufbuild/cel-spec/testdata/tests.js";

Incremental approach

The tests aggregated by this package are useful for incremental testing of a CEL implementation. That is, they provide input expressions along with outputs at multiple points in the lifecycle of a CEL program, not only its final output.

Chiefly, tests provide some or all of the following outputs:

  • The parsed abstract syntax tree (AST) for an input expression
  • The output type that should be statically inferred by a type checker for an expression
  • The final result of compiling and running the expression

It should be noted that only the final result is actually provided by the conformance tests sourced from the CEL specification repo. The incremental outputs are derived from the cel-go implementation, considering it to be positioned as a reference implementation.

版本与发布记录

@bufbuild/cel-spec 共发布 9 个版本,首次发布于 2025/04/30;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.2latest2026/11/044 天前
0.6.12026/08/272 个月前
0.6.02026/06/015 个月前
0.5.02026/05/076 个月前
0.4.02026/01/219 个月前
0.3.02025/07/281.3 年前

关于 @bufbuild/cel-spec 的常见问题

@bufbuild/cel-spec 是什么?

CEL definitions and test data

如何安装 @bufbuild/cel-spec?

在项目目录运行 npm install @bufbuild/cel-spec,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@bufbuild/protobuf(^2.6.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bufbuild/cel-spec 支持 TypeScript 吗?

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

@bufbuild/cel-spec 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bufbuild/cel-spec 可以商用吗?

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

@bufbuild/cel-spec 的下载量有多少?

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

@bufbuild/cel-spec 还在维护吗?

最新版本 0.6.2 发布于 2026/11/04(4 天前);至今共发布 9 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/04/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。