@newpeak/barista-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +23 -0
- package/.prettierrc +9 -0
- package/.sisyphus/notepads/liberica-employees/learnings.md +73 -0
- package/AGENTS.md +270 -0
- package/CONTRIBUTING.md +291 -0
- package/README.md +707 -0
- package/bin/barista +6 -0
- package/bin/barista.js +3 -0
- package/docs/ARCHITECTURE.md +184 -0
- package/docs/COMMANDS.md +352 -0
- package/docs/COMMAND_DESIGN_SPEC.md +811 -0
- package/docs/INTEGRATION_NOTES.md +270 -0
- package/docs/commands/REFERENCE.md +297 -0
- package/docs/commands/arabica/auth/index.md +296 -0
- package/docs/commands/liberica/auth/index.md +133 -0
- package/docs/commands/liberica/context/index.md +60 -0
- package/docs/commands/liberica/employees/create.md +185 -0
- package/docs/commands/liberica/employees/disable.md +138 -0
- package/docs/commands/liberica/employees/enable.md +137 -0
- package/docs/commands/liberica/employees/get.md +153 -0
- package/docs/commands/liberica/employees/list.md +168 -0
- package/docs/commands/liberica/employees/update.md +180 -0
- package/docs/commands/liberica/orgs/list.md +62 -0
- package/docs/commands/liberica/positions/list.md +61 -0
- package/docs/commands/liberica/roles/list.md +67 -0
- package/docs/commands/liberica/users/create.md +170 -0
- package/docs/commands/liberica/users/get.md +151 -0
- package/docs/commands/liberica/users/list.md +175 -0
- package/package.json +37 -0
- package/src/commands/arabica/auth/index.ts +277 -0
- package/src/commands/arabica/auth/login.ts +5 -0
- package/src/commands/arabica/auth/logout.ts +5 -0
- package/src/commands/arabica/auth/register.ts +5 -0
- package/src/commands/arabica/auth/status.ts +5 -0
- package/src/commands/arabica/index.ts +23 -0
- package/src/commands/auth.ts +107 -0
- package/src/commands/context.ts +60 -0
- package/src/commands/liberica/auth/index.ts +170 -0
- package/src/commands/liberica/context/index.ts +43 -0
- package/src/commands/liberica/employees/create.ts +275 -0
- package/src/commands/liberica/employees/delete.ts +122 -0
- package/src/commands/liberica/employees/disable.ts +97 -0
- package/src/commands/liberica/employees/enable.ts +97 -0
- package/src/commands/liberica/employees/get.ts +115 -0
- package/src/commands/liberica/employees/index.ts +23 -0
- package/src/commands/liberica/employees/list.ts +131 -0
- package/src/commands/liberica/employees/update.ts +157 -0
- package/src/commands/liberica/index.ts +36 -0
- package/src/commands/liberica/orgs/index.ts +35 -0
- package/src/commands/liberica/positions/index.ts +30 -0
- package/src/commands/liberica/roles/index.ts +59 -0
- package/src/commands/liberica/users/create.ts +132 -0
- package/src/commands/liberica/users/delete.ts +49 -0
- package/src/commands/liberica/users/disable.ts +41 -0
- package/src/commands/liberica/users/enable.ts +30 -0
- package/src/commands/liberica/users/get.ts +46 -0
- package/src/commands/liberica/users/index.ts +27 -0
- package/src/commands/liberica/users/list.ts +68 -0
- package/src/commands/liberica/users/me.ts +42 -0
- package/src/commands/liberica/users/reset-password.ts +42 -0
- package/src/commands/liberica/users/update.ts +48 -0
- package/src/core/api/client.ts +825 -0
- package/src/core/auth/token-manager.ts +183 -0
- package/src/core/config/manager.ts +164 -0
- package/src/index.ts +37 -0
- package/src/types/employee.ts +102 -0
- package/src/types/index.ts +75 -0
- package/src/types/org.ts +25 -0
- package/src/types/position.ts +24 -0
- package/src/types/user.ts +64 -0
- package/tests/unit/commands/arabica/auth.test.ts +230 -0
- package/tests/unit/commands/liberica/auth.test.ts +175 -0
- package/tests/unit/commands/liberica/context.test.ts +98 -0
- package/tests/unit/commands/liberica/employees/create.test.ts +463 -0
- package/tests/unit/commands/liberica/employees/disable.test.ts +82 -0
- package/tests/unit/commands/liberica/employees/enable.test.ts +82 -0
- package/tests/unit/commands/liberica/employees/get.test.ts +111 -0
- package/tests/unit/commands/liberica/employees/list.test.ts +294 -0
- package/tests/unit/commands/liberica/employees/update.test.ts +210 -0
- package/tests/unit/config.test.ts +141 -0
- package/tests/unit/types.test.ts +195 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Liberica API Integration Notes
|
|
2
|
+
|
|
3
|
+
This document captures the lessons learned from integrating with the Liberica backend API.
|
|
4
|
+
|
|
5
|
+
## Authentication
|
|
6
|
+
|
|
7
|
+
### Authorization Header
|
|
8
|
+
|
|
9
|
+
The API expects the token directly without `Bearer` prefix:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// WRONG
|
|
13
|
+
this.client.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
14
|
+
|
|
15
|
+
// CORRECT
|
|
16
|
+
this.client.defaults.headers.common['Authorization'] = token;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Tenant Header (X-TENANT-ID)
|
|
20
|
+
|
|
21
|
+
**IMPORTANT**: The `X-TENANT-ID` header is NOT required. The tenant is embedded in the JWT token.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// WRONG - Backend expects Long but we pass String
|
|
25
|
+
{ headers: { 'X-TENANT-ID': tenant } }
|
|
26
|
+
|
|
27
|
+
// CORRECT - Don't pass X-TENANT-ID at all
|
|
28
|
+
// Tenant is extracted from JWT token by the backend
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Adding `X-TENANT-ID` with string tenant name causes `NumberFormatException: For input string: "shanghai"` because the backend expects a numeric tenant ID.
|
|
32
|
+
|
|
33
|
+
## BigInteger IDs
|
|
34
|
+
|
|
35
|
+
**CRITICAL**: Backend returns BigInteger for ID fields, which exceeds JavaScript's `number` range (max safe integer: 9007199254740991).
|
|
36
|
+
|
|
37
|
+
**Always use `string` type for ID fields in TypeScript**:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// WRONG - Precision loss for IDs > 9007199254740991
|
|
41
|
+
interface Employee {
|
|
42
|
+
employeeId: number; // Will lose precision!
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// CORRECT - Use string for IDs
|
|
46
|
+
interface Employee {
|
|
47
|
+
employeeId: string;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Affected Fields
|
|
52
|
+
- `Employee.employeeId` - always use string
|
|
53
|
+
- `Employee.organizationId` - always use string
|
|
54
|
+
- `UpdateEmployeeRequest.employeeId` - always use string
|
|
55
|
+
- Any ID field from backend that is BigInteger
|
|
56
|
+
|
|
57
|
+
## API Endpoints
|
|
58
|
+
|
|
59
|
+
### Base URL Pattern
|
|
60
|
+
```
|
|
61
|
+
https://{tenant}-{env}.newpeaksh.com/api/...
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Required Prefix
|
|
65
|
+
All endpoints require the `/api` prefix:
|
|
66
|
+
```
|
|
67
|
+
/api/enterprise/employee/page
|
|
68
|
+
/api/enterprise/employee/add
|
|
69
|
+
/api/enterprise/employee/edit
|
|
70
|
+
/api/enterprise/employee/delete
|
|
71
|
+
/api/enterprise/employee/deActive
|
|
72
|
+
/api/enterprise/employee/active
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### HTTP Methods
|
|
76
|
+
Different endpoints use different HTTP methods:
|
|
77
|
+
|
|
78
|
+
| Endpoint | Method | Notes |
|
|
79
|
+
|----------|--------|-------|
|
|
80
|
+
| `/employee/page` | GET | List with pagination |
|
|
81
|
+
| `/employee/detail` | GET | Single item lookup |
|
|
82
|
+
| `/employee/add` | POST | Create |
|
|
83
|
+
| `/employee/edit` | POST | Update |
|
|
84
|
+
| `/employee/delete` | POST | Delete |
|
|
85
|
+
| `/employee/active` | POST | Enable |
|
|
86
|
+
| `/employee/deActive` | POST | Disable |
|
|
87
|
+
| `/master/org/tree` | POST | Get org list (POST required, not GET) |
|
|
88
|
+
| `/master/position/list` | GET | Get position list |
|
|
89
|
+
|
|
90
|
+
## Pagination
|
|
91
|
+
|
|
92
|
+
### 0-Based Pagination
|
|
93
|
+
The backend uses 0-based pagination (page starts at 0, not 1):
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// CLI page 1 -> API page 0
|
|
97
|
+
const page = parseInt(options.page as string, 10) - 1;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Query Parameters
|
|
101
|
+
Use `pageNo` and `pageSize` (not `page` and `size`):
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
/api/enterprise/employee/page?pageNo=0&pageSize=20
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Response Field Names
|
|
108
|
+
|
|
109
|
+
The backend uses different field names than typical conventions:
|
|
110
|
+
|
|
111
|
+
| Backend Field | Standard Field | Description |
|
|
112
|
+
|-------------|---------------|-------------|
|
|
113
|
+
| `rows` | `records` | Array of items |
|
|
114
|
+
| `pageNo` | `current` | Current page number |
|
|
115
|
+
| `pageSize` | `size` | Items per page |
|
|
116
|
+
| `totalRows` | `total` | Total item count |
|
|
117
|
+
|
|
118
|
+
### Example Response
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"success": true,
|
|
122
|
+
"data": {
|
|
123
|
+
"pageNo": 1,
|
|
124
|
+
"pageSize": 20,
|
|
125
|
+
"totalRows": 19,
|
|
126
|
+
"totalPage": 1,
|
|
127
|
+
"rows": [...]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Error Response Format
|
|
133
|
+
|
|
134
|
+
**IMPORTANT**: Backend error format varies - may be at top level OR nested under `error`:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Backend returns ONE of these formats:
|
|
138
|
+
|
|
139
|
+
// Format 1: Error at top level (common for delete, enable, disable)
|
|
140
|
+
{
|
|
141
|
+
"success": false,
|
|
142
|
+
"code": "A150001",
|
|
143
|
+
"message": "A150001: 查询结果不存在"
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Format 2: Error nested under 'error' object
|
|
147
|
+
{
|
|
148
|
+
"success": false,
|
|
149
|
+
"error": {
|
|
150
|
+
"code": "01001150001",
|
|
151
|
+
"message": "职员不存在"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Handle in handleApiError():
|
|
157
|
+
```typescript
|
|
158
|
+
function handleApiError(error: unknown): EmployeeApiResponse {
|
|
159
|
+
if (axios.isAxiosError(error)) {
|
|
160
|
+
const responseData = axiosError.response?.data;
|
|
161
|
+
if (responseData) {
|
|
162
|
+
const success = responseData.success as boolean | undefined;
|
|
163
|
+
if (success === false) {
|
|
164
|
+
const code = responseData.code as string | undefined;
|
|
165
|
+
const message = responseData.message as string | undefined;
|
|
166
|
+
const errorObj = responseData.error as { code?: string; message?: string } | undefined;
|
|
167
|
+
if (!errorObj && (code || message)) {
|
|
168
|
+
return {
|
|
169
|
+
success: false,
|
|
170
|
+
error: {
|
|
171
|
+
code: code || 'API_ERROR',
|
|
172
|
+
message: message || 'API error occurred',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return responseData as EmployeeApiResponse;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// ...
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Null Data Handling
|
|
185
|
+
|
|
186
|
+
When the API returns no data, the `data` field may be:
|
|
187
|
+
- `null`
|
|
188
|
+
- Not present in the response
|
|
189
|
+
|
|
190
|
+
Always check for null before accessing data fields:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const data = response.data as EmployeeListResponse | null;
|
|
194
|
+
|
|
195
|
+
if (!data) {
|
|
196
|
+
console.log('No data found');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Error Codes
|
|
202
|
+
|
|
203
|
+
| Code | Message | Cause |
|
|
204
|
+
|------|---------|-------|
|
|
205
|
+
| B0301 | TOKEN解析失败 | Invalid or expired token |
|
|
206
|
+
| B0001 | 系统执行出错 | Internal server error (check exceptionTip) |
|
|
207
|
+
| A150001 | 查询结果不存在 | Resource not found |
|
|
208
|
+
| A1504 | 当前接口不支持GET方式请求 | Wrong HTTP method (should be POST) |
|
|
209
|
+
|
|
210
|
+
## Common Issues
|
|
211
|
+
|
|
212
|
+
### 1. Token Parsing Failed
|
|
213
|
+
**Error**: `B0301: TOKEN解析失败,请重新登录`
|
|
214
|
+
|
|
215
|
+
**Cause**: Token format issue or secret mismatch.
|
|
216
|
+
|
|
217
|
+
**Solution**: Re-authenticate and ensure the token is passed without `Bearer` prefix.
|
|
218
|
+
|
|
219
|
+
### 2. X-TENANT-ID Causing NumberFormatException
|
|
220
|
+
**Error**: `NumberFormatException: For input string: "shanghai"`
|
|
221
|
+
|
|
222
|
+
**Cause**: Passing `X-TENANT-ID` header with string tenant name. Backend expects numeric tenant ID or no header at all.
|
|
223
|
+
|
|
224
|
+
**Solution**: Do NOT pass `X-TENANT-ID` header. Tenant is embedded in JWT token.
|
|
225
|
+
|
|
226
|
+
### 3. Wrong HTTP Method
|
|
227
|
+
**Error**: `A1504: 当前接口不支持GET方式请求`
|
|
228
|
+
|
|
229
|
+
**Cause**: Using GET when endpoint requires POST (or vice versa).
|
|
230
|
+
|
|
231
|
+
**Solution**: Check endpoint documentation for correct HTTP method.
|
|
232
|
+
|
|
233
|
+
### 4. BigInteger Precision Loss
|
|
234
|
+
**Symptom**: Employee IDs display as truncated in CLI, API calls fail with "not found" for valid IDs.
|
|
235
|
+
|
|
236
|
+
**Cause**: ID is BigInteger > 9007199254740991, losing precision in JavaScript number.
|
|
237
|
+
|
|
238
|
+
**Solution**: Use string type for all ID fields.
|
|
239
|
+
|
|
240
|
+
### 5. Empty Results Despite Data
|
|
241
|
+
**Cause**: Field name mismatch between client and API.
|
|
242
|
+
|
|
243
|
+
**Solution**: Verify you are using the correct field names from the response, not assumed names.
|
|
244
|
+
|
|
245
|
+
## Testing
|
|
246
|
+
|
|
247
|
+
### Verify API Connection
|
|
248
|
+
```bash
|
|
249
|
+
# Login first
|
|
250
|
+
node ./bin/barista.js liberica auth login dev <tenant> <email> <password>
|
|
251
|
+
|
|
252
|
+
# Test list
|
|
253
|
+
node ./bin/barista.js liberica employees list
|
|
254
|
+
|
|
255
|
+
# Test with JSON output
|
|
256
|
+
node ./bin/barista.js liberica employees list --json
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Debug API Calls
|
|
260
|
+
Add temporary logging to see raw responses:
|
|
261
|
+
```typescript
|
|
262
|
+
console.error('DEBUG response:', JSON.stringify(response, null, 2));
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## File Locations
|
|
266
|
+
|
|
267
|
+
- API Client: `src/core/api/client.ts`
|
|
268
|
+
- Types: `src/types/employee.ts`
|
|
269
|
+
- Commands: `src/commands/liberica/employees/*.ts`
|
|
270
|
+
- Config: `~/.barista/config.yaml`
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Barista CLI 命令参考
|
|
2
|
+
|
|
3
|
+
> 基于实际业务需求整理的所有功能清单,按 Arabica(销售前端)和 Liberica(生产管理)分类。
|
|
4
|
+
|
|
5
|
+
## 📊 命令统计总览
|
|
6
|
+
|
|
7
|
+
| 服务 | 模块 | 命令数量 | 状态 | 优先级 |
|
|
8
|
+
|------|------|---------|------|--------|
|
|
9
|
+
| **Arabica** | auth | 4 | ✅ 已实现 | P0 |
|
|
10
|
+
| **Arabica** | members | 3 | 📋 待开发 | P0 |
|
|
11
|
+
| **Arabica** | enterprises | 3 | 📋 待开发 | P0 |
|
|
12
|
+
| **Arabica** | products | 2 | 📋 待开发 | P1 |
|
|
13
|
+
| **Arabica** | subscriptions | 4 | 📋 待开发 | P0 |
|
|
14
|
+
| **Arabica** | access | 1 | 📋 待开发 | P0 |
|
|
15
|
+
| **Liberica** | auth | 2 | ✅ 已实现 | P0 |
|
|
16
|
+
| **Liberica** | context | 3 | ✅ 已实现 | P0 |
|
|
17
|
+
| **Liberica** | users | 3 | 📋 待开发 | P1 |
|
|
18
|
+
| **Liberica** | employees | 3 | 📋 待开发 | P1 |
|
|
19
|
+
| **Liberica** | clients | 4 | 📋 待开发 | P0 |
|
|
20
|
+
| **Liberica** | suppliers | 4 | 📋 待开发 | P0 |
|
|
21
|
+
| **Liberica** | materials | 5 | 📋 待开发 | P0 |
|
|
22
|
+
| **Liberica** | sales-prices | 4 | 📋 待开发 | P1 |
|
|
23
|
+
| **Liberica** | purchase-prices | 4 | 📋 待开发 | P1 |
|
|
24
|
+
| **Liberica** | sales-orders | 5 | 📋 待开发 | P0 |
|
|
25
|
+
| **总计** | 16模块 | **47命令** | | |
|
|
26
|
+
|
|
27
|
+
**状态说明**:
|
|
28
|
+
- ✅ 已实现 - 功能已完成,可在 `src/commands/` 目录查看实现
|
|
29
|
+
- 📋 待开发 - 功能已设计但尚未实现,需按设计规范开发
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🌐 Arabica 命令(销售前端)
|
|
34
|
+
|
|
35
|
+
> **用户**: 最终客户(潜在租户企业的代表)
|
|
36
|
+
> **访问**: www.newpeaksh.com / members.newpeakjp.com
|
|
37
|
+
|
|
38
|
+
### 1. auth(认证)- ✅ 已实现
|
|
39
|
+
|
|
40
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
41
|
+
|------|------|------|------|----------|
|
|
42
|
+
| 会员登录 | `barista arabica auth login [env] [account] [password]` | POST | 获取访问Token | [docs](./arabica/auth/index.md) |
|
|
43
|
+
| 注册会员 | `barista arabica auth register [env] [email] [password] [phone] [username]` | POST | 新用户注册 | [docs](./arabica/auth/index.md) |
|
|
44
|
+
| 获取登录状态 | `barista arabica auth status` | GET | 查看当前登录状态 | [docs](./arabica/auth/index.md) |
|
|
45
|
+
| 登出 | `barista arabica auth logout` | - | 清除登录Token | [docs](./arabica/auth/index.md) |
|
|
46
|
+
|
|
47
|
+
### 2. members(会员管理)- 📋 待开发
|
|
48
|
+
|
|
49
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
50
|
+
|------|------|------|------|----------|
|
|
51
|
+
| 注册会员 | `barista arabica members register` | POST | 新用户注册 | 待创建 |
|
|
52
|
+
| 会员登录 | `barista arabica members login` | POST | 获取访问Token | 待创建 |
|
|
53
|
+
| 获取会员信息 | `barista arabica members get` | GET | 查看当前会员详情 | 待创建 |
|
|
54
|
+
|
|
55
|
+
### 3. enterprises(企业管理)- 📋 待开发
|
|
56
|
+
|
|
57
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
58
|
+
|------|------|------|------|----------|
|
|
59
|
+
| 注册企业 | `barista arabica enterprises register` | POST | 会员创建新企业 | 待创建 |
|
|
60
|
+
| 获取企业列表 | `barista arabica enterprises list` | GET | 查看会员关联的所有企业 | 待创建 |
|
|
61
|
+
| 获取企业详情 | `barista arabica enterprises get <id>` | GET | 查看企业详细信息 | 待创建 |
|
|
62
|
+
|
|
63
|
+
### 4. products(产品浏览)- 📋 待开发
|
|
64
|
+
|
|
65
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
66
|
+
|------|------|------|------|----------|
|
|
67
|
+
| 查询产品列表 | `barista arabica products list` | GET | 浏览可购买的SaaS产品 | 待创建 |
|
|
68
|
+
| 获取产品详情 | `barista arabica products get <id>` | GET | 查看产品详细信息 | 待创建 |
|
|
69
|
+
|
|
70
|
+
### 5. subscriptions(服务订阅)- 📋 待开发
|
|
71
|
+
|
|
72
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
73
|
+
|------|------|------|------|----------|
|
|
74
|
+
| 申请产品试用 | `barista arabica subscriptions trial` | POST | 申请免费试用 | 待创建 |
|
|
75
|
+
| 购买服务 | `barista arabica subscriptions purchase` | POST | 购买正式服务 | 待创建 |
|
|
76
|
+
| 获取已购买服务 | `barista arabica subscriptions list` | GET | 查看所有订阅(含试用) | 待创建 |
|
|
77
|
+
| 获取服务详情 | `barista arabica subscriptions get <id>` | GET | 查看订阅详情 | 待创建 |
|
|
78
|
+
|
|
79
|
+
### 6. access(系统访问)- 📋 待开发
|
|
80
|
+
|
|
81
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
82
|
+
|------|------|------|------|----------|
|
|
83
|
+
| 获取Liberica访问URL | `barista arabica access url` | GET | 获取租户系统访问地址 | 待创建 |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🏭 Liberica 命令(生产管理)
|
|
88
|
+
|
|
89
|
+
> **用户**: 租户企业内部员工
|
|
90
|
+
> **访问**: {tenant}.newpeaksh.com / {tenant}.newpeakjp.com
|
|
91
|
+
|
|
92
|
+
### 1. auth(认证)- ✅ 已实现
|
|
93
|
+
|
|
94
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
95
|
+
|------|------|------|------|----------|
|
|
96
|
+
| 租户企业账号登录 | `barista liberica auth login` | POST | 使用租户账号登录 | [docs](./liberica/auth/index.md) |
|
|
97
|
+
| 获取登录状态 | `barista liberica auth status` | GET | 查看当前登录状态 | [docs](./liberica/auth/index.md) |
|
|
98
|
+
|
|
99
|
+
### 2. context(上下文管理)- ✅ 已实现
|
|
100
|
+
|
|
101
|
+
| 功能 | 命令 | 说明 | 设计文档 |
|
|
102
|
+
|------|------|------|----------|
|
|
103
|
+
| 显示当前上下文 | `barista context show` | 查看当前环境、租户、Token状态 | [docs](./liberica/context/index.md) |
|
|
104
|
+
| 切换环境 | `barista context use-env [env]` | 切换操作的环境 | [docs](./liberica/context/index.md) |
|
|
105
|
+
| 切换租户 | `barista context use-tenant <tenant>` | 切换操作的企业 | [docs](./liberica/context/index.md) |
|
|
106
|
+
|
|
107
|
+
### 3. users(用户管理)- 📋 待开发
|
|
108
|
+
|
|
109
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
110
|
+
|------|------|------|------|----------|
|
|
111
|
+
| 创建新用户 | `barista liberica users create` | POST | 创建系统用户账号 | 待创建 |
|
|
112
|
+
| 获取用户列表 | `barista liberica users list` | GET | 查看所有用户 | 待创建 |
|
|
113
|
+
| 获取用户详情 | `barista liberica users get <id>` | GET | 查看用户信息 | 待创建 |
|
|
114
|
+
|
|
115
|
+
### 4. employees(职员管理)- 📋 待开发
|
|
116
|
+
|
|
117
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
118
|
+
|------|------|------|------|----------|
|
|
119
|
+
| 创建新职员 | `barista liberica employees create` | POST | 添加企业员工 | 待创建 |
|
|
120
|
+
| 获取职员列表 | `barista liberica employees list` | GET | 查看所有职员 | 待创建 |
|
|
121
|
+
| 获取职员详情 | `barista liberica employees get <id>` | GET | 查看职员信息 | 待创建 |
|
|
122
|
+
|
|
123
|
+
### 5. clients(客户管理)- 📋 待开发
|
|
124
|
+
|
|
125
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
126
|
+
|------|------|------|------|----------|
|
|
127
|
+
| 创建客户 | `barista liberica clients create` | POST | 添加下游客户 | 待创建 |
|
|
128
|
+
| 获取客户列表 | `barista liberica clients list` | GET | 查看所有客户 | 待创建 |
|
|
129
|
+
| 获取客户详情 | `barista liberica clients get <id>` | GET | 查看客户信息 | 待创建 |
|
|
130
|
+
| 更新客户 | `barista liberica clients update <id>` | POST | 修改客户信息 | 待创建 |
|
|
131
|
+
|
|
132
|
+
### 6. suppliers(供应商管理)- 📋 待开发
|
|
133
|
+
|
|
134
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
135
|
+
|------|------|------|------|----------|
|
|
136
|
+
| 创建供应商 | `barista liberica suppliers create` | POST | 添加上游供应商 | 待创建 |
|
|
137
|
+
| 获取供应商列表 | `barista liberica suppliers list` | GET | 查看所有供应商 | 待创建 |
|
|
138
|
+
| 获取供应商详情 | `barista liberica suppliers get <id>` | GET | 查看供应商信息 | 待创建 |
|
|
139
|
+
| 更新供应商 | `barista liberica suppliers update <id>` | POST | 修改供应商信息 | 待创建 |
|
|
140
|
+
|
|
141
|
+
### 7. materials(物料管理)- 📋 待开发
|
|
142
|
+
|
|
143
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
144
|
+
|------|------|------|------|----------|
|
|
145
|
+
| 创建物料 | `barista liberica materials create` | POST | 创建产品/原材料/半成品 | 待创建 |
|
|
146
|
+
| 获取物料列表 | `barista liberica materials list` | GET | 查看所有物料 | 待创建 |
|
|
147
|
+
| 获取物料详情 | `barista liberica materials get <id>` | GET | 查看物料信息 | 待创建 |
|
|
148
|
+
| 搜索物料 | `barista liberica materials search` | GET | 按条件搜索物料 | 待创建 |
|
|
149
|
+
| 更新物料 | `barista liberica materials update <id>` | POST | 修改物料信息 | 待创建 |
|
|
150
|
+
|
|
151
|
+
### 8. sales-prices(销售价格)- 📋 待开发
|
|
152
|
+
|
|
153
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
154
|
+
|------|------|------|------|----------|
|
|
155
|
+
| 添加销售价格 | `barista liberica sales-prices create` | POST | 设置物料的销售价格 | 待创建 |
|
|
156
|
+
| 查询销售价格 | `barista liberica sales-prices list` | GET | 查看销售价格列表 | 待创建 |
|
|
157
|
+
| 获取价格详情 | `barista liberica sales-prices get <id>` | GET | 查看价格详情 | 待创建 |
|
|
158
|
+
| 更新销售价格 | `barista liberica sales-prices update <id>` | POST | 修改销售价格 | 待创建 |
|
|
159
|
+
|
|
160
|
+
### 9. purchase-prices(采购价格)- 📋 待开发
|
|
161
|
+
|
|
162
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
163
|
+
|------|------|------|------|----------|
|
|
164
|
+
| 添加采购价格 | `barista liberica purchase-prices create` | POST | 设置物料的采购价格 | 待创建 |
|
|
165
|
+
| 查询采购价格 | `barista liberica purchase-prices list` | GET | 查看采购价格列表 | 待创建 |
|
|
166
|
+
| 获取价格详情 | `barista liberica purchase-prices get <id>` | GET | 查看价格详情 | 待创建 |
|
|
167
|
+
| 更新采购价格 | `barista liberica purchase-prices update <id>` | POST | 修改采购价格 | 待创建 |
|
|
168
|
+
|
|
169
|
+
### 10. sales-orders(销售订单)- 📋 待开发
|
|
170
|
+
|
|
171
|
+
| 功能 | 命令 | HTTP | 说明 | 设计文档 |
|
|
172
|
+
|------|------|------|------|----------|
|
|
173
|
+
| 创建销售订单 | `barista liberica sales-orders create` | POST | 创建新的销售订单 | 待创建 |
|
|
174
|
+
| 获取销售订单列表 | `barista liberica sales-orders list` | GET | 查看所有销售订单 | 待创建 |
|
|
175
|
+
| 获取销售订单详情 | `barista liberica sales-orders get <id>` | GET | 查看订单详情 | 待创建 |
|
|
176
|
+
| 更新销售订单 | `barista liberica sales-orders update <id>` | POST | 修改订单信息 | 待创建 |
|
|
177
|
+
| 取消销售订单 | `barista liberica sales-orders cancel <id>` | POST | 取消订单 | 待创建 |
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 🎯 开发优先级
|
|
182
|
+
|
|
183
|
+
### P0 - 核心功能(MVP必须)
|
|
184
|
+
|
|
185
|
+
**Arabica(销售前端)**:
|
|
186
|
+
1. `arabica members register/login` - 会员注册登录
|
|
187
|
+
2. `arabica enterprises register/list` - 企业注册管理
|
|
188
|
+
3. `arabica subscriptions trial/list` - 试用申请和服务查看
|
|
189
|
+
4. `arabica access url` - 获取Liberica访问地址
|
|
190
|
+
|
|
191
|
+
**Liberica(生产管理)**:
|
|
192
|
+
5. `liberica auth login` - 租户登录 ✅ 已实现
|
|
193
|
+
6. `liberica clients create/list` - 客户管理
|
|
194
|
+
7. `liberica suppliers create/list` - 供应商管理
|
|
195
|
+
8. `liberica materials create/list` - 物料管理
|
|
196
|
+
9. `liberica sales-orders create/list` - 销售订单
|
|
197
|
+
|
|
198
|
+
### P1 - 重要功能(第二阶段)
|
|
199
|
+
|
|
200
|
+
- `arabica products list/get` - 产品浏览
|
|
201
|
+
- `liberica users/employees` - 用户和职员管理
|
|
202
|
+
- `liberica sales-prices/purchase-prices` - 价格管理
|
|
203
|
+
- `liberica materials search/update` - 物料高级功能
|
|
204
|
+
|
|
205
|
+
### P2 - 扩展功能(后续迭代)
|
|
206
|
+
|
|
207
|
+
- 更新操作(所有 update/cancel 命令)
|
|
208
|
+
- 高级搜索和筛选
|
|
209
|
+
- 批量操作
|
|
210
|
+
- 报表和统计
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 📝 设计文档目录结构
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
docs/commands/
|
|
218
|
+
├── REFERENCE.md # 本文件 - 命令总览
|
|
219
|
+
│
|
|
220
|
+
├── arabica/
|
|
221
|
+
│ ├── auth/ # ✅ 已实现
|
|
222
|
+
│ │ └── index.md
|
|
223
|
+
│ ├── members/ # 📋 待开发
|
|
224
|
+
│ │ └── index.md # 待创建
|
|
225
|
+
│ ├── enterprises/ # 📋 待开发
|
|
226
|
+
│ │ └── index.md # 待创建
|
|
227
|
+
│ ├── products/ # 📋 待开发
|
|
228
|
+
│ │ └── index.md # 待创建
|
|
229
|
+
│ ├── subscriptions/ # 📋 待开发
|
|
230
|
+
│ │ └── index.md # 待创建
|
|
231
|
+
│ └── access/ # 📋 待开发
|
|
232
|
+
│ └── index.md # 待创建
|
|
233
|
+
│
|
|
234
|
+
└── liberica/
|
|
235
|
+
├── auth/ # ✅ 已实现
|
|
236
|
+
│ └── index.md
|
|
237
|
+
├── context/ # ✅ 已实现
|
|
238
|
+
│ └── index.md
|
|
239
|
+
├── users/ # 📋 待开发
|
|
240
|
+
│ └── index.md # 待创建
|
|
241
|
+
├── employees/ # 📋 待开发
|
|
242
|
+
│ └── index.md # 待创建
|
|
243
|
+
├── clients/ # 📋 待开发
|
|
244
|
+
│ └── index.md # 待创建
|
|
245
|
+
├── suppliers/ # 📋 待开发
|
|
246
|
+
│ └── index.md # 待创建
|
|
247
|
+
├── materials/ # 📋 待开发
|
|
248
|
+
│ └── index.md # 待创建
|
|
249
|
+
├── sales-prices/ # 📋 待开发
|
|
250
|
+
│ └── index.md # 待创建
|
|
251
|
+
├── purchase-prices/ # 📋 待开发
|
|
252
|
+
│ └── index.md # 待创建
|
|
253
|
+
└── sales-orders/ # 📋 待开发
|
|
254
|
+
└── index.md # 待创建
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## ⚠️ 关键说明
|
|
260
|
+
|
|
261
|
+
### 1. 用户角色区分
|
|
262
|
+
|
|
263
|
+
**Arabica 用户**(会员):
|
|
264
|
+
- 可以是个人,也可以代表企业
|
|
265
|
+
- 可以注册多个企业
|
|
266
|
+
- 主要操作:浏览、购买、管理订阅
|
|
267
|
+
|
|
268
|
+
**Liberica 用户**(租户内部):
|
|
269
|
+
- 必须是某个租户企业的员工
|
|
270
|
+
- 拥有系统账号和权限
|
|
271
|
+
- 主要操作:生产管理、订单处理
|
|
272
|
+
|
|
273
|
+
### 2. 数据流
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
Arabica(会员) Liberica(租户员工)
|
|
277
|
+
│ │
|
|
278
|
+
├─ 注册企业 ───────────────>├─ 企业成为租户
|
|
279
|
+
├─ 购买服务 ───────────────>├─ 开通租户账号
|
|
280
|
+
└─ 获取访问URL ────────────>└─ 登录生产系统
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### 3. 认证差异
|
|
284
|
+
|
|
285
|
+
**Arabica 认证**:
|
|
286
|
+
- 会员注册/登录
|
|
287
|
+
- Token 关联会员ID
|
|
288
|
+
- 权限:管理自己的企业和订阅
|
|
289
|
+
|
|
290
|
+
**Liberica 认证**:
|
|
291
|
+
- 租户员工登录
|
|
292
|
+
- Token 关联租户ID + 用户ID
|
|
293
|
+
- 权限:操作租户企业的生产数据
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
**最后更新**: 2025-04-12
|