@haneinfo/metadata-schema

中文文档
1.1.36发布于 2026/11/17UNLICENSEDTypeScriptCommonJS近 30 天下载 4691
原始使用文档
文档目录4 节
  1. Prisma documentation tags
  2. @internal
  3. @cubeMeasure <hint>
  4. @cubeRef <app>.<Model>.<field>

@haneinfo/metadata-schema

@haneinfo/metadata-schema exposes the Prisma DMMF used by an app through GET /metadata/schema. The response includes scalar and enum fields, relation metadata, database column names, and structured annotations parsed from Prisma /// documentation comments.

Prisma documentation tags

Tags are case-sensitive. @cubeMeasure and @cubeRef are line-oriented: they are recognised only when they start a documentation line, after optional whitespace. @internal is the exception (see below). A description can follow the tag on the same line, or appear on separate /// lines. The original documentation value in the metadata response is preserved byte-for-byte; parsing adds structured properties without removing tag text.

@internal

Place @internal anywhere in a model's documentation to exclude that model from the derived availableScopes list; package Prisma fragments put it at the end of the model's first /// line. The model and its metadata are still exposed in models; only the scope derivation filters it out.

/// @internal
/// Framework bookkeeping; not part of the public data scopes.
model AuditLog {
  id String @id @default(cuid())
}

@cubeMeasure <hint>

Place @cubeMeasure on a scalar or enum field and provide one non-whitespace hint. The current recommended dictionary is sum, avg, min, max, and count, but measureHint is an open string so future Cube measures such as countDistinct, countDistinctApprox, and runningTotal can be used without a package type change. The parser does not validate whether the field type is appropriate for the hint. Consumers should ignore or warn on unknown hints rather than failing the whole query.

model InvoiceLine {
  id     String  @id @default(cuid())
  /// @cubeMeasure sum Line amount in the invoice currency.
  amount Decimal
}

@cubeRef <app>.<Model>.<field>

Place @cubeRef on a field that refers to a field owned by another app. The three dot-separated parts are returned as crossAppRef: { app, model, field }. Parsing is syntactic only: the app, model, and field do not need to exist in the current repository. Cross-app joins are never inferred when this tag is absent.

model Shipment {
  id              String @id @default(cuid())
  /// @cubeRef sales.Order.id
  /// The order identifier is owned by the sales app.
  salesOrderId    String @map("sales_order_id")
}

Tags can be combined on one field and can be mixed with ordinary text:

model Payment {
  id        String  @id @default(cuid())
  /// Payment amount in the settlement currency.
  /// @cubeMeasure sum
  /// @cubeRef billing.Invoice.total
  amount    Decimal @map("amount_value")
}

Malformed @cubeMeasure or @cubeRef lines are ignored and produce a warning. Lowercase variants such as @cubemeasure are ordinary text. If a tag appears more than once on a field, the first valid occurrence wins. A tag string embedded in the middle of a sentence is not a tag; move it to the beginning of a /// documentation line.

版本与发布记录

@haneinfo/metadata-schema 共发布 36 个版本,首次发布于 2026/10/02;过去 12 个月发布了 36 个版本。

版本发布日期距今
1.1.36latest2026/11/17今天
1.1.352026/11/17今天
1.1.342026/11/17今天
1.1.332026/11/161 天前
1.1.322026/11/0413 天前
1.1.312026/10/2919 天前

关于 @haneinfo/metadata-schema 的常见问题

如何安装 @haneinfo/metadata-schema?

在项目目录运行 npm install @haneinfo/metadata-schema,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@nestjs/core(^11.0.0 || ^12.0.0)、@nestjs/common(^11.0.0 || ^12.0.0)、@prisma/client(^6.19.0 || ^7.10.1)、@haneinfo/plugin-host-nest(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@haneinfo/metadata-schema 支持 TypeScript 吗?

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

@haneinfo/metadata-schema 支持 ESM 还是 CommonJS?

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

@haneinfo/metadata-schema 可以商用吗?

@haneinfo/metadata-schema 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@haneinfo/metadata-schema 的下载量有多少?

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

@haneinfo/metadata-schema 还在维护吗?

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