Selaa lähdekoodia

📝 docs(prd): update shared-types and module export documentation

- 移除shared-types中的zod依赖说明,明确纯类型定义特性
- 重构shared-types导出内容,增加基础工具类型和通用响应类型
- 调整业务相关类型组织方式,移至各自业务模块package中
- 更新geo-areas、geo-locations和mini-auth等模块的类型定义示例
- 修改使用示例,增加类型导入方式和通用类型使用说明
yourname 4 viikkoa sitten
vanhempi
sitoutus
fb028b5774
1 muutettua tiedostoa jossa 75 lisäystä ja 36 poistoa
  1. 75 36
      docs/prd/epic-005-mini-auth-modules-integration.md

+ 75 - 36
docs/prd/epic-005-mini-auth-modules-integration.md

@@ -241,7 +241,7 @@ server (应用入口)
 {
   "name": "@d8d/shared-types",
   "dependencies": {
-    "zod": "^4.1.12"
+    // 纯类型定义,不需要外部依赖
   }
 }
 ```
@@ -334,46 +334,44 @@ server (应用入口)
 
 #### shared-types 导出
 ```typescript
-// 基础类型
-export interface BaseEntity {
-  id: string;
-  createdAt: Date;
-  updatedAt: Date;
+// 基础工具类型
+export type DeepPartial<T> = {
+  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
+};
+
+// 通用响应类型
+export interface ApiResponse<T> {
+  data: T;
+  message?: string;
+  code?: number;
 }
 
-// 地区相关类型
-export interface Area {
-  id: string;
-  name: string;
-  code: string;
-  level: number;
-  parentId?: string;
+// 分页类型
+export interface Pagination {
+  total: number;
+  current: number;
+  pageSize: number;
 }
 
-// 地点相关类型
-export interface Location {
-  id: string;
-  name: string;
-  latitude: number;
-  longitude: number;
-  areaId: string;
+// 通用查询参数
+export interface QueryParams {
+  page?: number;
+  pageSize?: number;
+  keyword?: string;
+  sortBy?: string;
+  sortOrder?: 'ASC' | 'DESC';
 }
 
-// 小程序相关类型
-export interface MiniAuthUser {
-  openid: string;
-  unionid?: string;
-  sessionKey: string;
+// 通用错误类型
+export interface ApiError {
+  code: number;
+  message: string;
+  details?: any;
 }
-
-// Zod schemas
-export const areaSchema = z.object({
-  // ...
-});
 ```
 
 #### 模块 package 导出模式
-每个模块 package 遵循统一的导出模式:
+每个模块 package 遵循统一的导出模式,业务相关类型放在各自package中:
 
 ```typescript
 // 实体
@@ -391,10 +389,48 @@ export { AreaController } from './controllers/area.controller';
 // 路由
 export { areaRoutes } from './routes/area.routes';
 
-// 类型
+// 业务相关类型 (放在各自package中)
 export type { Area, AreaLevel } from './types/area.types';
 ```
 
+#### 业务模块类型示例
+
+**geo-areas package 中的类型**
+```typescript
+// 地区相关类型
+export interface Area {
+  id: string;
+  name: string;
+  code: string;
+  level: number;
+  parentId?: string;
+}
+
+export type AreaLevel = 1 | 2 | 3; // 省市区
+```
+
+**geo-locations package 中的类型**
+```typescript
+// 地点相关类型
+export interface Location {
+  id: string;
+  name: string;
+  latitude: number;
+  longitude: number;
+  areaId: string;
+}
+```
+
+**mini-auth package 中的类型**
+```typescript
+// 小程序认证相关类型
+export interface MiniAuthUser {
+  openid: string;
+  unionid?: string;
+  sessionKey: string;
+}
+```
+
 ### 使用示例
 
 #### 项目按需使用
@@ -428,10 +464,13 @@ export type { Area, AreaLevel } from './types/area.types';
 
 #### 代码中使用
 ```typescript
-// 只导入需要的模块
-import { AreaService } from '@d8d/geo-areas';
-import { LocationService } from '@d8d/geo-locations';
-import { MiniAuthService } from '@d8d/mini-auth';
+// 只导入需要的模块和类型
+import { AreaService, type Area } from '@d8d/geo-areas';
+import { LocationService, type Location } from '@d8d/geo-locations';
+import { MiniAuthService, type MiniAuthUser } from '@d8d/mini-auth';
+
+// 使用通用类型
+import type { ApiResponse, Pagination } from '@d8d/shared-types';
 
 // 或者从 server 统一导入
 import {