@builder6/sharepoint 3.2.3 → 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.
Files changed (2) hide show
  1. package/README.md +229 -4
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,5 +1,230 @@
1
- # Builder6 Sharepoint Module
1
+ # Builder6 SharePoint Module
2
2
 
3
- ```shell
4
- B6_SHAREPOINT_OFFICE_CONVERT_URL=
5
- ```
3
+ Builder6 SharePoint 模块为 Builder6 平台提供文档处理和 Microsoft 365 集成能力,支持 Word 文档与 XML 互转、AI 文档审阅以及 SharePoint Online/OneDrive 集成。
4
+
5
+ ## 功能特性
6
+
7
+ ### SharePoint 服务
8
+
9
+ - **Word ↔ XML 转换**: 将 Word 文档转换为 XML 格式,支持双向转换
10
+ - **AI 文档审阅**: 在 XML 文档中插入 AI 生成的审阅意见
11
+ - **评论管理**: 支持在指定行范围添加嵌入式评论
12
+ - **临时文件管理**: 自动管理文档转换过程中的临时文件
13
+ - **文件存储集成**: 与 Builder6 文件存储系统无缝集成
14
+
15
+ ### Microsoft 365 集成
16
+
17
+ - **OAuth 2.0 认证**: 使用客户端凭据流进行 Microsoft Graph API 认证
18
+ - **SharePoint 站点管理**: 列出和访问 SharePoint 站点
19
+ - **驱动器和文档访问**: 访问 OneDrive 和 SharePoint 文档库
20
+ - **文件下载/上传**: 从 SharePoint 下载文件或上传文件到 Microsoft 365
21
+ - **租户配置**: 支持多租户 Microsoft 365 配置
22
+
23
+ ## 安装
24
+
25
+ ```bash
26
+ npm install @builder6/sharepoint
27
+ ```
28
+
29
+
30
+
31
+ ```bash
32
+ yarn add @builder6/sharepoint
33
+ ```
34
+
35
+ ## 环境变量
36
+
37
+ ### SharePoint 配置
38
+
39
+ ```bash
40
+ # Office 文档转换服务 URL
41
+ B6_SHAREPOINT_OFFICE_CONVERT_URL=https://your-convert-service.com
42
+ ```
43
+
44
+ ### Microsoft 365 配置
45
+
46
+ ```bash
47
+ # Microsoft 365 租户 ID
48
+ B6_MICROSOFT365_TENANT_ID=your-tenant-id
49
+
50
+ # Microsoft 365 客户端 ID
51
+ B6_MICROSOFT365_CLIENT_ID=your-client-id
52
+
53
+ # Microsoft 365 客户端密钥
54
+ B6_MICROSOFT365_CLIENT_SECRET=your-client-secret
55
+
56
+ # Microsoft 365 站点 URL
57
+ B6_MICROSOFT365_SITE_URL=https://yourtenant.sharepoint.com/sites/yoursite
58
+ ```
59
+
60
+ ## 主要 API
61
+
62
+ ### SharePoint 控制器 (`/api/v6/sharepoint`)
63
+
64
+ 文档转换和审阅相关的 API:
65
+
66
+ - **POST `/api/v6/sharepoint/word2xml`**: Word 文档转换为 XML
67
+ - **POST `/api/v6/sharepoint/xml2word`**: XML 转换为 Word 文档
68
+ - **POST `/api/v6/sharepoint/xmlWriteComments`**: 在 XML 中插入审阅意见
69
+
70
+ ### Microsoft 365 控制器 (`/api/v6/microsoft365`)
71
+
72
+ Microsoft 365 集成 API:
73
+
74
+ - **GET `/api/v6/microsoft365/sites`**: 列出 SharePoint 站点
75
+ - **GET `/api/v6/microsoft365/drives`**: 获取驱动器列表
76
+ - **GET `/api/v6/microsoft365/files`**: 列出文档库文件
77
+ - **GET `/api/v6/microsoft365/download/:fileId`**: 下载文件
78
+ - **POST `/api/v6/microsoft365/upload`**: 上传文件到 Microsoft 365
79
+
80
+ ## 使用示例
81
+
82
+ ### 在 NestJS 应用中集成
83
+
84
+ ```typescript
85
+ import { Module } from '@nestjs/common';
86
+ import { SharepointModule } from '@builder6/sharepoint';
87
+
88
+ @Module({
89
+ imports: [SharepointModule],
90
+ })
91
+ export class AppModule {}
92
+ ```
93
+
94
+ ### Word 转 XML
95
+
96
+ ```typescript
97
+ import { SharepointService } from '@builder6/sharepoint';
98
+
99
+ constructor(private sharepointService: SharepointService) {}
100
+
101
+ async convertWordToXml(fileId: string) {
102
+ const xmlFileId = await this.sharepointService.word2Xml(fileId);
103
+ return xmlFileId;
104
+ }
105
+ ```
106
+
107
+ ### 在 XML 中插入 AI 审阅意见
108
+
109
+ ```typescript
110
+ async addAIComments(xmlFileId: string) {
111
+ const comments = [
112
+ {
113
+ startLine: 10,
114
+ endLine: 15,
115
+ comment: 'AI 建议:这段内容可以更简洁'
116
+ }
117
+ ];
118
+
119
+ const updatedFileId = await this.sharepointService.xmlWriteComments(
120
+ xmlFileId,
121
+ comments
122
+ );
123
+ return updatedFileId;
124
+ }
125
+ ```
126
+
127
+ ### XML 转回 Word
128
+
129
+ ```typescript
130
+ async convertXmlToWord(xmlFileId: string) {
131
+ const wordFileId = await this.sharepointService.xml2Word(xmlFileId);
132
+ return wordFileId;
133
+ }
134
+ ```
135
+
136
+ ### 访问 Microsoft 365 文件
137
+
138
+ ```bash
139
+ # 列出 SharePoint 站点
140
+ curl -X GET http://localhost:5100/api/v6/microsoft365/sites \
141
+ -H "Authorization: Bearer YOUR_TOKEN"
142
+
143
+ # 下载文件
144
+ curl -X GET http://localhost:5100/api/v6/microsoft365/download/FILE_ID \
145
+ -H "Authorization: Bearer YOUR_TOKEN" \
146
+ --output document.docx
147
+ ```
148
+
149
+ ## 工作流示例
150
+
151
+ ### AI 文档审阅完整流程
152
+
153
+ 1. **Word 转 XML**: 将 Word 文档转换为 XML 格式
154
+ 2. **AI 分析**: AI 系统分析文档内容
155
+ 3. **插入评论**: 在 XML 中插入 AI 生成的审阅意见
156
+ 4. **XML 转 Word**: 将带有评论的 XML 转回 Word 文档
157
+ 5. **分发审阅**: 用户可在 Word 中查看所有 AI 评论
158
+
159
+ ```typescript
160
+ async aiDocumentReview(wordFileId: string) {
161
+ // 1. Word 转 XML
162
+ const xmlFileId = await this.sharepointService.word2Xml(wordFileId);
163
+
164
+ // 2. AI 分析并生成评论
165
+ const aiComments = await this.analyzeDocument(xmlFileId);
166
+
167
+ // 3. 插入 AI 评论
168
+ const commentedXmlId = await this.sharepointService.xmlWriteComments(
169
+ xmlFileId,
170
+ aiComments
171
+ );
172
+
173
+ // 4. 转回 Word
174
+ const reviewedWordId = await this.sharepointService.xml2Word(commentedXmlId);
175
+
176
+ return reviewedWordId;
177
+ }
178
+ ```
179
+
180
+ ## 权限控制
181
+
182
+ 所有 API 端点都受 `AdminGuard` 保护,只有管理员用户才能访问这些接口。
183
+
184
+ ## 依赖项
185
+
186
+ ### 主要依赖
187
+
188
+ - `form-data`: ^4.0.5 - 多部分表单数据处理
189
+ - `line-reader`: ^0.4.0 - 逐行读取文件
190
+ - `nodemailer`: ^7.0.11 - 邮件发送(用于通知)
191
+
192
+ ### Peer Dependencies
193
+
194
+ - `@builder6/core`: ^3.0.10 - 核心功能模块
195
+ - `@builder6/files`: ^3.0.10 - 文件管理模块
196
+ - `@builder6/moleculer`: ^3.0.10 - 微服务框架
197
+ - `@nestjs/common`: ^11.0.0 - NestJS 核心
198
+ - `@nestjs/core`: ^11.0.0 - NestJS 核心
199
+ - `@nestjs/swagger`: ^11.0.7 - API 文档
200
+
201
+ ## 开发
202
+
203
+ ### 构建
204
+
205
+ ```bash
206
+ npm run build
207
+ ```
208
+
209
+ ### 监听模式
210
+
211
+ ```bash
212
+ npm run build:watch
213
+ ```
214
+
215
+ ### 格式化代码
216
+
217
+ ```bash
218
+ npm run format
219
+ ```
220
+
221
+ ## 使用场景
222
+
223
+ - **文档协作**: 支持团队协作和文档审阅工作流
224
+ - **AI 辅助写作**: 集成 AI 进行文档内容分析和建议
225
+ - **SharePoint 集成**: 连接企业 SharePoint 环境进行文档管理
226
+ - **文档转换**: 在不同格式之间转换文档以支持不同的处理需求
227
+
228
+ ## License
229
+
230
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder6/sharepoint",
3
- "version": "3.2.3",
3
+ "version": "3.2.12",
4
4
  "main": "dist/plugin.module.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -27,5 +27,5 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "544e8b41e82e41a3a7534cd30219c00d60285c63"
30
+ "gitHead": "6d6e13fed8d4b3c6de14f84dcb6287c5661ea6f6"
31
31
  }