@builder6/steedos 3.2.1 → 3.2.12
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/README.md +171 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1,172 @@
|
|
|
1
1
|
# Builder6 Steedos Module
|
|
2
|
+
|
|
3
|
+
Builder6 Steedos 模块为 Builder6 平台提供直接的 MongoDB 数据库访问 API,允许管理员用户通过 RESTful 端点对自定义对象及其记录执行完整的 CRUD 操作。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **直接数据库访问**: 通过 REST API 直接访问 MongoDB 数据库
|
|
8
|
+
- **对象管理**: 对任意自定义对象进行增删改查操作
|
|
9
|
+
- **高级查询**: 支持复杂过滤、排序和分页
|
|
10
|
+
- **DevExtreme 集成**: 支持 DevExtreme 数据网格的高级查询功能
|
|
11
|
+
- **自动元数据**: 自动注入创建者、修改者、时间戳等元数据
|
|
12
|
+
- **权限控制**: 所有操作都需要管理员权限保护
|
|
13
|
+
- **API 文档**: 完整的 Swagger/OpenAPI 文档支持
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @builder6/steedos
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
或
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @builder6/steedos
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 主要 API
|
|
28
|
+
|
|
29
|
+
### MongoDB 控制器 (`/api/v6/direct`)
|
|
30
|
+
|
|
31
|
+
提供标准的 REST API 操作:
|
|
32
|
+
|
|
33
|
+
- **POST `/api/v6/direct/:objectName`**: 创建新记录
|
|
34
|
+
- **GET `/api/v6/direct/:objectName`**: 查询记录列表
|
|
35
|
+
- **GET `/api/v6/direct/:objectName/:recordId`**: 获取单条记录
|
|
36
|
+
- **GET `/api/v6/direct/:objectName/:fieldName/:fieldValue`**: 根据字段值查询
|
|
37
|
+
- **PUT `/api/v6/direct/:objectName/:recordId`**: 更新单条记录
|
|
38
|
+
- **PUT `/api/v6/direct/:objectName/updateMany`**: 批量更新记录
|
|
39
|
+
- **PUT `/api/v6/direct/:objectName/:fieldName/:fieldValue`**: 根据字段值更新
|
|
40
|
+
- **DELETE `/api/v6/direct/:objectName/:recordId`**: 删除单条记录
|
|
41
|
+
- **DELETE `/api/v6/direct/:objectName/deleteMany`**: 批量删除记录
|
|
42
|
+
- **DELETE `/api/v6/direct/:objectName/:fieldName/:fieldValue`**: 根据字段值删除
|
|
43
|
+
|
|
44
|
+
### DevExtreme 控制器 (`/api/v6/devextreme`)
|
|
45
|
+
|
|
46
|
+
支持 DevExtreme 数据网格的高级查询:
|
|
47
|
+
|
|
48
|
+
- **GET `/api/v6/devextreme/:objectName`**: DevExtreme 数据网格查询
|
|
49
|
+
- 支持分组、汇总、复杂过滤等高级功能
|
|
50
|
+
|
|
51
|
+
## 查询参数
|
|
52
|
+
|
|
53
|
+
### 字段选择
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
GET /api/v6/direct/users?fields=name,email,created
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 过滤查询
|
|
60
|
+
|
|
61
|
+
支持 MongoDB 风格的过滤条件:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
GET /api/v6/direct/users?filters=[["status","=","active"],["age",">",18]]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 排序
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
GET /api/v6/direct/users?sort=name,-created
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 分页
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
GET /api/v6/direct/users?top=20&skip=0
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 使用示例
|
|
80
|
+
|
|
81
|
+
### 在 NestJS 应用中集成
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { Module } from '@nestjs/common';
|
|
85
|
+
import { SteedosModule } from '@builder6/steedos';
|
|
86
|
+
|
|
87
|
+
@Module({
|
|
88
|
+
imports: [SteedosModule],
|
|
89
|
+
})
|
|
90
|
+
export class AppModule {}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 创建记录
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
curl -X POST http://localhost:5100/api/v6/direct/contacts \
|
|
97
|
+
-H "Authorization: Bearer YOUR_TOKEN" \
|
|
98
|
+
-H "Content-Type: application/json" \
|
|
99
|
+
-d '{
|
|
100
|
+
"name": "John Doe",
|
|
101
|
+
"email": "john@example.com",
|
|
102
|
+
"phone": "1234567890"
|
|
103
|
+
}'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 查询记录
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
curl -X GET "http://localhost:5100/api/v6/direct/contacts?fields=name,email&filters=[[\"name\",\"contains\",\"John\"]]" \
|
|
110
|
+
-H "Authorization: Bearer YOUR_TOKEN"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 更新记录
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
curl -X PUT http://localhost:5100/api/v6/direct/contacts/RECORD_ID \
|
|
117
|
+
-H "Authorization: Bearer YOUR_TOKEN" \
|
|
118
|
+
-H "Content-Type: application/json" \
|
|
119
|
+
-d '{
|
|
120
|
+
"phone": "0987654321"
|
|
121
|
+
}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 自动元数据注入
|
|
125
|
+
|
|
126
|
+
每个记录操作会自动注入以下元数据:
|
|
127
|
+
|
|
128
|
+
- `created_by`: 创建者用户 ID
|
|
129
|
+
- `modified_by`: 修改者用户 ID
|
|
130
|
+
- `created`: 创建时间
|
|
131
|
+
- `modified`: 修改时间
|
|
132
|
+
- `owner`: 所有者用户 ID
|
|
133
|
+
- `space`: 租户/工作区 ID
|
|
134
|
+
|
|
135
|
+
## 权限控制
|
|
136
|
+
|
|
137
|
+
所有 API 端点都受 `AdminGuard` 保护,只有管理员用户才能访问这些接口。
|
|
138
|
+
|
|
139
|
+
## 依赖项
|
|
140
|
+
|
|
141
|
+
### Peer Dependencies
|
|
142
|
+
|
|
143
|
+
- `@builder6/core`: ^3.0.10 - 核心功能模块
|
|
144
|
+
- `@builder6/files`: ^3.0.10 - 文件管理模块
|
|
145
|
+
- `@builder6/moleculer`: ^3.0.10 - 微服务框架
|
|
146
|
+
- `@nestjs/common`: ^11.0.0 - NestJS 核心
|
|
147
|
+
- `@nestjs/core`: ^11.0.0 - NestJS 核心
|
|
148
|
+
- `@nestjs/swagger`: ^11.0.7 - API 文档
|
|
149
|
+
|
|
150
|
+
## 开发
|
|
151
|
+
|
|
152
|
+
### 构建
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm run build
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 监听模式
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npm run build:watch
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 格式化代码
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm run format
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder6/steedos",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.12",
|
|
4
4
|
"main": "dist/plugin.module.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "6d6e13fed8d4b3c6de14f84dcb6287c5661ea6f6"
|
|
26
26
|
}
|