@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,340 @@
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 storage_blob_1 = require("@azure/storage-blob");
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
+ class AzureBlobPlugin {
10
+ constructor() {
11
+ this.name = 'azure-blob';
12
+ this.version = '1.0.0';
13
+ this.description = 'Azure Blob Storage document source';
14
+ this.supportedOperations = ['import', 'export', 'both'];
15
+ }
16
+ async testConnection(config) {
17
+ try {
18
+ const blobConfig = config;
19
+ const client = this.createBlobServiceClient(blobConfig);
20
+ const containerClient = client.getContainerClient(blobConfig.containerName);
21
+ await containerClient.getProperties();
22
+ return true;
23
+ }
24
+ catch (error) {
25
+ console.error(`Azure Blob connection test failed: ${error.message}`);
26
+ return false;
27
+ }
28
+ }
29
+ async scan(config, options) {
30
+ this.config = config;
31
+ this.blobServiceClient = this.createBlobServiceClient(this.config);
32
+ const sources = [];
33
+ const errors = [];
34
+ let totalSize = 0;
35
+ try {
36
+ const limit = this.config.limit || options?.limit;
37
+ console.log(`🔍 Scanning Azure Blob container: ${this.config.containerName}${limit ? ` (limit: ${limit})` : ''}...`);
38
+ const containerClient = this.blobServiceClient.getContainerClient(this.config.containerName);
39
+ const blobs = await this.listAllBlobs(containerClient, this.config.prefix);
40
+ let processedCount = 0;
41
+ for (const blob of blobs) {
42
+ const source = {
43
+ id: blob.name,
44
+ // Normalize filename to NFC to handle accented characters consistently across platforms
45
+ name: path_1.default.basename(blob.name).normalize('NFC'),
46
+ path: blob.name,
47
+ size: blob.size,
48
+ mimeType: blob.contentType || this.getMimeType(blob.name),
49
+ lastModified: blob.lastModified,
50
+ metadata: {
51
+ blobName: blob.name,
52
+ etag: blob.etag,
53
+ azureMetadata: blob.metadata,
54
+ tags: blob.tags
55
+ }
56
+ };
57
+ // Apply filters
58
+ if (this.shouldIncludeSource(source, options)) {
59
+ sources.push(source);
60
+ totalSize += source.size;
61
+ processedCount++;
62
+ // Check limit
63
+ if (limit && processedCount >= limit) {
64
+ console.log(`📏 Reached limit of ${limit} files`);
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ return {
70
+ sources,
71
+ totalCount: sources.length,
72
+ totalSize,
73
+ errors
74
+ };
75
+ }
76
+ catch (error) {
77
+ return {
78
+ sources: [],
79
+ totalCount: 0,
80
+ totalSize: 0,
81
+ errors: [`Azure Blob scan failed: ${error.message}`]
82
+ };
83
+ }
84
+ }
85
+ async import(config, sources, targetDir, options) {
86
+ this.config = config;
87
+ this.blobServiceClient = this.createBlobServiceClient(this.config);
88
+ const results = [];
89
+ const batchSize = options?.batchSize || 5;
90
+ // Process in batches to manage connections
91
+ for (let i = 0; i < sources.length; i += batchSize) {
92
+ const batch = sources.slice(i, i + batchSize);
93
+ for (const source of batch) {
94
+ const result = await this.importSingle(source, targetDir);
95
+ results.push(result);
96
+ // Small delay to respect rate limits
97
+ await this.sleep(100);
98
+ }
99
+ }
100
+ return results;
101
+ }
102
+ async importSingle(source, targetDir) {
103
+ try {
104
+ if (!this.blobServiceClient || !this.config)
105
+ throw new Error('Blob service client not initialized');
106
+ const targetPath = path_1.default.join(targetDir, source.path);
107
+ const targetDirectory = path_1.default.dirname(targetPath);
108
+ await fs_extra_1.default.ensureDir(targetDirectory);
109
+ const containerClient = this.blobServiceClient.getContainerClient(this.config.containerName);
110
+ const blobClient = containerClient.getBlobClient(source.id);
111
+ // Download blob to file
112
+ await blobClient.downloadToFile(targetPath);
113
+ return {
114
+ success: true,
115
+ source,
116
+ localPath: targetPath,
117
+ bytesTransferred: source.size
118
+ };
119
+ }
120
+ catch (error) {
121
+ return {
122
+ success: false,
123
+ source,
124
+ error: error.message
125
+ };
126
+ }
127
+ }
128
+ async export(config, localSources, options) {
129
+ this.config = config;
130
+ this.blobServiceClient = this.createBlobServiceClient(this.config);
131
+ const results = [];
132
+ for (const source of localSources) {
133
+ try {
134
+ if (!this.blobServiceClient || !this.config)
135
+ throw new Error('Blob service client not initialized');
136
+ // Determine blob name
137
+ let blobName;
138
+ if (options?.preserveStructure) {
139
+ blobName = this.config.prefix ? `${this.config.prefix}/${source.path}` : source.path;
140
+ }
141
+ else {
142
+ blobName = this.config.prefix ? `${this.config.prefix}/${source.name}` : source.name;
143
+ }
144
+ const containerClient = this.blobServiceClient.getContainerClient(this.config.containerName);
145
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
146
+ // Upload file to Azure Blob Storage
147
+ const fileContent = await fs_extra_1.default.readFile(source.id);
148
+ await blockBlobClient.upload(fileContent, fileContent.length, {
149
+ blobHTTPHeaders: {
150
+ blobContentType: source.mimeType
151
+ },
152
+ metadata: {
153
+ originalPath: source.path,
154
+ originalName: source.name,
155
+ uploadedBy: 'hubdoc-tools',
156
+ uploadDate: new Date().toISOString()
157
+ }
158
+ });
159
+ const targetPath = options?.preserveStructure ? source.path : source.name;
160
+ results.push({
161
+ success: true,
162
+ targetPath,
163
+ source,
164
+ bytesTransferred: source.size
165
+ });
166
+ }
167
+ catch (error) {
168
+ results.push({
169
+ success: false,
170
+ targetPath: options?.targetPath || '',
171
+ source,
172
+ error: error.message
173
+ });
174
+ }
175
+ }
176
+ return results;
177
+ }
178
+ async listAllBlobs(containerClient, prefix) {
179
+ const allBlobs = [];
180
+ try {
181
+ const listBlobsOptions = {
182
+ includeMetadata: true,
183
+ includeTags: true
184
+ };
185
+ if (prefix) {
186
+ listBlobsOptions.prefix = prefix;
187
+ }
188
+ for await (const blob of containerClient.listBlobsFlat(listBlobsOptions)) {
189
+ // Skip directories (virtual folders)
190
+ if (!blob.name.endsWith('/')) {
191
+ allBlobs.push({
192
+ name: blob.name,
193
+ size: blob.properties.contentLength || 0,
194
+ lastModified: blob.properties.lastModified || new Date(),
195
+ etag: blob.properties.etag || '',
196
+ contentType: blob.properties.contentType,
197
+ metadata: blob.metadata,
198
+ tags: blob.tags
199
+ });
200
+ }
201
+ }
202
+ return allBlobs;
203
+ }
204
+ catch (error) {
205
+ throw new Error(`Failed to list Azure blobs: ${error.message}`);
206
+ }
207
+ }
208
+ getConfigSchema() {
209
+ return {
210
+ type: 'object',
211
+ properties: {
212
+ accountName: {
213
+ type: 'string',
214
+ description: 'Azure Storage Account name',
215
+ required: true
216
+ },
217
+ accountKey: {
218
+ type: 'string',
219
+ description: 'Azure Storage Account key (if using key authentication)',
220
+ required: false
221
+ },
222
+ sasToken: {
223
+ type: 'string',
224
+ description: 'Azure Storage SAS token (alternative to account key)',
225
+ required: false
226
+ },
227
+ connectionString: {
228
+ type: 'string',
229
+ description: 'Azure Storage connection string (alternative to account name/key)',
230
+ required: false
231
+ },
232
+ containerName: {
233
+ type: 'string',
234
+ description: 'Azure Blob Storage container name',
235
+ required: true
236
+ },
237
+ prefix: {
238
+ type: 'string',
239
+ description: 'Blob name prefix to filter objects (optional)',
240
+ required: false
241
+ },
242
+ limit: {
243
+ type: 'number',
244
+ description: 'Maximum number of documents to scan (useful for testing)',
245
+ required: false
246
+ }
247
+ },
248
+ required: ['accountName', 'containerName'],
249
+ oneOf: [
250
+ { required: ['accountName', 'accountKey', 'containerName'] },
251
+ { required: ['accountName', 'sasToken', 'containerName'] },
252
+ { required: ['connectionString', 'containerName'] }
253
+ ]
254
+ };
255
+ }
256
+ async initialize(config) {
257
+ this.config = config;
258
+ if (!this.config.containerName) {
259
+ throw new Error('Azure Blob container name is required');
260
+ }
261
+ // Validate authentication method
262
+ if (!this.config.connectionString && !this.config.accountName) {
263
+ throw new Error('Either connection string or account name is required');
264
+ }
265
+ if (this.config.accountName && !this.config.accountKey && !this.config.sasToken) {
266
+ throw new Error('When using account name, either account key or SAS token is required');
267
+ }
268
+ this.blobServiceClient = this.createBlobServiceClient(this.config);
269
+ }
270
+ async destroy() {
271
+ this.config = undefined;
272
+ this.blobServiceClient = undefined;
273
+ }
274
+ createBlobServiceClient(config) {
275
+ // Option 1: Connection string (simplest)
276
+ if (config.connectionString) {
277
+ return storage_blob_1.BlobServiceClient.fromConnectionString(config.connectionString);
278
+ }
279
+ // Option 2: Account name + SAS token
280
+ if (config.accountName && config.sasToken) {
281
+ const blobServiceUri = `https://${config.accountName}.blob.core.windows.net`;
282
+ return new storage_blob_1.BlobServiceClient(`${blobServiceUri}?${config.sasToken}`);
283
+ }
284
+ // Option 3: Account name + Account key
285
+ if (config.accountName && config.accountKey) {
286
+ const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(config.accountName, config.accountKey);
287
+ const blobServiceUri = `https://${config.accountName}.blob.core.windows.net`;
288
+ return new storage_blob_1.BlobServiceClient(blobServiceUri, sharedKeyCredential);
289
+ }
290
+ throw new Error('Invalid Azure Blob Storage configuration');
291
+ }
292
+ getMimeType(blobName) {
293
+ const ext = path_1.default.extname(blobName).toLowerCase();
294
+ const mimeTypes = {
295
+ '.pdf': 'application/pdf',
296
+ '.doc': 'application/msword',
297
+ '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
298
+ '.xls': 'application/vnd.ms-excel',
299
+ '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
300
+ '.ppt': 'application/vnd.ms-powerpoint',
301
+ '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
302
+ '.txt': 'text/plain',
303
+ '.csv': 'text/csv',
304
+ '.json': 'application/json',
305
+ '.xml': 'application/xml',
306
+ '.jpg': 'image/jpeg',
307
+ '.jpeg': 'image/jpeg',
308
+ '.png': 'image/png',
309
+ '.gif': 'image/gif',
310
+ '.zip': 'application/zip',
311
+ '.tar': 'application/x-tar',
312
+ '.gz': 'application/gzip'
313
+ };
314
+ return mimeTypes[ext] || 'application/octet-stream';
315
+ }
316
+ shouldIncludeSource(source, options) {
317
+ // Apply size filter
318
+ if (options?.filters?.maxSize && source.size > options.filters.maxSize) {
319
+ return false;
320
+ }
321
+ // Apply date range filter
322
+ if (options?.filters?.dateRange) {
323
+ const { from, to } = options.filters.dateRange;
324
+ if (from && source.lastModified < from)
325
+ return false;
326
+ if (to && source.lastModified > to)
327
+ return false;
328
+ }
329
+ // Apply MIME type filter
330
+ if (options?.filters?.mimeTypes && !options.filters.mimeTypes.includes(source.mimeType)) {
331
+ return false;
332
+ }
333
+ return true;
334
+ }
335
+ sleep(ms) {
336
+ return new Promise(resolve => setTimeout(resolve, ms));
337
+ }
338
+ }
339
+ exports.default = AzureBlobPlugin;
340
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../plugins/azure-blob/index.ts"],"names":[],"mappings":";;;;;AAAA,sDAAwI;AACxI,wDAA0B;AAC1B,gDAAwB;AAgCxB,MAAqB,eAAe;IAApC;QACW,SAAI,GAAG,YAAY,CAAC;QACpB,YAAO,GAAG,OAAO,CAAC;QAClB,gBAAW,GAAG,oCAAoC,CAAC;QACnD,wBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;IA6XvE,CAAC;IAxXC,KAAK,CAAC,cAAc,CAAC,MAAoB;QACvC,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAyB,CAAC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;YAExD,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,aAAa,CAAC,CAA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,YAAY,GAAG,IAAI;gBAAE,OAAO,KAAK,CAAC;YACrD,IAAI,EAAE,IAAI,MAAM,CAAC,YAAY,GAAG,EAAE;gBAAE,OAAO,KAAK,CAAC;QACnD,CAAC;QAED,yBAAyB;QACzB,IAAI,OAAO,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAjYD,kCAiYC"}
@@ -0,0 +1,26 @@
1
+ import { DocumentSourcePlugin, DocumentSource, PluginConfig, ScanResult, PluginImportOptions, PluginExportOptions, ImportResult, ExportResult } from '../../src/types/plugins';
2
+ export default class BoxPlugin implements DocumentSourcePlugin {
3
+ readonly name = "box";
4
+ readonly version = "1.0.0";
5
+ readonly description = "Box cloud storage document source";
6
+ readonly supportedOperations: readonly ["import", "export", "both"];
7
+ private config?;
8
+ private apiClient?;
9
+ private readonly baseUrl;
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 createApiClient;
21
+ private getItemPath;
22
+ private getMimeType;
23
+ private shouldIncludeSource;
24
+ private sleep;
25
+ }
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