# @happyvertical/smrt-products 中文文档

规范地址：https://npmcn.com/package/%40happyvertical/smrt-products/

版本：0\.62\.1
npm 元数据更新时间：2026-11-17T07:54:16.682Z
中文译文更新时间：2026-11-17T09:54:28.925Z
软件包许可：未声明

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40happyvertical/smrt-products
原文对照：https://npmcn.com/package/%40happyvertical/smrt-products/?lang=original
项目主页：https://github.com/happyvertical/smrt#readme
源码仓库：https://github.com/happyvertical/smrt

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：757 kB，163 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：14 个
- peer 依赖：svelte ^5\.57\.0
- 首次发布：2026-06-23T01:18:43.306Z
- 最新版本发布：2026-11-17T07:54:16.521Z
- 近 30 天下载量：16931（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：365（近 12 个月 365 个）

## 中文简介

SMRT产品模块:用于独立应用程序、联邦模块和国家预防机制图书馆的三重用途微服务模板

## 安装

```sh
npm install @happyvertical/smrt-products
```

也可以使用：`pnpm add @happyvertical/smrt-products`、`yarn add @happyvertical/smrt-products`、`bun add @happyvertical/smrt-products`

## README

# @happyvertical/ smrt- 产品

产品目录参考模板,展示三重消费:npm包库,模块联合会,以及独立的REST API服务器.

## 安装

```bash
pnpm add @happyvertical/smrt-products
```

## 使用量

### 导入为 npm 库

```typescript
import { Product, ProductCollection, Category } from '@happyvertical/smrt-products';
import { startServer } from '@happyvertical/smrt-products';
import { generateMCPServer } from '@happyvertical/smrt-products';
import { AssetCollection } from '@happyvertical/smrt-assets';

// Start standalone REST API server
const { shutdown } = await startServer();

const products = await ProductCollection.create();
const assets = await AssetCollection.create();
const product = await products.create({
  name: 'Demo Product',
  price: 29.99,
});
const hero = await assets.create({
  name: 'demo-product-hero.jpg',
  sourceUri: 'file:///tmp/demo-product-hero.jpg',
  mimeType: 'image/jpeg',
});

await product.addAsset(hero, 'hero');
await products.addAsset(product.id!, hero, 'gallery', 1);
```

### 三种消费方式

1.  **国家预防机制图书馆** -- 直接导入类别、组件和存储
2.  **模块联合会** -- 运行时间组件共享(实验性)
3.  **独立 API** - 说吧 `startServer()` 带有自动生成路线的快车

## API 密码

### 顶级出口

| 导出 | 说明 |
| --- | --- |
| `startServer` | 启动独立的 REST API 服务器 |
| `generateMCPServer` | 生成用于 AI 工具集成的 MCP 服务器 |
| `demonstrateClient` | 自动生成的 TypeScript 客户端的解析 |
| `startAll` | 启动所有服务(REST + MCP) |

### 型号(从 `lib/models`(中文(简体) )

| 导出 | 说明 |
| --- | --- |
| `Product` | 带有规格和标签的科技和创新产品 |
| `Category` | 等级分类(父母身份、级别、产品) |
| `ProductAsset` | 专用自有资产加入存储于 `product_assets` 与 `relationship` 财务报告和审定财务报表 `sortOrder`;由于 `Product` 没有租户范围 |

### 收款(从 `lib/collections`(中文(简体) )

| 导出 | 说明 |
| --- | --- |
| `ProductCollection` | CROUD 外加号 `findByManufacturer()`, (中文(简体) ), `findInStock()`和自有资产包装 |
| `ProductAssetCollection` | 直接进入 `product_assets` 行外加资产助手包装 |

### 构成部分(从 `lib/components`(中文(简体) )

| 导出 | 说明 |
| --- | --- |
| `ProductCard` | Svelte 5 产品显示组件 |
| `ProductForm` | Svelte 5 产品编辑表 |

### 库存(从 `lib/stores`(中文(简体) )

| 导出 | 说明 |
| --- | --- |
| `ProductStoreClass` | Svelte 5 个基于 rune 的州级管理课程 |
| `productStore` | Singleton 存储实例 |

### 水电费(从 `lib/utils`(中文(简体) )

| 导出 | 说明 |
| --- | --- |
| `formatPrice` | 格式编号为USD 货币字符串 |
| `formatDate` | 格式化日期为可读字符串 |
| `slugify` | 将文本转换为方便 URL 的 sult |
| `generateId` | 生成随机 ID 字符串 |

### 虚拟模块( Vite 插件)

| 导出 | 说明 |
| --- | --- |
| `createClient` | 自动生成 TypeScript API 客户端 |
| `setupRoutes` | 自动生成的快车路线 |
| `createMCPServer` | 自动生成的 MCP 服务器 |
| `manifest` | s-m-r-t 对象元数据 |

双方都有自有资产助手 `Product` 财务报告和审定财务报表 `ProductCollection` 通过 `getAssets()`, (中文(简体) ), `addAsset()`,以及 `removeAsset()`共同关系包括: `hero`, (中文(简体) ), `gallery`, (中文(简体) ), `attachment`,以及 `thumbnail`。 。 。 .

## 依赖关系

| 软件包 | 目的 |
| --- | --- |
| `@happyvertical/smrt-core` | Smrt Object/Smrt Collection base class, REST 服务器, MCP 生成器 |
| `@happyvertical/smrt-assets` | 产品自有资产助手使用的共享资产/资产收集类型 |
| `@happyvertical/sql` | 数据库操作 |
| `@happyvertical/ai` | 大赦国际一体化 |

## 常见问题

### @happyvertical/smrt-products 是什么？

SMRT产品模块:用于独立应用程序、联邦模块和国家预防机制图书馆的三重用途微服务模板

### 如何安装 @happyvertical/smrt-products？

在项目目录运行 npm install @happyvertical/smrt-products，或使用 pnpm add / yarn add / bun add。

### @happyvertical/smrt-products 支持 TypeScript 吗？

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

### @happyvertical/smrt-products 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @happyvertical/smrt-products 可以商用吗？

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

### @happyvertical/smrt-products 的下载量有多少？

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

### @happyvertical/smrt-products 还在维护吗？

最新版本 0\.62\.1 发布于 2026/11/17（今天）；至今共发布 365 个版本，其中过去 12 个月发布了 365 个；首次发布于 2026/06/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

