@livdot-tech/contracts

中文文档
1.19.1发布于 2026/11/02TypeScriptESM + CJS零依赖

Shared API contracts for the LivDot platform

原始使用文档
文档目录10 节
  1. Purpose
  2. Repositories That Consume This Package
  3. What Belongs Here
  4. What Must Not Be Added Here
  5. Ownership
  6. Versioning
  7. Change Rules
  8. Structure
  9. Installation and Usage
  10. Goal

LivDot Shared Contracts

Central contract repository for schemas and shared API-facing types used across the LivDot platform.

Purpose

This repository exists to keep backend, frontend, and mobile aligned on the same contract surface without coupling the codebases into a monorepo. It is the single shared source for:

  • request and response schemas
  • domain enums and state constants
  • canonical error codes
  • shared DTOs and validation rules
  • other API-boundary definitions that must remain consistent across services and clients

Repositories That Consume This Package

  • livdot-backend
  • livdot-frontend
  • livdot-mobile

What Belongs Here

Only cross-stack contract artifacts. Examples:

  • CreateEventRequest
  • BookingState
  • EventState
  • ApiErrorCode
  • Zod schemas for payload validation
  • shared auth/token payload shapes where applicable

What Must Not Be Added Here

This repository is not a dumping ground for shared code. Do not add:

  • backend business logic
  • ORM/database models
  • repositories/services/use-cases
  • frontend UI components
  • mobile-specific runtime code
  • infrastructure or deployment logic
  • utilities that are not part of a cross-stack contract If it is not part of the contract boundary, it does not belong here.

Ownership

The backend remains the authority on system behavior and API truth. This repository defines the contract shape, not the implementation or business logic.

Versioning

Releases are automated. semantic-release reads Conventional Commit messages on main and decides the bump, writes CHANGELOG.md, tags, and publishes to npm. Do not edit the version field in package.json by hand — CI owns it.

The commit prefix determines the bump:

  • fix: → PATCH, backward-compatible fixes
  • feat: → MINOR, backward-compatible additions
  • feat!: or a BREAKING CHANGE: footer → MAJOR

Because the bump is derived from the commit message rather than from schema diffing, a breaking change committed as fix: will ship as a patch. Field removals and renames must carry the breaking marker.

Consumers pin a caret range and upgrade through review.

Change Rules

Any contract change must be treated carefully because it can affect multiple codebases. Before merging a change:

  1. confirm the change is truly cross-stack
  2. identify whether it is breaking or non-breaking
  3. update version appropriately
  4. document migration notes if consumers need code changes

Structure

One folder per domain, each exporting *.enums.ts, *.schemas.ts and *.types.ts through an index.ts barrel.

src/
  auth/          user/          event/
  booking/       marketplace/   joblisting/
  host/          moment/        chat/
  payment/       streaming/     dispute/
  notification/  common/        errors/
  index.ts       # master barrel

common/ holds CurrencyEnum, pagination, audit enums and ResponseMessages; errors/ holds the ApiErrorCode catalogue; booking/ additionally owns booking-state-machine.ts — the valid transitions, per-transition actor RBAC, and which target states require a reason.

Adding a domain means three edits: create the folder with its index.ts, re-export it from src/index.ts, and add it to the entry array in tsup.config.ts — miss the last one and the @livdot-tech/contracts/<domain> subpath resolves to nothing.

Installation and Usage

npm install @livdot-tech/contracts zod

zod is a peer dependency, not bundled — the package has zero runtime dependencies, and keeping Zod on the consumer side means there is only ever one Zod instance in play.

import { BookingState, CurrencyEnum } from '@livdot-tech/contracts';
import { VALID_BOOKING_TRANSITIONS } from '@livdot-tech/contracts/booking';

See docs/README.md for usage detail, docs/ONBOARDING.md for setup, and architecture/SAD.md plus architecture/decisions/ for the design decisions.

Goal

Keep contracts explicit, versioned, and stable.

This repository exists to improve consistency across backend, frontend, and mobile while preserving clear ownership boundaries between the separate LivDot codebases.

版本与发布记录

@livdot-tech/contracts 共发布 153 个版本,首次发布于 2026/04/28;过去 12 个月发布了 153 个版本。

版本发布日期距今
1.19.1latest2026/11/021 天前
1.19.02026/11/012 天前
1.18.62026/10/313 天前
1.18.52026/10/304 天前
1.18.42026/10/304 天前
1.18.32026/10/285 天前

关于 @livdot-tech/contracts 的常见问题

@livdot-tech/contracts 是什么?

LivDot平台的共享API契约

如何安装 @livdot-tech/contracts?

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

@livdot-tech/contracts 支持 TypeScript 吗?

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

@livdot-tech/contracts 支持 ESM 还是 CommonJS?

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

@livdot-tech/contracts 可以商用吗?

@livdot-tech/contracts 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@livdot-tech/contracts 还在维护吗?

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