open-index/open-npm huggingface dataset:
npm package: @huaiyou/types
Description: Shared TypeScript type definitions
Latest version: 1.0.0

# @huaiyou/types

> 共享的 TypeScript 类型定义，适用于整个 monorepo。

## 📦 安装

```bash
pnpm add @huaiyou/types
```

## 🚀 使用方法

```typescript
import type { User, ApiResponse, PaginatedResponse } from '@huaiyou/types';

// 使用类型
const user: User = {
  id: '1',
  username: 'john',
  email: 'john@example.com',
  createdAt: new Date(),
  updatedAt: new Date(),
};

// API 响应
const response: ApiResponse<User> = {
  code: 200,
  message: 'Success',
  data: user,
  timestamp: Date.now(),
};

// 分页数据
const pageData: PaginatedResponse<User> = {
  items: [user],
  total: 100,
  page: 1,
  pageSize: 10,
  totalPages: 10,
};
```

## 📋 类型定义

### User

用户信息类型：

```typescript
interface User {
  id: string;
  username: string;
  email: string;
  avatar?: string;
  createdAt: Date;
  updatedAt: Date;
}
```

### ApiResponse<T>

API 响应包装类型：

```typescript
interface ApiResponse<T = unknown> {
  code: number;
  message: string;
  data: T;
  timestamp: number;
}
```

### PaginatedResponse<T>

分页响应类型：

```typescript
interface PaginatedResponse<T = unknown> {
  items: T[];
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
}
```

### ApiError

错误类型：

```typescript
interface ApiError {
  code: string;
  message: string;
  details?: Record<string, unknown>;
}
```

### AuthToken

认证令牌类型：

```typescript
interface AuthToken {
  accessToken: string;
  refreshToken: string;
  expiresIn: number;
}
```

### MenuItem

菜单/导航项类型：

```typescript
interface MenuItem {
  id: string;
  label: string;
  icon?: string;
  path?: string;
  children?: MenuItem[];
  permissions?: string[];
}
```

## 🔧 扩展类型

### 创建新类型

在你的项目中扩展基础类型：

```typescript
import type { User } from '@huaiyou/types';

// 扩展 User 类型
interface AdminUser extends User {
  role: 'admin' | 'superadmin';
  permissions: string[];
}

// 或创建新的联合类型
type UserRole = 'user' | 'admin' | 'superadmin';

interface ExtendedUser extends User {
  role: UserRole;
}
```

### 泛型使用

```typescript
import type { ApiResponse, PaginatedResponse } from '@huaiyou/types';

interface Product {
  id: string;
  name: string;
  price: number;
}

// 产品列表响应
type ProductListResponse = ApiResponse<PaginatedResponse<Product>>;

// 单个产品响应
type ProductResponse = ApiResponse<Product>;
```

## 📝 最佳实践

1. **使用 type 导入**: 使用 `import type` 导入类型，避免运行时开销

   ```typescript
   import type { User } from '@huaiyou/types';
   ```

2. **类型组合**: 使用 TypeScript 的类型组合功能

   ```typescript
   type UserWithRole = User & { role: string };
   type OptionalUser = Partial<User>;
   type RequiredUser = Required<User>;
   ```

3. **类型守卫**: 创建类型守卫函数

   ```typescript
   function isApiError(error: unknown): error is ApiError {
     return typeof error === 'object' && error !== null && 'code' in error && 'message' in error;
   }
   ```

4. **泛型约束**: 使用泛型约束确保类型安全

   ```typescript
   function processResponse<T extends { id: string }>(response: ApiResponse<T>): T {
     return response.data;
   }
   ```

## 🤝 贡献

如需添加新的共享类型定义，请提交 Pull Request。

## 📄 License

MIT
npm package: @huajie-ng/amap
Description: This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.1.0.
Latest version: 1.2.0

# Amap

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.1.0.

## Code scaffolding

Run `ng generate component component-name --project amap` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project amap`.
> Note: Don't forget to add `--project amap` or else it will be added to the default project in your `angular.json` file. 

## Build

Run `ng build amap` to build the project. The build artifacts will be stored in the `dist/` directory.

## Publishing

After building your library with `ng build amap`, go to the dist folder `cd dist/amap` and run `npm publish`.

## Running unit tests

Run `ng test amap` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.