@drzl/analyzer

中文文档
1.22.0发布于 2026/08/14Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 3237
原始使用文档
文档目录4 节
  1. 💚 Sponsor DRZL
  2. Use
  3. Output (high level)
  4. Notes

@drzl/analyzer

CI npm

Drizzle schema → normalized analysis for fast, reliable codegen.

💚 Sponsor DRZL

DRZL is crafted nights & weekends. Sponsorships keep the generators fast, tested, and free.

Sponsor DRZL

  • Every dollar speeds up CI hardware and offsets long test runs on my aging laptop.
  • Sponsors get roadmap input and priority responses in GitHub Issues.
  • Prefer a quick overview? The current goals and thank-yous are at https://use-drzl.github.io/drzl/sponsor.

Use

import { SchemaAnalyzer } from '@drzl/analyzer';

const analyzer = new SchemaAnalyzer('src/db/schemas/index.ts');
const analysis = await analyzer.analyze({
  includeRelations: true,
  validateConstraints: true,
});

The CLI consumes this analysis to generate validation, services, and routers.

Output (high level)

  • dialect, tables, columns, keys, indexes
  • relations (incl. inferred), enums
  • issues (warnings/errors) for constraints and shape

Per column, beyond the type: nullable, hasDefault, defaultValue (literal defaults only), isGenerated, enumValues, maxLength (characters), maxBytes (bytes, which is a different measurement on the same kind of column), min/max, arrayDimensions, format, and shape for values that are not scalars (json, buffer, tuple, numberObject, vector, bitstring, customType).

maxBytes is set by MySQL and nothing else. Its TEXT and BLOB families carry their limit in the type rather than in a declared length, and count it in bytes: 255 for tinytext and tinyblob, 65535 for text and blob, 16777215 for the medium pair and 4294967295 for the long pair. A varchar(n) is genuinely n characters and keeps maxLength. See the analyzer page for how the generators encode it.

format names a pattern in COLUMN_FORMATS, and two of its values name a dialect: a bigint({ mode: 'string' }) column is pgBigint on Postgres and mysqlBigint on MySQL and SingleStore, because the two servers really do parse that text differently ('0x1f' is 31 on one and an error on the other, '12.5' is 13 on one and an error on the other). SQL Server carries no format for it, since none was measured.

DRZL_ANL_UNKNOWN_COLUMN is reported for any column whose validator would accept anything, which is the shape a missing type mapping takes: nothing throws, and every row passes.

Notes

  • Best‑effort introspection aligned with Drizzle symbols across versions. Both live majors are covered and diffed against each other in CI: 0.4x and v1 model arrays and enums differently, and reading only one silently typed every .array() column as unknown on the other.

版本与发布记录

@drzl/analyzer 共发布 41 个版本,首次发布于 2025/09/06;过去 12 个月发布了 33 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.22.0latest2026/08/142 个月前
1.21.52026/08/113 个月前
1.21.42026/08/113 个月前
1.21.32026/08/113 个月前
1.21.22026/08/113 个月前
1.21.12026/08/103 个月前

关于 @drzl/analyzer 的常见问题

如何安装 @drzl/analyzer?

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

@drzl/analyzer 支持 TypeScript 吗?

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

@drzl/analyzer 支持 ESM 还是 CommonJS?

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

@drzl/analyzer 需要什么版本的 Node.js?

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

@drzl/analyzer 可以商用吗?

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

@drzl/analyzer 的下载量有多少?

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

@drzl/analyzer 还在维护吗?

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