@sinoia/hubdoc-tools 1.3.4 → 1.3.5

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 (43) hide show
  1. package/dist/plugins/alfresco/index.d.ts +26 -0
  2. package/dist/plugins/alfresco/index.d.ts.map +1 -0
  3. package/dist/plugins/alfresco/index.js +405 -0
  4. package/dist/plugins/alfresco/index.js.map +1 -0
  5. package/dist/plugins/aws-s3/index.d.ts +23 -0
  6. package/dist/plugins/aws-s3/index.d.ts.map +1 -0
  7. package/dist/plugins/aws-s3/index.js +383 -0
  8. package/dist/plugins/aws-s3/index.js.map +1 -0
  9. package/dist/plugins/azure-blob/index.d.ts +23 -0
  10. package/dist/plugins/azure-blob/index.d.ts.map +1 -0
  11. package/dist/plugins/azure-blob/index.js +340 -0
  12. package/dist/plugins/azure-blob/index.js.map +1 -0
  13. package/dist/plugins/box/index.d.ts +26 -0
  14. package/dist/plugins/box/index.d.ts.map +1 -0
  15. package/dist/plugins/box/index.js +387 -0
  16. package/dist/plugins/box/index.js.map +1 -0
  17. package/dist/plugins/dropbox/index.d.ts +27 -0
  18. package/dist/plugins/dropbox/index.d.ts.map +1 -0
  19. package/dist/plugins/dropbox/index.js +375 -0
  20. package/dist/plugins/dropbox/index.js.map +1 -0
  21. package/dist/plugins/googledrive/index.d.ts +27 -0
  22. package/dist/plugins/googledrive/index.d.ts.map +1 -0
  23. package/dist/plugins/googledrive/index.js +383 -0
  24. package/dist/plugins/googledrive/index.js.map +1 -0
  25. package/dist/plugins/nuxeo/index.d.ts +24 -0
  26. package/dist/plugins/nuxeo/index.d.ts.map +1 -0
  27. package/dist/plugins/nuxeo/index.js +405 -0
  28. package/dist/plugins/nuxeo/index.js.map +1 -0
  29. package/dist/plugins/onedrive/index.d.ts +25 -0
  30. package/dist/plugins/onedrive/index.d.ts.map +1 -0
  31. package/dist/plugins/onedrive/index.js +362 -0
  32. package/dist/plugins/onedrive/index.js.map +1 -0
  33. package/dist/plugins/opentext/index.d.ts +26 -0
  34. package/dist/plugins/opentext/index.d.ts.map +1 -0
  35. package/dist/plugins/opentext/index.js +440 -0
  36. package/dist/plugins/opentext/index.js.map +1 -0
  37. package/dist/plugins/sharepoint/index.d.ts +27 -0
  38. package/dist/plugins/sharepoint/index.d.ts.map +1 -0
  39. package/dist/plugins/sharepoint/index.js +397 -0
  40. package/dist/plugins/sharepoint/index.js.map +1 -0
  41. package/package.json +6 -1
  42. package/plugins/aws-s3/index.ts +2 -2
  43. package/plugins/sharepoint/index.ts +1 -1
@@ -0,0 +1,375 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
+ class DropboxPlugin {
10
+ constructor() {
11
+ this.name = 'dropbox';
12
+ this.version = '1.0.0';
13
+ this.description = 'Dropbox document source';
14
+ this.supportedOperations = ['import', 'export', 'both'];
15
+ this.apiUrl = 'https://api.dropboxapi.com/2';
16
+ this.contentUrl = 'https://content.dropboxapi.com/2';
17
+ }
18
+ async testConnection(config) {
19
+ try {
20
+ const client = this.createApiClient(config);
21
+ const response = await client.post('/users/get_current_account');
22
+ return response.status === 200;
23
+ }
24
+ catch (error) {
25
+ console.error(`Dropbox connection test failed: ${error.message}`);
26
+ return false;
27
+ }
28
+ }
29
+ async scan(config, options) {
30
+ this.config = config;
31
+ this.apiClient = this.createApiClient(this.config);
32
+ const sources = [];
33
+ const errors = [];
34
+ let totalSize = 0;
35
+ try {
36
+ const rootPath = this.config.rootPath || '';
37
+ const items = await this.scanFolder(rootPath, options);
38
+ for (const item of items) {
39
+ if (item['.tag'] === 'file') {
40
+ const source = {
41
+ id: item.path_display,
42
+ name: item.name,
43
+ path: this.getRelativePath(item.path_display, rootPath),
44
+ size: item.size || 0,
45
+ mimeType: this.getMimeType(item.name),
46
+ lastModified: new Date(item.server_modified || item.client_modified || Date.now()),
47
+ metadata: {
48
+ dropboxId: item.id,
49
+ pathLower: item.path_lower,
50
+ contentHash: item.content_hash
51
+ }
52
+ };
53
+ // Apply filters
54
+ if (this.shouldIncludeSource(source, options)) {
55
+ sources.push(source);
56
+ totalSize += source.size;
57
+ }
58
+ }
59
+ }
60
+ return {
61
+ sources,
62
+ totalCount: sources.length,
63
+ totalSize,
64
+ errors
65
+ };
66
+ }
67
+ catch (error) {
68
+ return {
69
+ sources: [],
70
+ totalCount: 0,
71
+ totalSize: 0,
72
+ errors: [`Dropbox scan failed: ${error.message}`]
73
+ };
74
+ }
75
+ }
76
+ async scanFolder(folderPath, options) {
77
+ if (!this.apiClient)
78
+ throw new Error('API client not initialized');
79
+ const allItems = [];
80
+ let cursor;
81
+ try {
82
+ // Initial request
83
+ const response = await this.apiClient.post('/files/list_folder', {
84
+ path: folderPath || '',
85
+ recursive: true,
86
+ limit: 2000,
87
+ include_media_info: false,
88
+ include_deleted: false,
89
+ include_has_explicit_shared_members: false
90
+ });
91
+ allItems.push(...response.data.entries);
92
+ // Handle pagination
93
+ while (response.data.has_more) {
94
+ cursor = response.data.cursor;
95
+ const continueResponse = await this.apiClient.post('/files/list_folder/continue', {
96
+ cursor
97
+ });
98
+ allItems.push(...continueResponse.data.entries);
99
+ if (!continueResponse.data.has_more)
100
+ break;
101
+ response.data = continueResponse.data;
102
+ }
103
+ return allItems;
104
+ }
105
+ catch (error) {
106
+ if (error.response?.data?.error?.['.tag'] === 'path_not_found') {
107
+ console.warn(`Warning: Folder not found: ${folderPath}`);
108
+ return [];
109
+ }
110
+ throw error;
111
+ }
112
+ }
113
+ async import(config, sources, targetDir, options) {
114
+ this.config = config;
115
+ this.apiClient = this.createApiClient(this.config);
116
+ const results = [];
117
+ const batchSize = options?.batchSize || 10;
118
+ // Process in batches
119
+ for (let i = 0; i < sources.length; i += batchSize) {
120
+ const batch = sources.slice(i, i + batchSize);
121
+ for (const source of batch) {
122
+ const result = await this.importSingle(source, targetDir);
123
+ results.push(result);
124
+ // Small delay to respect rate limits
125
+ await this.sleep(100);
126
+ }
127
+ }
128
+ return results;
129
+ }
130
+ async importSingle(source, targetDir) {
131
+ try {
132
+ if (!this.apiClient)
133
+ throw new Error('API client not initialized');
134
+ const targetPath = path_1.default.join(targetDir, source.path);
135
+ const targetDirectory = path_1.default.dirname(targetPath);
136
+ await fs_extra_1.default.ensureDir(targetDirectory);
137
+ // Download file from Dropbox
138
+ const downloadClient = axios_1.default.create({
139
+ baseURL: this.contentUrl,
140
+ headers: {
141
+ 'Authorization': `Bearer ${this.config.accessToken}`,
142
+ 'Dropbox-API-Arg': JSON.stringify({
143
+ path: source.id
144
+ })
145
+ },
146
+ responseType: 'stream'
147
+ });
148
+ const response = await downloadClient.post('/files/download');
149
+ const writer = fs_extra_1.default.createWriteStream(targetPath);
150
+ response.data.pipe(writer);
151
+ return new Promise((resolve) => {
152
+ writer.on('finish', () => {
153
+ resolve({
154
+ success: true,
155
+ source,
156
+ localPath: targetPath,
157
+ bytesTransferred: source.size
158
+ });
159
+ });
160
+ writer.on('error', (error) => {
161
+ resolve({
162
+ success: false,
163
+ source,
164
+ error: error.message
165
+ });
166
+ });
167
+ });
168
+ }
169
+ catch (error) {
170
+ return {
171
+ success: false,
172
+ source,
173
+ error: error.message
174
+ };
175
+ }
176
+ }
177
+ async export(config, localSources, options) {
178
+ this.config = config;
179
+ this.apiClient = this.createApiClient(this.config);
180
+ const results = [];
181
+ for (const source of localSources) {
182
+ try {
183
+ const targetPath = options?.preserveStructure
184
+ ? `${this.config.rootPath || ''}/${options.targetPath}/${source.path}`
185
+ : `${this.config.rootPath || ''}/${options?.targetPath || ''}/${source.name}`;
186
+ // Read file content
187
+ const fileContent = await fs_extra_1.default.readFile(source.id);
188
+ const fileSize = fileContent.length;
189
+ // Upload file to Dropbox
190
+ const uploadClient = axios_1.default.create({
191
+ baseURL: this.contentUrl,
192
+ headers: {
193
+ 'Authorization': `Bearer ${this.config.accessToken}`,
194
+ 'Content-Type': 'application/octet-stream',
195
+ 'Dropbox-API-Arg': JSON.stringify({
196
+ path: targetPath,
197
+ mode: options?.overwrite ? 'overwrite' : 'add',
198
+ autorename: !options?.overwrite,
199
+ mute: false
200
+ })
201
+ }
202
+ });
203
+ // Use upload sessions for large files (>150MB)
204
+ if (fileSize > 150 * 1024 * 1024) {
205
+ await this.uploadLargeFile(uploadClient, fileContent, targetPath);
206
+ }
207
+ else {
208
+ await uploadClient.post('/files/upload', fileContent);
209
+ }
210
+ results.push({
211
+ success: true,
212
+ targetPath,
213
+ source,
214
+ bytesTransferred: fileSize
215
+ });
216
+ }
217
+ catch (error) {
218
+ results.push({
219
+ success: false,
220
+ targetPath: options?.targetPath || '',
221
+ source,
222
+ error: error.message
223
+ });
224
+ }
225
+ }
226
+ return results;
227
+ }
228
+ async uploadLargeFile(uploadClient, content, targetPath) {
229
+ const chunkSize = 4 * 1024 * 1024; // 4MB chunks
230
+ let offset = 0;
231
+ let sessionId;
232
+ while (offset < content.length) {
233
+ const chunk = content.slice(offset, offset + chunkSize);
234
+ const isLastChunk = offset + chunkSize >= content.length;
235
+ if (!sessionId) {
236
+ // Start upload session
237
+ const startResponse = await uploadClient.post('/files/upload_session/start', chunk, {
238
+ headers: {
239
+ 'Dropbox-API-Arg': JSON.stringify({ close: false })
240
+ }
241
+ });
242
+ sessionId = startResponse.data.session_id;
243
+ }
244
+ else if (!isLastChunk) {
245
+ // Continue upload session
246
+ await uploadClient.post('/files/upload_session/append_v2', chunk, {
247
+ headers: {
248
+ 'Dropbox-API-Arg': JSON.stringify({
249
+ cursor: { session_id: sessionId, offset },
250
+ close: false
251
+ })
252
+ }
253
+ });
254
+ }
255
+ else {
256
+ // Finish upload session
257
+ await uploadClient.post('/files/upload_session/finish', chunk, {
258
+ headers: {
259
+ 'Dropbox-API-Arg': JSON.stringify({
260
+ cursor: { session_id: sessionId, offset },
261
+ commit: {
262
+ path: targetPath,
263
+ mode: 'add',
264
+ autorename: true
265
+ }
266
+ })
267
+ }
268
+ });
269
+ }
270
+ offset += chunkSize;
271
+ }
272
+ }
273
+ getConfigSchema() {
274
+ return {
275
+ type: 'object',
276
+ properties: {
277
+ accessToken: {
278
+ type: 'string',
279
+ description: 'Dropbox Access Token',
280
+ required: true
281
+ },
282
+ appKey: {
283
+ type: 'string',
284
+ description: 'Dropbox App Key (optional)',
285
+ required: false
286
+ },
287
+ appSecret: {
288
+ type: 'string',
289
+ description: 'Dropbox App Secret (optional)',
290
+ required: false
291
+ },
292
+ rootPath: {
293
+ type: 'string',
294
+ description: 'Root path to scan (e.g., /Documents)',
295
+ default: ''
296
+ }
297
+ },
298
+ required: ['accessToken']
299
+ };
300
+ }
301
+ async initialize(config) {
302
+ this.config = config;
303
+ if (!this.config.accessToken) {
304
+ throw new Error('Dropbox access token is required');
305
+ }
306
+ this.apiClient = this.createApiClient(this.config);
307
+ }
308
+ async destroy() {
309
+ this.config = undefined;
310
+ this.apiClient = undefined;
311
+ }
312
+ createApiClient(config) {
313
+ return axios_1.default.create({
314
+ baseURL: this.apiUrl,
315
+ headers: {
316
+ 'Authorization': `Bearer ${config.accessToken}`,
317
+ 'Content-Type': 'application/json'
318
+ },
319
+ timeout: 30000
320
+ });
321
+ }
322
+ getRelativePath(fullPath, rootPath) {
323
+ if (!rootPath)
324
+ return fullPath.startsWith('/') ? fullPath.substring(1) : fullPath;
325
+ const relativePath = fullPath.startsWith(rootPath)
326
+ ? fullPath.substring(rootPath.length)
327
+ : fullPath;
328
+ return relativePath.startsWith('/') ? relativePath.substring(1) : relativePath;
329
+ }
330
+ getMimeType(fileName) {
331
+ const ext = path_1.default.extname(fileName).toLowerCase();
332
+ const mimeTypes = {
333
+ '.pdf': 'application/pdf',
334
+ '.doc': 'application/msword',
335
+ '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
336
+ '.xls': 'application/vnd.ms-excel',
337
+ '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
338
+ '.ppt': 'application/vnd.ms-powerpoint',
339
+ '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
340
+ '.txt': 'text/plain',
341
+ '.csv': 'text/csv',
342
+ '.json': 'application/json',
343
+ '.jpg': 'image/jpeg',
344
+ '.jpeg': 'image/jpeg',
345
+ '.png': 'image/png',
346
+ '.gif': 'image/gif',
347
+ '.zip': 'application/zip'
348
+ };
349
+ return mimeTypes[ext] || 'application/octet-stream';
350
+ }
351
+ shouldIncludeSource(source, options) {
352
+ // Apply size filter
353
+ if (options?.filters?.maxSize && source.size > options.filters.maxSize) {
354
+ return false;
355
+ }
356
+ // Apply date range filter
357
+ if (options?.filters?.dateRange) {
358
+ const { from, to } = options.filters.dateRange;
359
+ if (from && source.lastModified < from)
360
+ return false;
361
+ if (to && source.lastModified > to)
362
+ return false;
363
+ }
364
+ // Apply MIME type filter
365
+ if (options?.filters?.mimeTypes && !options.filters.mimeTypes.includes(source.mimeType)) {
366
+ return false;
367
+ }
368
+ return true;
369
+ }
370
+ sleep(ms) {
371
+ return new Promise(resolve => setTimeout(resolve, ms));
372
+ }
373
+ }
374
+ exports.default = DropboxPlugin;
375
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../plugins/dropbox/index.ts"],"names":[],"mappings":";;;;;AAAA,kDAA6C;AAC7C,wDAA0B;AAC1B,gDAAwB;AA+BxB,MAAqB,aAAa;IAAlC;QACW,SAAI,GAAG,SAAS,CAAC;QACjB,YAAO,GAAG,OAAO,CAAC;QAClB,gBAAW,GAAG,yBAAyB,CAAC;QACxC,wBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;QAIpD,WAAM,GAAG,8BAA8B,CAAC;QACxC,eAAU,GAAG,kCAAkC,CAAC;IAwZnE,CAAC;IAtZC,KAAK,CAAC,cAAc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AAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAjaD,gCAiaC"}
@@ -0,0 +1,27 @@
1
+ import { DocumentSourcePlugin, DocumentSource, PluginConfig, ScanResult, PluginImportOptions, PluginExportOptions, ImportResult, ExportResult } from '../../src/types/plugins';
2
+ export default class GoogleDrivePlugin implements DocumentSourcePlugin {
3
+ readonly name = "googledrive";
4
+ readonly version = "1.0.0";
5
+ readonly description = "Google Drive document source";
6
+ readonly supportedOperations: readonly ["import", "export", "both"];
7
+ private config?;
8
+ private drive?;
9
+ private auth?;
10
+ testConnection(config: PluginConfig): Promise<boolean>;
11
+ scan(config: PluginConfig, options?: PluginImportOptions): Promise<ScanResult>;
12
+ private scanFolder;
13
+ import(config: PluginConfig, sources: DocumentSource[], targetDir: string, options?: PluginImportOptions): Promise<ImportResult[]>;
14
+ private importSingle;
15
+ export?(config: PluginConfig, localSources: DocumentSource[], options?: PluginExportOptions): Promise<ExportResult[]>;
16
+ private createFolderStructure;
17
+ getConfigSchema(): Record<string, any>;
18
+ initialize(config: PluginConfig): Promise<void>;
19
+ destroy(): Promise<void>;
20
+ private createAuth;
21
+ private isGoogleWorkspaceDoc;
22
+ private getExportMimeType;
23
+ private getExportExtension;
24
+ private shouldIncludeSource;
25
+ private sleep;
26
+ }
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugins/googledrive/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACb,MAAM,yBAAyB,CAAC;AAWjC,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,oBAAoB;IACpE,QAAQ,CAAC,IAAI,iBAAiB;IAC9B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