@sinoia/hubdoc-tools 1.3.8 → 1.4.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/dist/commands/export-v2.d.ts +45 -0
- package/dist/commands/export-v2.d.ts.map +1 -0
- package/dist/commands/export-v2.js +369 -0
- package/dist/commands/export-v2.js.map +1 -0
- package/dist/commands/import-v2.d.ts +32 -0
- package/dist/commands/import-v2.d.ts.map +1 -0
- package/dist/commands/import-v2.js +331 -0
- package/dist/commands/import-v2.js.map +1 -0
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +10 -2
- package/dist/commands/import.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/alfresco/plugin.json +1 -1
- package/dist/plugins/aws-s3/plugin.json +1 -1
- package/dist/plugins/azure-blob/plugin.json +1 -1
- package/dist/plugins/box/plugin.json +1 -1
- package/dist/plugins/core/plugin.json +1 -1
- package/dist/plugins/nuxeo/plugin.json +1 -1
- package/dist/plugins/o365-mail/index.d.ts +26 -0
- package/dist/plugins/o365-mail/index.d.ts.map +1 -0
- package/dist/plugins/o365-mail/index.js +392 -0
- package/dist/plugins/o365-mail/index.js.map +1 -0
- package/dist/plugins/o365-mail/plugin.json +8 -0
- package/dist/plugins/opentext/plugin.json +1 -1
- package/dist/plugins/sharepoint/plugin.json +1 -1
- package/dist/services/hubdoc-api-v2.d.ts +150 -0
- package/dist/services/hubdoc-api-v2.d.ts.map +1 -0
- package/dist/services/hubdoc-api-v2.js +418 -0
- package/dist/services/hubdoc-api-v2.js.map +1 -0
- package/dist/services/hubdoc-client.d.ts +246 -0
- package/dist/services/hubdoc-client.d.ts.map +1 -0
- package/dist/services/hubdoc-client.js +714 -0
- package/dist/services/hubdoc-client.js.map +1 -0
- package/dist/services/hubdoc-export-service.d.ts +90 -0
- package/dist/services/hubdoc-export-service.d.ts.map +1 -0
- package/dist/services/hubdoc-export-service.js +443 -0
- package/dist/services/hubdoc-export-service.js.map +1 -0
- package/dist/services/hubdoc-export-v2.d.ts +77 -0
- package/dist/services/hubdoc-export-v2.d.ts.map +1 -0
- package/dist/services/hubdoc-export-v2.js +329 -0
- package/dist/services/hubdoc-export-v2.js.map +1 -0
- package/dist/services/hubdoc-import-service.d.ts +64 -0
- package/dist/services/hubdoc-import-service.d.ts.map +1 -0
- package/dist/services/hubdoc-import-service.js +374 -0
- package/dist/services/hubdoc-import-service.js.map +1 -0
- package/dist/test/hubdoc-api-test.d.ts +8 -0
- package/dist/test/hubdoc-api-test.d.ts.map +1 -0
- package/dist/test/hubdoc-api-test.js +152 -0
- package/dist/test/hubdoc-api-test.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,418 @@
|
|
|
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
|
+
exports.HubDocApiServiceV2 = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
class HubDocApiServiceV2 {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.client = axios_1.default.create({
|
|
16
|
+
baseURL: config.apiUrl,
|
|
17
|
+
headers: {
|
|
18
|
+
'Authorization': `Bearer ${config.token}`,
|
|
19
|
+
'Accept': 'application/json'
|
|
20
|
+
},
|
|
21
|
+
timeout: 30000
|
|
22
|
+
});
|
|
23
|
+
// Add request interceptor for debugging
|
|
24
|
+
this.client.interceptors.request.use(request => {
|
|
25
|
+
console.log(chalk_1.default.gray(`🔗 ${request.method?.toUpperCase()} ${request.url}`));
|
|
26
|
+
return request;
|
|
27
|
+
});
|
|
28
|
+
// Add response interceptor for error handling
|
|
29
|
+
this.client.interceptors.response.use(response => response, error => {
|
|
30
|
+
if (error.response) {
|
|
31
|
+
console.error(chalk_1.default.red(`❌ API Error ${error.response.status}: ${error.response.data?.message || error.message}`));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.error(chalk_1.default.red(`❌ Network Error: ${error.message}`));
|
|
35
|
+
}
|
|
36
|
+
return Promise.reject(error);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Test API connection
|
|
41
|
+
*/
|
|
42
|
+
async testConnection() {
|
|
43
|
+
try {
|
|
44
|
+
// Try to get current user info to test authentication
|
|
45
|
+
const response = await this.client.get('/auth/me');
|
|
46
|
+
console.log(chalk_1.default.green(`✅ Connected as: ${response.data.email || 'User'}`));
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error(chalk_1.default.red('❌ API connection failed:'), error.message);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Login and get JWT token
|
|
56
|
+
*/
|
|
57
|
+
async login(email, password) {
|
|
58
|
+
try {
|
|
59
|
+
const response = await axios_1.default.post(`${this.config.apiUrl}/auth/login`, {
|
|
60
|
+
email,
|
|
61
|
+
password
|
|
62
|
+
});
|
|
63
|
+
const token = response.data.token;
|
|
64
|
+
if (!token) {
|
|
65
|
+
throw new Error('No token received from login response');
|
|
66
|
+
}
|
|
67
|
+
// Update client headers with new token
|
|
68
|
+
this.client.defaults.headers['Authorization'] = `Bearer ${token}`;
|
|
69
|
+
console.log(chalk_1.default.green('✅ Login successful'));
|
|
70
|
+
return token;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new Error(`Login failed: ${error.response?.data?.message || error.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get all workspaces
|
|
78
|
+
*/
|
|
79
|
+
async getWorkspaces() {
|
|
80
|
+
try {
|
|
81
|
+
const response = await this.client.get('/workspaces');
|
|
82
|
+
return response.data.data || response.data; // Handle pagination
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw new Error(`Failed to fetch workspaces: ${error.message}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a new workspace
|
|
90
|
+
*/
|
|
91
|
+
async createWorkspace(request) {
|
|
92
|
+
try {
|
|
93
|
+
const response = await this.client.post('/workspaces', request);
|
|
94
|
+
console.log(chalk_1.default.blue(`📁 Created workspace: ${request.name}`));
|
|
95
|
+
return response.data;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw new Error(`Failed to create workspace "${request.name}": ${error.message}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Find workspace by name
|
|
103
|
+
*/
|
|
104
|
+
async findWorkspace(name) {
|
|
105
|
+
const workspaces = await this.getWorkspaces();
|
|
106
|
+
return workspaces.find(w => w.name === name) || null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Find or create workspace
|
|
110
|
+
*/
|
|
111
|
+
async findOrCreateWorkspace(name, permissions) {
|
|
112
|
+
let workspace = await this.findWorkspace(name);
|
|
113
|
+
if (!workspace) {
|
|
114
|
+
const request = {
|
|
115
|
+
name,
|
|
116
|
+
description: `Auto-created workspace for: ${name}`
|
|
117
|
+
};
|
|
118
|
+
if (permissions) {
|
|
119
|
+
request.permissions = this.convertPermissions(permissions);
|
|
120
|
+
}
|
|
121
|
+
workspace = await this.createWorkspace(request);
|
|
122
|
+
}
|
|
123
|
+
return workspace;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get folders in workspace
|
|
127
|
+
*/
|
|
128
|
+
async getFolders(workspaceId) {
|
|
129
|
+
try {
|
|
130
|
+
const params = {};
|
|
131
|
+
if (workspaceId) {
|
|
132
|
+
params.workspace_id = workspaceId;
|
|
133
|
+
}
|
|
134
|
+
const response = await this.client.get('/folders', { params });
|
|
135
|
+
return response.data.data || response.data;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw new Error(`Failed to fetch folders: ${error.message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new folder
|
|
143
|
+
*/
|
|
144
|
+
async createFolder(request) {
|
|
145
|
+
try {
|
|
146
|
+
const response = await this.client.post('/folders', request);
|
|
147
|
+
console.log(chalk_1.default.blue(`📁 Created folder: ${request.name}`));
|
|
148
|
+
return response.data;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
throw new Error(`Failed to create folder "${request.name}": ${error.message}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Find or create folder hierarchy
|
|
156
|
+
*/
|
|
157
|
+
async findOrCreateFolderPath(folderPath, workspaceId, permissions) {
|
|
158
|
+
const pathParts = folderPath.split('/').filter(part => part.trim().length > 0);
|
|
159
|
+
let parentId;
|
|
160
|
+
let currentFolder;
|
|
161
|
+
for (const folderName of pathParts) {
|
|
162
|
+
const folders = await this.getFolders(workspaceId);
|
|
163
|
+
// Find existing folder
|
|
164
|
+
currentFolder = folders.find(f => f.name === folderName &&
|
|
165
|
+
f.parent_id === parentId &&
|
|
166
|
+
(!workspaceId || f.workspace_id === workspaceId));
|
|
167
|
+
if (!currentFolder) {
|
|
168
|
+
// Create new folder
|
|
169
|
+
const request = {
|
|
170
|
+
name: folderName,
|
|
171
|
+
parent_id: parentId,
|
|
172
|
+
workspace_id: workspaceId
|
|
173
|
+
};
|
|
174
|
+
if (permissions) {
|
|
175
|
+
request.permissions = this.convertPermissions(permissions);
|
|
176
|
+
}
|
|
177
|
+
currentFolder = await this.createFolder(request);
|
|
178
|
+
}
|
|
179
|
+
parentId = currentFolder.id;
|
|
180
|
+
}
|
|
181
|
+
if (!currentFolder) {
|
|
182
|
+
throw new Error(`Failed to create folder path: ${folderPath}`);
|
|
183
|
+
}
|
|
184
|
+
return currentFolder;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Upload a file
|
|
188
|
+
*/
|
|
189
|
+
async uploadFile(filePath, request) {
|
|
190
|
+
if (!await fs_extra_1.default.pathExists(filePath)) {
|
|
191
|
+
throw new Error(`File not found: ${filePath}`);
|
|
192
|
+
}
|
|
193
|
+
const formData = new form_data_1.default();
|
|
194
|
+
const fileStream = fs_extra_1.default.createReadStream(filePath);
|
|
195
|
+
const fileName = path_1.default.basename(filePath);
|
|
196
|
+
const stats = await fs_extra_1.default.stat(filePath);
|
|
197
|
+
formData.append('file', fileStream, {
|
|
198
|
+
filename: fileName,
|
|
199
|
+
contentType: this.getMimeType(filePath)
|
|
200
|
+
});
|
|
201
|
+
// Add optional parameters
|
|
202
|
+
if (request.folder_id) {
|
|
203
|
+
formData.append('folder_id', request.folder_id);
|
|
204
|
+
}
|
|
205
|
+
if (request.workspace_id) {
|
|
206
|
+
formData.append('workspace_id', request.workspace_id);
|
|
207
|
+
}
|
|
208
|
+
if (request.metadata) {
|
|
209
|
+
formData.append('metadata', JSON.stringify(request.metadata));
|
|
210
|
+
}
|
|
211
|
+
if (request.permissions) {
|
|
212
|
+
formData.append('permissions', JSON.stringify(request.permissions));
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const response = await this.client.post('/files', formData, {
|
|
216
|
+
headers: {
|
|
217
|
+
...formData.getHeaders(),
|
|
218
|
+
},
|
|
219
|
+
maxContentLength: Infinity,
|
|
220
|
+
maxBodyLength: Infinity
|
|
221
|
+
});
|
|
222
|
+
const file = response.data;
|
|
223
|
+
console.log(chalk_1.default.green(`✅ Uploaded: ${fileName} (${this.formatFileSize(stats.size)})`));
|
|
224
|
+
return file;
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
throw new Error(`Failed to upload file "${fileName}": ${error.response?.data?.message || error.message}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Import document using mapping
|
|
232
|
+
*/
|
|
233
|
+
async importDocument(mapping) {
|
|
234
|
+
const result = {
|
|
235
|
+
success: false,
|
|
236
|
+
filePath: mapping.filePath
|
|
237
|
+
};
|
|
238
|
+
try {
|
|
239
|
+
let workspaceId;
|
|
240
|
+
let folderId;
|
|
241
|
+
// Handle workspace
|
|
242
|
+
if (mapping.workspace) {
|
|
243
|
+
const workspace = await this.findOrCreateWorkspace(mapping.workspace, mapping.permissions);
|
|
244
|
+
workspaceId = workspace.id;
|
|
245
|
+
}
|
|
246
|
+
// Handle folder
|
|
247
|
+
if (mapping.targetFolder) {
|
|
248
|
+
const folder = await this.findOrCreateFolderPath(mapping.targetFolder, workspaceId, mapping.permissions);
|
|
249
|
+
folderId = folder.id;
|
|
250
|
+
}
|
|
251
|
+
// Prepare upload request
|
|
252
|
+
const uploadRequest = {
|
|
253
|
+
folder_id: folderId,
|
|
254
|
+
workspace_id: workspaceId,
|
|
255
|
+
metadata: mapping.metadata
|
|
256
|
+
};
|
|
257
|
+
if (mapping.permissions) {
|
|
258
|
+
uploadRequest.permissions = this.convertPermissions(mapping.permissions);
|
|
259
|
+
}
|
|
260
|
+
// Upload file
|
|
261
|
+
const file = await this.uploadFile(mapping.filePath, uploadRequest);
|
|
262
|
+
result.success = true;
|
|
263
|
+
result.document = {
|
|
264
|
+
id: file.id,
|
|
265
|
+
name: file.name,
|
|
266
|
+
size: file.size,
|
|
267
|
+
mime_type: file.mime_type,
|
|
268
|
+
folder_id: file.folder_id,
|
|
269
|
+
workspace_id: file.workspace_id,
|
|
270
|
+
created_at: file.created_at,
|
|
271
|
+
updated_at: file.updated_at
|
|
272
|
+
};
|
|
273
|
+
const targetLocation = [
|
|
274
|
+
mapping.workspace,
|
|
275
|
+
mapping.targetFolder,
|
|
276
|
+
path_1.default.basename(mapping.filePath)
|
|
277
|
+
].filter(Boolean).join(' → ');
|
|
278
|
+
console.log(chalk_1.default.green(`✅ Imported: ${targetLocation}`));
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
result.error = error.message;
|
|
282
|
+
console.error(chalk_1.default.red(`❌ Failed to import ${mapping.filePath}: ${error.message}`));
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Bulk import documents
|
|
288
|
+
*/
|
|
289
|
+
async bulkImport(mappings, options = {}) {
|
|
290
|
+
const { batchSize = 10, concurrent = false } = options;
|
|
291
|
+
const results = [];
|
|
292
|
+
console.log(chalk_1.default.blue(`📦 Starting bulk import of ${mappings.length} documents`));
|
|
293
|
+
console.log(chalk_1.default.gray(` Batch size: ${batchSize}, Concurrent: ${concurrent}`));
|
|
294
|
+
if (concurrent) {
|
|
295
|
+
// Concurrent processing in batches
|
|
296
|
+
for (let i = 0; i < mappings.length; i += batchSize) {
|
|
297
|
+
const batch = mappings.slice(i, i + batchSize);
|
|
298
|
+
const batchPromises = batch.map(mapping => this.importDocument(mapping));
|
|
299
|
+
const batchResults = await Promise.allSettled(batchPromises);
|
|
300
|
+
for (const promiseResult of batchResults) {
|
|
301
|
+
if (promiseResult.status === 'fulfilled') {
|
|
302
|
+
results.push(promiseResult.value);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
results.push({
|
|
306
|
+
success: false,
|
|
307
|
+
filePath: 'unknown',
|
|
308
|
+
error: promiseResult.reason?.message || 'Unknown error'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// Progress update
|
|
313
|
+
console.log(chalk_1.default.blue(`📊 Progress: ${results.length}/${mappings.length} processed`));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
// Sequential processing
|
|
318
|
+
for (let i = 0; i < mappings.length; i++) {
|
|
319
|
+
const result = await this.importDocument(mappings[i]);
|
|
320
|
+
results.push(result);
|
|
321
|
+
// Progress update every 10 documents
|
|
322
|
+
if ((i + 1) % 10 === 0) {
|
|
323
|
+
console.log(chalk_1.default.blue(`📊 Progress: ${i + 1}/${mappings.length} processed`));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const successful = results.filter(r => r.success).length;
|
|
328
|
+
const failed = results.length - successful;
|
|
329
|
+
console.log(chalk_1.default.bold('\n📊 Bulk Import Summary'));
|
|
330
|
+
console.log(chalk_1.default.green(`✅ Successful: ${successful}`));
|
|
331
|
+
if (failed > 0) {
|
|
332
|
+
console.log(chalk_1.default.red(`❌ Failed: ${failed}`));
|
|
333
|
+
}
|
|
334
|
+
return results;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Search files and folders
|
|
338
|
+
*/
|
|
339
|
+
async search(query, type) {
|
|
340
|
+
try {
|
|
341
|
+
const params = { q: query };
|
|
342
|
+
if (type) {
|
|
343
|
+
params.type = type;
|
|
344
|
+
}
|
|
345
|
+
const response = await this.client.get('/search', { params });
|
|
346
|
+
return response.data;
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
throw new Error(`Search failed: ${error.message}`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Convert DocumentMapping permissions to HubDoc API format
|
|
354
|
+
*/
|
|
355
|
+
convertPermissions(permissions) {
|
|
356
|
+
if (!permissions)
|
|
357
|
+
return [];
|
|
358
|
+
const result = [];
|
|
359
|
+
if (permissions.read) {
|
|
360
|
+
result.push({
|
|
361
|
+
level: 'read',
|
|
362
|
+
users: permissions.read.users || [],
|
|
363
|
+
groups: permissions.read.groups || []
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (permissions.write) {
|
|
367
|
+
result.push({
|
|
368
|
+
level: 'write',
|
|
369
|
+
users: permissions.write.users || [],
|
|
370
|
+
groups: permissions.write.groups || []
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Get MIME type from file extension
|
|
377
|
+
*/
|
|
378
|
+
getMimeType(filePath) {
|
|
379
|
+
const ext = path_1.default.extname(filePath).toLowerCase();
|
|
380
|
+
const mimeTypes = {
|
|
381
|
+
'.pdf': 'application/pdf',
|
|
382
|
+
'.doc': 'application/msword',
|
|
383
|
+
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
384
|
+
'.xls': 'application/vnd.ms-excel',
|
|
385
|
+
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
386
|
+
'.ppt': 'application/vnd.ms-powerpoint',
|
|
387
|
+
'.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
388
|
+
'.txt': 'text/plain',
|
|
389
|
+
'.csv': 'text/csv',
|
|
390
|
+
'.json': 'application/json',
|
|
391
|
+
'.xml': 'application/xml',
|
|
392
|
+
'.jpg': 'image/jpeg',
|
|
393
|
+
'.jpeg': 'image/jpeg',
|
|
394
|
+
'.png': 'image/png',
|
|
395
|
+
'.gif': 'image/gif',
|
|
396
|
+
'.bmp': 'image/bmp',
|
|
397
|
+
'.tiff': 'image/tiff',
|
|
398
|
+
'.zip': 'application/zip',
|
|
399
|
+
'.rar': 'application/vnd.rar'
|
|
400
|
+
};
|
|
401
|
+
return mimeTypes[ext] || 'application/octet-stream';
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Format file size for display
|
|
405
|
+
*/
|
|
406
|
+
formatFileSize(bytes) {
|
|
407
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
408
|
+
let size = bytes;
|
|
409
|
+
let unitIndex = 0;
|
|
410
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
411
|
+
size /= 1024;
|
|
412
|
+
unitIndex++;
|
|
413
|
+
}
|
|
414
|
+
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
exports.HubDocApiServiceV2 = HubDocApiServiceV2;
|
|
418
|
+
//# sourceMappingURL=hubdoc-api-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hubdoc-api-v2.js","sourceRoot":"","sources":["../../src/services/hubdoc-api-v2.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAC7C,0DAAiC;AACjC,wDAA0B;AAC1B,gDAAwB;AAExB,kDAA0B;AAqF1B,MAAa,kBAAkB;IAI7B,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,MAAM;YACtB,OAAO,EAAE;gBACP,eAAe,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE;gBACzC,QAAQ,EAAE,kBAAkB;aAC7B;YACD,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAEH,wCAAwC;QACxC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC7C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC9E,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,8CAA8C;QAC9C,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EACpB,KAAK,CAAC,EAAE;YACN,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG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BAAiB;YACzB,MAAM,EAAE,qBAAqB;SAC9B,CAAC;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,0BAA0B,CAAC;IACtD,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,KAAa;QAClC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtC,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,OAAO,IAAI,IAAI,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpD,IAAI,IAAI,IAAI,CAAC;YACb,SAAS,EAAE,CAAC;QACd,CAAC;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;IAClD,CAAC;CACF;AAxdD,gDAwdC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { HubDocConfig, DocumentMapping } from '../types';
|
|
2
|
+
export interface HubDocWorkspace {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
domain?: string;
|
|
7
|
+
permissions: {
|
|
8
|
+
level: 'read' | 'write' | 'admin';
|
|
9
|
+
users: string[];
|
|
10
|
+
groups: string[];
|
|
11
|
+
}[];
|
|
12
|
+
metadata?: Record<string, any>;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
}
|
|
16
|
+
export interface HubDocFolder {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
parent_id?: string;
|
|
20
|
+
workspace_id?: string;
|
|
21
|
+
domain?: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
permissions: {
|
|
24
|
+
level: 'read' | 'write' | 'admin';
|
|
25
|
+
users: string[];
|
|
26
|
+
groups: string[];
|
|
27
|
+
}[];
|
|
28
|
+
metadata?: Record<string, any>;
|
|
29
|
+
created_at: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
}
|
|
32
|
+
export interface HubDocFile {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
size: number;
|
|
36
|
+
mime_type: string;
|
|
37
|
+
folder_id?: string;
|
|
38
|
+
workspace_id?: string;
|
|
39
|
+
domain?: string;
|
|
40
|
+
version: number;
|
|
41
|
+
metadata?: Record<string, any>;
|
|
42
|
+
permissions: {
|
|
43
|
+
level: 'read' | 'write' | 'admin';
|
|
44
|
+
users: string[];
|
|
45
|
+
groups: string[];
|
|
46
|
+
}[];
|
|
47
|
+
download_url?: string;
|
|
48
|
+
created_at: string;
|
|
49
|
+
updated_at: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PaginationParams {
|
|
52
|
+
page?: number;
|
|
53
|
+
limit?: number;
|
|
54
|
+
sort?: string;
|
|
55
|
+
order?: 'asc' | 'desc';
|
|
56
|
+
}
|
|
57
|
+
export interface PaginatedResponse<T> {
|
|
58
|
+
data: T[];
|
|
59
|
+
pagination: {
|
|
60
|
+
current_page: number;
|
|
61
|
+
total_pages: number;
|
|
62
|
+
total_items: number;
|
|
63
|
+
items_per_page: number;
|
|
64
|
+
has_next: boolean;
|
|
65
|
+
has_prev: boolean;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export interface CreateWorkspaceRequest {
|
|
69
|
+
name: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
domain?: string;
|
|
72
|
+
permissions?: {
|
|
73
|
+
level: 'read' | 'write' | 'admin';
|
|
74
|
+
users?: string[];
|
|
75
|
+
groups?: string[];
|
|
76
|
+
}[];
|
|
77
|
+
metadata?: Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
export interface CreateFolderRequest {
|
|
80
|
+
name: string;
|
|
81
|
+
parent_id?: string;
|
|
82
|
+
workspace_id?: string;
|
|
83
|
+
domain?: string;
|
|
84
|
+
permissions?: {
|
|
85
|
+
level: 'read' | 'write' | 'admin';
|
|
86
|
+
users?: string[];
|
|
87
|
+
groups?: string[];
|
|
88
|
+
}[];
|
|
89
|
+
metadata?: Record<string, any>;
|
|
90
|
+
}
|
|
91
|
+
export interface UploadFileRequest {
|
|
92
|
+
folder_id?: string;
|
|
93
|
+
workspace_id?: string;
|
|
94
|
+
domain?: string;
|
|
95
|
+
permissions?: {
|
|
96
|
+
level: 'read' | 'write' | 'admin';
|
|
97
|
+
users?: string[];
|
|
98
|
+
groups?: string[];
|
|
99
|
+
}[];
|
|
100
|
+
metadata?: Record<string, any>;
|
|
101
|
+
}
|
|
102
|
+
export interface ExportItem {
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
type: 'workspace' | 'folder' | 'file';
|
|
106
|
+
parent_id?: string;
|
|
107
|
+
workspace_id?: string;
|
|
108
|
+
folder_id?: string;
|
|
109
|
+
path: string;
|
|
110
|
+
size?: number;
|
|
111
|
+
metadata?: Record<string, any>;
|
|
112
|
+
download_url?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ImportResult {
|
|
115
|
+
success: boolean;
|
|
116
|
+
filePath: string;
|
|
117
|
+
document?: HubDocFile;
|
|
118
|
+
error?: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Complete HubDoc API Client with workspaces, folders, files, and pagination support
|
|
122
|
+
*/
|
|
123
|
+
export declare class HubDocClient {
|
|
124
|
+
private client;
|
|
125
|
+
private config;
|
|
126
|
+
constructor(config: HubDocConfig);
|
|
127
|
+
/**
|
|
128
|
+
* Test API connection and authentication
|
|
129
|
+
*/
|
|
130
|
+
testConnection(): Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* Login and get JWT token
|
|
133
|
+
*/
|
|
134
|
+
login(email: string, password: string): Promise<string>;
|
|
135
|
+
/**
|
|
136
|
+
* OAuth2 Client Credentials flow
|
|
137
|
+
*/
|
|
138
|
+
authenticateOAuth2(): Promise<string>;
|
|
139
|
+
/**
|
|
140
|
+
* Get all workspaces with pagination support
|
|
141
|
+
*/
|
|
142
|
+
getWorkspaces(params?: PaginationParams & {
|
|
143
|
+
domain?: string;
|
|
144
|
+
}): Promise<PaginatedResponse<HubDocWorkspace>>;
|
|
145
|
+
/**
|
|
146
|
+
* Get all workspaces (paginated iterator)
|
|
147
|
+
*/
|
|
148
|
+
getAllWorkspaces(domain?: string): Promise<HubDocWorkspace[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Create a new workspace
|
|
151
|
+
*/
|
|
152
|
+
createWorkspace(request: CreateWorkspaceRequest): Promise<HubDocWorkspace>;
|
|
153
|
+
/**
|
|
154
|
+
* Get workspace by ID
|
|
155
|
+
*/
|
|
156
|
+
getWorkspace(id: string): Promise<HubDocWorkspace>;
|
|
157
|
+
/**
|
|
158
|
+
* Find workspace by name and optionally domain
|
|
159
|
+
*/
|
|
160
|
+
findWorkspace(name: string, domain?: string): Promise<HubDocWorkspace | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Find or create workspace
|
|
163
|
+
*/
|
|
164
|
+
findOrCreateWorkspace(name: string, domain?: string, permissions?: DocumentMapping['permissions']): Promise<HubDocWorkspace>;
|
|
165
|
+
/**
|
|
166
|
+
* Get folders with pagination support
|
|
167
|
+
*/
|
|
168
|
+
getFolders(params?: PaginationParams & {
|
|
169
|
+
workspace_id?: string;
|
|
170
|
+
parent_id?: string;
|
|
171
|
+
domain?: string;
|
|
172
|
+
}): Promise<PaginatedResponse<HubDocFolder>>;
|
|
173
|
+
/**
|
|
174
|
+
* Get all folders (paginated iterator)
|
|
175
|
+
*/
|
|
176
|
+
getAllFolders(workspaceId?: string, domain?: string): Promise<HubDocFolder[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Create a new folder
|
|
179
|
+
*/
|
|
180
|
+
createFolder(request: CreateFolderRequest): Promise<HubDocFolder>;
|
|
181
|
+
/**
|
|
182
|
+
* Get folder by ID
|
|
183
|
+
*/
|
|
184
|
+
getFolder(id: string): Promise<HubDocFolder>;
|
|
185
|
+
/**
|
|
186
|
+
* Find or create folder hierarchy
|
|
187
|
+
*/
|
|
188
|
+
findOrCreateFolderPath(folderPath: string, workspaceId?: string, domain?: string, permissions?: DocumentMapping['permissions']): Promise<HubDocFolder>;
|
|
189
|
+
/**
|
|
190
|
+
* Get files with pagination support
|
|
191
|
+
*/
|
|
192
|
+
getFiles(params?: PaginationParams & {
|
|
193
|
+
folder_id?: string;
|
|
194
|
+
workspace_id?: string;
|
|
195
|
+
domain?: string;
|
|
196
|
+
}): Promise<PaginatedResponse<HubDocFile>>;
|
|
197
|
+
/**
|
|
198
|
+
* Get all files (paginated iterator)
|
|
199
|
+
*/
|
|
200
|
+
getAllFiles(folderId?: string, workspaceId?: string, domain?: string): Promise<HubDocFile[]>;
|
|
201
|
+
/**
|
|
202
|
+
* Upload a file
|
|
203
|
+
*/
|
|
204
|
+
uploadFile(filePath: string, request: UploadFileRequest): Promise<HubDocFile>;
|
|
205
|
+
/**
|
|
206
|
+
* Get file by ID
|
|
207
|
+
*/
|
|
208
|
+
getFile(id: string): Promise<HubDocFile>;
|
|
209
|
+
/**
|
|
210
|
+
* Download a file
|
|
211
|
+
*/
|
|
212
|
+
downloadFile(id: string, targetPath: string): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Scan all accessible files and folders for export
|
|
215
|
+
*/
|
|
216
|
+
scanForExport(domain?: string): Promise<ExportItem[]>;
|
|
217
|
+
/**
|
|
218
|
+
* Import document using mapping
|
|
219
|
+
*/
|
|
220
|
+
importDocument(mapping: DocumentMapping): Promise<ImportResult>;
|
|
221
|
+
/**
|
|
222
|
+
* Search across workspaces, folders, and files
|
|
223
|
+
*/
|
|
224
|
+
search(query: string, type?: 'workspace' | 'folder' | 'file', domain?: string): Promise<any>;
|
|
225
|
+
/**
|
|
226
|
+
* Format paginated response
|
|
227
|
+
*/
|
|
228
|
+
private formatPaginatedResponse;
|
|
229
|
+
/**
|
|
230
|
+
* Build full folder path from hierarchy
|
|
231
|
+
*/
|
|
232
|
+
private buildFolderPath;
|
|
233
|
+
/**
|
|
234
|
+
* Convert DocumentMapping permissions to HubDoc API format
|
|
235
|
+
*/
|
|
236
|
+
private convertPermissions;
|
|
237
|
+
/**
|
|
238
|
+
* Get MIME type from file extension
|
|
239
|
+
*/
|
|
240
|
+
private getMimeType;
|
|
241
|
+
/**
|
|
242
|
+
* Format file size for display
|
|
243
|
+
*/
|
|
244
|
+
private formatFileSize;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=hubdoc-client.d.ts.map
|