@adbls/api-types

中文文档
1.9.27发布于 2026/11/05Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 4111

Generated TypeScript and zod types for the Adibilis CORE API. Version tracks the core release tag 1:1.

原始使用文档
文档目录6 节
  1. What it is (and what it isn't)
  2. Version contract
  3. Consuming it
  4. Publishing (maintainers)
  5. What you get
  6. Notes and limits

@adbls/api-types

Generated TypeScript + zod types for the Adibilis CORE API. Nothing here is hand-written.

What it is (and what it isn't)

This package is a build output of core: ajtg reads core's compiled backend bytecode during mvn process-classes and emits the types into src/. That is why it is published from core/core and not from core/SDK — publishing it elsewhere would mean re-running core's Java build in that repo, or copying generated output between repos, which is exactly the drift this package exists to eliminate.

It is not the SDK. @adbls/sdk is hand-written (API client, form layer, checkout, holidays), depends on this package, and re-exports the symbols satellites actually need. A satellite normally installs only the SDK.

Version contract

A released version is 1:1 with the core release tag: @adbls/[email protected] is exactly the API surface of core v1.4.2. CI stamps it from the tag; the 0.0.0 in package.json is a placeholder and is never hand-bumped.

The package follows the same three channels as the core image, so the two can never drift:

core refimage tagpackage versionnpm dist-tagpublished to
v1.4.2:v1.4.21.4.2latestnpmjs.org (public) and Forgejo
main:latest0.0.0-stage.<run>stageForgejo only
dev:dev0.0.0-dev.<run>devForgejo only

Releases are public so anyone can build a frontend against core: @adbls/sdk depends on this package and is public itself. Prereleases stay on Forgejo — they describe unreleased API, and publishing one per push would flood the public registry.

pnpm add @adbls/api-types          # newest released version (npmjs, no token)
pnpm add @adbls/api-types@dev      # newest dev build (Forgejo, see below)
pnpm add @adbls/api-types@stage    # newest stage build (Forgejo, see below)

Prereleases are published under their own dist-tag, so a plain pnpm add never resolves to one. Pin latest in production satellites; use dev while developing against unreleased API changes.

@adbls/sdk carries its own semver and declares a compatible range on this package, so it can ship a fix without a core release and state which core versions it speaks to.

Consuming it

Released versions need nothing: pnpm add @adbls/api-types zod resolves them from npmjs.org.

For the dev and stage prereleases, map the scope to Forgejo instead: copy .npmrc.example to .npmrc and export a read token. The mapping is per scope, so while it is in place every @adbls/* package — releases included — comes from Forgejo, which carries them too.

@adbls:registry=https://forge.cloud.adibilis.ch/api/packages/core/npm/
//forge.cloud.adibilis.ch/api/packages/core/npm/:_authToken=${NPM_TOKEN}
export NPM_TOKEN=<read token>
pnpm add @adbls/api-types zod

zod is a peer dependency so you resolve exactly one copy of it.

The npm registry token is build-time and has nothing to do with the WEBSITE API key a satellite uses at runtime to call core. Different lifetimes, different blast radii — do not conflate them.

Publishing (maintainers)

CI publishes with the org-level REGISTRY_TOKEN. Forgejo serves the container registry and the npm registry from one package subsystem, and both need write:package, so the token that already does docker login for the image build covers npm publish too — no separate npm secret exists.

Release tags then reach npmjs.org by trusted publishing, which npm only offers to GitHub, GitLab and CircleCI — not Forgejo. So the release job pings publish-api-types in the public Adibilis/sdk repo (secret SDK_DISPATCH_TOKEN), which copies the Forgejo tarball to npmjs. Its hourly schedule catches a missed ping. No npm token exists.

Consumers of prereleases still need their own read-scoped Forgejo token; do not hand out the publishing one.

What you get

  • Validated DTOs → a zod schema plus its inferred type: ContactRequestModel (schema) and ContactRequest (type).
  • Enums → UserRoleModel (schema) and UserRole (type).
  • Unvalidated DTOs → a plain interface, default-exported and also re-exported by name from the barrel.
import { ContactRequestModel, type ContactRequest } from '@adbls/api-types';

const parsed = ContactRequestModel.safeParse(formValues);

Schemas mirror the backend's Bean Validation exactly: a @NotBlank field is required in the schema, so parse({}) fails rather than silently passing.

Notes and limits

  • CommonJS output. The generator emits extensionless relative imports, which Node's ESM loader rejects; CJS resolves them, and every consuming bundler (Next.js, Vite) handles CJS fine. Types come from the .d.ts files either way.
  • No Angular services. The build emits them (ajtg-angular is on the plugin classpath) but routes them to a throwaway directory via typesOnlyOutputDirectories — they import @angular/* and would break a satellite's build.
  • The barrel is generated (scripts/generate-index.mjs, run as prebuild). ajtg wipes src/ on every build, so it cannot be a committed file.
  • src/ and dist/ are gitignored. Regenerate with mvn clean package -DskipTests from the repo root, then pnpm build here.

版本与发布记录

@adbls/api-types 共发布 39 个版本,首次发布于 2026/09/27;过去 12 个月发布了 39 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.9.27latest2026/11/051 天前
1.9.262026/11/041 天前
1.9.252026/11/041 天前
1.9.242026/11/041 天前
1.9.232026/10/298 天前
1.9.222026/10/288 天前

关于 @adbls/api-types 的常见问题

@adbls/api-types 是什么?

Generated TypeScript and zod types for the Adibilis CORE API. Version tracks the core release tag 1:1.

如何安装 @adbls/api-types?

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

@adbls/api-types 支持 TypeScript 吗?

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

@adbls/api-types 支持 ESM 还是 CommonJS?

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

@adbls/api-types 可以商用吗?

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

@adbls/api-types 的下载量有多少?

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

@adbls/api-types 还在维护吗?

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