@sinoia/hubdoc-tools 1.2.1 → 1.3.1

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 (62) hide show
  1. package/README.md +219 -412
  2. package/dist/api/api/users-api.d.ts +246 -0
  3. package/dist/api/api/users-api.d.ts.map +1 -0
  4. package/dist/api/api/users-api.js +465 -0
  5. package/dist/api/api/users-api.js.map +1 -0
  6. package/dist/api/api.d.ts +1 -0
  7. package/dist/api/api.d.ts.map +1 -1
  8. package/dist/api/api.js +1 -0
  9. package/dist/api/api.js.map +1 -1
  10. package/dist/api/models/contact-mutation.d.ts +4 -4
  11. package/dist/api/models/contact-mutation.d.ts.map +1 -1
  12. package/dist/api/models/contact.d.ts +8 -8
  13. package/dist/api/models/contact.d.ts.map +1 -1
  14. package/dist/api/models/group-mutation.d.ts +1 -1
  15. package/dist/api/models/group-mutation.d.ts.map +1 -1
  16. package/dist/api/models/group.d.ts +3 -3
  17. package/dist/api/models/group.d.ts.map +1 -1
  18. package/dist/api/models/index.d.ts +1 -0
  19. package/dist/api/models/index.d.ts.map +1 -1
  20. package/dist/api/models/index.js +1 -0
  21. package/dist/api/models/index.js.map +1 -1
  22. package/dist/api/models/permission-actor.d.ts +1 -1
  23. package/dist/api/models/permission-actor.d.ts.map +1 -1
  24. package/dist/api/models/permission-mutation.d.ts +5 -5
  25. package/dist/api/models/permission-mutation.d.ts.map +1 -1
  26. package/dist/api/models/permission.d.ts +7 -7
  27. package/dist/api/models/permission.d.ts.map +1 -1
  28. package/dist/api/models/user-mutation.d.ts +45 -0
  29. package/dist/api/models/user-mutation.d.ts.map +1 -0
  30. package/dist/api/models/user-mutation.js +23 -0
  31. package/dist/api/models/user-mutation.js.map +1 -0
  32. package/dist/api/models/user.d.ts +43 -0
  33. package/dist/api/models/user.d.ts.map +1 -1
  34. package/dist/api/models/user.js +7 -0
  35. package/dist/api/models/user.js.map +1 -1
  36. package/dist/api-client.d.ts +19 -0
  37. package/dist/api-client.d.ts.map +1 -0
  38. package/dist/api-client.js +43 -0
  39. package/dist/api-client.js.map +1 -0
  40. package/dist/commands/import.d.ts +23 -1
  41. package/dist/commands/import.d.ts.map +1 -1
  42. package/dist/commands/import.js +138 -0
  43. package/dist/commands/import.js.map +1 -1
  44. package/dist/index.d.ts +2 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +3 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/services/hubdoc-api.d.ts +3 -1
  49. package/dist/services/hubdoc-api.d.ts.map +1 -1
  50. package/dist/services/hubdoc-api.js +31 -51
  51. package/dist/services/hubdoc-api.js.map +1 -1
  52. package/dist/services/permission-manager.d.ts +42 -0
  53. package/dist/services/permission-manager.d.ts.map +1 -0
  54. package/dist/services/permission-manager.js +187 -0
  55. package/dist/services/permission-manager.js.map +1 -0
  56. package/dist/types/index.d.ts +13 -0
  57. package/dist/types/index.d.ts.map +1 -1
  58. package/dist/utils/csv.d.ts +44 -0
  59. package/dist/utils/csv.d.ts.map +1 -1
  60. package/dist/utils/csv.js +268 -36
  61. package/dist/utils/csv.js.map +1 -1
  62. package/package.json +2 -1
package/README.md CHANGED
@@ -5,541 +5,348 @@
5
5
  [![npm version](https://badge.fury.io/js/%40sinoia%2Fhubdoc-tools.svg)](https://www.npmjs.com/package/@sinoia/hubdoc-tools)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- A powerful Node.js command-line tool for bulk document import/export with HubDoc solution. Import documents from local filesystem or cloud sources to HubDoc, or export documents from HubDoc to local filesystem with customizable folder structures.
8
+ Outil CLI puissant pour l'import/export en masse de documents avec HubDoc. Importez depuis le système de fichiers local ou des sources cloud, exportez avec structures personnalisées et metadata XML.
9
+
10
+ ---
9
11
 
10
12
  ## 📦 Installation
11
13
 
12
14
  ```bash
13
- # Global installation (recommended)
15
+ # Installation globale (recommandé)
14
16
  npm install -g @sinoia/hubdoc-tools
15
17
 
16
- # Verify installation
18
+ # Vérifier l'installation
17
19
  hubdoc-tool --version
18
20
  ```
19
21
 
20
- **🚀 Latest Features:**
21
- - **🔐 Automatic OAuth2**: Zero-config authentication with automatic token refresh
22
- - **📦 NPM Package**: Install globally with `npm install -g @sinoia/hubdoc-tools`
23
- - **🔌 API Integration**: Full integration with official HubDoc Swagger/OpenAPI API
24
- - **🧩 Plugin System**: Extensible architecture for external sources (OneDrive, Google Drive, S3, Dropbox)
25
- - **✅ Enhanced Validation**: Pre-import validation and detailed error reporting
26
- - **🎯 Interactive Mode**: Guided workflows with previews and confirmations
27
-
28
- ### Features
29
-
30
- **📥 Import Capabilities**
31
- - **Direct Import Mode**: Import all files from a directory, preserving folder structure
32
- - **Mapping Import Mode**: Use CSV mapping file for precise control over document placement
33
- - **Project Support**: Assign documents to specific projects with classification plans
34
- - **Permissions Management**: Set user and group permissions (read/write) on imported documents
35
-
36
- **📤 Export Capabilities**
37
- - **Scan Mode**: Generate export mapping from existing HubDoc documents
38
- - **Export Mode**: Download documents with customizable folder structure recreation
39
- - **XML Metadata Export**: Generate `*_metadata.xml` files with HubDoc metadata for each exported document
40
- - **Project/Domain Filtering**: Export specific subsets of documents
41
- - **Path Customization**: Specify custom target directories for exported files
42
-
43
- **⚙️ General Features**
44
- - **🔐 Automatic OAuth2**: Zero-config authentication with automatic token refresh and expiration handling
45
- - **🎯 Interactive & CLI Modes**: Both interactive wizard and command-line interface
46
- - **📁 Folder Management**: Automatic folder creation in HubDoc
47
- - **📊 Progress Tracking**: Real-time import/export progress with detailed feedback
48
- - **🔄 Token Management**: Automatic token refresh before expiration (60s buffer)
49
-
50
- ## 🚀 Quick Start
51
-
52
- ### 1. Installation
53
- ```bash
54
- npm install -g @sinoia/hubdoc-tools
55
- ```
56
-
57
- ### 2. Configuration
22
+ ---
58
23
 
59
- #### Automatic Setup (OAuth2 - Recommended)
24
+ ## Quick Start
60
25
 
61
- **Configuration is now fully automatic!** Simply set environment variables and run any command:
26
+ ### 1. Configuration (30 secondes)
62
27
 
63
28
  ```bash
64
- # Set OAuth2 credentials (one time)
29
+ # Définir les credentials OAuth2
65
30
  export HUBDOC_API_URL=https://rec.hubdoc.sinoia.cloud
66
31
  export HUBDOC_OAUTH_CLIENT_ID=your-client-id
67
32
  export HUBDOC_OAUTH_CLIENT_SECRET=your-client-secret
68
33
  export HUBDOC_OAUTH_SCOPES="read write"
69
-
70
- # Run any command - authentication is automatic!
71
- hubdoc-tool import --source ./documents
72
34
  ```
73
35
 
74
- **What happens automatically:**
75
- 1. ✅ CLI checks for valid token
76
- 2. 🔄 Refreshes token if expired (using refresh_token)
77
- 3. 🌐 Opens browser for OAuth authentication if needed
78
- 4. 💾 Saves token to `.hubdoc-config.json`
79
- 5. ▶️ Proceeds with your command
80
-
81
- **No manual token management required!**
82
-
83
- #### Alternative: Configuration File
84
-
85
- Create a `.hubdoc-config.json` file (environment variables override this):
36
+ **L'authentification est ensuite 100% automatique !** ✨
86
37
 
87
- ```json
88
- {
89
- "apiUrl": "https://rec.hubdoc.sinoia.cloud",
90
- "clientId": "your-client-id",
91
- "clientSecret": "your-client-secret",
92
- "scopes": ["read", "write"]
93
- }
94
- ```
38
+ ### 2. Import Basique
95
39
 
96
- Or use `.env` file:
97
40
  ```bash
98
- HUBDOC_API_URL=https://rec.hubdoc.sinoia.cloud
99
- HUBDOC_OAUTH_CLIENT_ID=your-client-id
100
- HUBDOC_OAUTH_CLIENT_SECRET=your-client-secret
101
- HUBDOC_OAUTH_SCOPES="read write"
102
- ```
41
+ # Import direct (préserve la structure)
42
+ hubdoc-tool import --direct ./invoices
103
43
 
104
- ### 3. Basic Usage
105
- ```bash
106
- # Generate mapping from local directory
44
+ # Ou avec mapping CSV
107
45
  hubdoc-tool generate-mapping ./documents
108
-
109
- # Import documents (authentication is automatic!)
110
- hubdoc-tool import --source /path/to/documents
111
46
  hubdoc-tool import --mapping mapping.csv
112
- hubdoc-tool import --direct ./invoices
47
+ ```
113
48
 
114
- # Export documents
115
- hubdoc-tool export --scan # Generate export mapping
116
- hubdoc-tool export --mapping export-mapping.csv
117
- hubdoc-tool export --generate-xml-metadata # With XML metadata
49
+ ### 3. Export
118
50
 
119
- # Interactive mode
120
- hubdoc-tool --interactive
51
+ ```bash
52
+ # Générer mapping depuis HubDoc
53
+ hubdoc-tool export --scan
121
54
 
122
- # Use different engines for import
123
- hubdoc-tool --engine onedrive
124
- hubdoc-tool --engine googledrive
125
- hubdoc-tool --engine s3
55
+ # Exporter avec metadata XML
56
+ hubdoc-tool export --mapping export-mapping.csv --generate-xml-metadata
126
57
  ```
127
58
 
128
- ### 4. Plugin-based Sources
129
- ```bash
130
- # Microsoft OneDrive/SharePoint
131
- hubdoc-tool --engine onedrive
59
+ ---
132
60
 
133
- # Google Drive
134
- hubdoc-tool --engine googledrive
61
+ ## 🎯 Fonctionnalités Clés
135
62
 
136
- # AWS S3
137
- hubdoc-tool --engine s3
63
+ ### Import
64
+ - **Import direct** : Structure de dossiers préservée automatiquement
65
+ - ✅ **Import avec mapping** : Contrôle précis via CSV
66
+ - ✅ **Permissions** : Gestion read/write par utilisateur/groupe
67
+ - ✅ **Metadata** : Format simplifié `key: value, parent.child: value`
68
+ - ✅ **Sources multiples** : Local, OneDrive, Google Drive, AWS S3
138
69
 
139
- # Local filesystem with XML metadata
140
- hubdoc-tool --engine filesystem --source /path/to/docs
141
- ```
70
+ ### Export
71
+ - **Scan automatique** : Génération du mapping depuis HubDoc
72
+ - ✅ **Structure personnalisée** : Recréation de l'arborescence
73
+ - ✅ **Metadata XML** : Fichiers `*_metadata.xml` générés automatiquement
74
+ - ✅ **Filtrage** : Par projet, domaine, workspace
142
75
 
143
- ### Documentation
76
+ ### Général
77
+ - ✅ **OAuth2 automatique** : Zéro config manuelle, refresh automatique
78
+ - ✅ **Mode interactif** : Assistant guidé étape par étape
79
+ - ✅ **Validation** : Pré-validation des fichiers avant import
80
+ - ✅ **Concurrent** : Import/export parallèle configurable
81
+ - ✅ **Plugins** : Architecture extensible pour sources externes
144
82
 
145
- See [README-hubdoc-tool.md](./README-hubdoc-tool.md) for detailed documentation, including:
83
+ ---
146
84
 
147
- - Complete installation and configuration instructions
148
- - CSV mapping format and examples
149
- - Permission system (read/write permissions)
150
- - Command reference
151
- - API integration details
152
- - Error handling
85
+ ## 📚 Documentation
153
86
 
154
- ### CSV Mapping Format
87
+ | Sujet | Description |
88
+ |-------|-------------|
89
+ | **[Configuration](./docs/configuration.md)** | OAuth2, variables d'environnement, fichiers config |
90
+ | **[Permissions](./docs/permissions.md)** | Format naturel : `users:r:email users:w:email | groups:Name` |
91
+ | **[Metadata](./docs/metadata.md)** | Format simplifié : `key: value, parent.child: value` |
92
+ | **[Exemples](./docs/examples.md)** | Cas d'usage, scripts, automatisation |
155
93
 
156
- The tool generates CSV files with the following columns:
94
+ ---
157
95
 
158
- - **File Path**: Path to the source file
159
- - **Target Folder**: Destination folder in HubDoc (created if doesn't exist)
160
- - **Projet**: Project name (optional)
161
- - **Domain**: Business domain for transverse classification
162
- - **Metadata (JSON)**: Additional metadata as JSON object
163
- - **Read Permissions**: Users/groups with read access (`users:user1,user2|groups:group1,group2`)
164
- - **Write Permissions**: Users/groups with write access (`users:user1,user2|groups:group1,group2`)
96
+ ## 🚀 Commandes Principales
165
97
 
166
- ### Example Usage
98
+ ### Import
167
99
 
168
100
  ```bash
169
- # 1. Generate mapping file (from current directory)
170
- npm run dev -- generate-mapping ./invoices
101
+ # Import direct (structure préservée)
102
+ hubdoc-tool import --direct ./documents
171
103
 
172
- # OR from any directory
173
- npm run dev -- generate-mapping --source /path/to/invoices
104
+ # Import avec mapping CSV
105
+ hubdoc-tool import --mapping mapping.csv
174
106
 
175
- # 2. Edit the generated mapping.csv file to specify:
176
- # - Target folders
177
- # - Projects & domains
178
- # - Permissions
179
- # - Metadata
107
+ # Import depuis source externe
108
+ hubdoc-tool --engine onedrive import --source "/Shared Documents"
109
+ hubdoc-tool --engine googledrive import --source "My Drive/Invoices"
110
+ hubdoc-tool --engine s3 import --source "s3://bucket/docs"
180
111
 
181
- # 3. Import using the mapping
182
- npm run dev -- import --mapping mapping.csv
112
+ # Options
113
+ --concurrent 5 # 5 jobs parallèles
114
+ --skip-existing # Skip documents déjà importés
115
+ --dry-run # Test sans importer
116
+ --validate-all # Validation stricte avant import
117
+ ```
183
118
 
184
- # 4. Export documents from HubDoc
185
- npm run dev -- export --scan # Generate export mapping
186
- npm run dev -- export # Download documents
187
- npm run dev -- export --generate-xml-metadata # Export with XML metadata files
119
+ ### Export
188
120
 
189
- # Test API integration
190
- npm run test-api
191
- ```
121
+ ```bash
122
+ # Générer mapping depuis HubDoc
123
+ hubdoc-tool export --scan
124
+
125
+ # Exporter selon mapping
126
+ hubdoc-tool export --mapping export-mapping.csv
192
127
 
193
- ### XML Metadata Export
128
+ # Export avec XML metadata
129
+ hubdoc-tool export --generate-xml-metadata
194
130
 
195
- When exporting documents from HubDoc, you can generate XML metadata files that contain all the document information:
131
+ # Options
132
+ --target ./output # Dossier de destination
133
+ --concurrent 5 # 5 downloads parallèles
134
+ ```
135
+
136
+ ### Mapping
196
137
 
197
138
  ```bash
198
- # Export with XML metadata generation
199
- npm run dev -- export --generate-xml-metadata
139
+ # Générer mapping depuis dossier local
140
+ hubdoc-tool generate-mapping ./documents
200
141
 
201
- # Interactive export with XML metadata
202
- npm run dev -- export --interactive
203
- # Then select "Yes" for XML metadata generation
142
+ # Générer avec sortie spécifique
143
+ hubdoc-tool generate-mapping ./docs --output custom-mapping.csv
204
144
  ```
205
145
 
206
- **Generated Files Structure:**
207
- ```
208
- export/
209
- ├── Project Name/
210
- │ ├── document.pdf # Original document
211
- │ ├── document_metadata.xml # Document metadata
212
- │ └── Subfolder/
213
- │ ├── another-doc.docx
214
- │ └── another-doc_metadata.xml
215
- └── export_summary.xml # Overall export summary
216
- ```
146
+ ### Mode Interactif
217
147
 
218
- **XML Metadata File Content:**
219
- Each `*_metadata.xml` file contains:
220
- - Document ID and name from HubDoc
221
- - Project and folder path information
222
- - All custom metadata fields
223
- - Export timestamp
224
- - Original download URL
225
- - User-defined metadata
226
-
227
- **Example XML:**
228
- ```xml
229
- <?xml version="1.0" encoding="UTF-8"?>
230
- <document fileName="Contract">
231
- <documentId>doc_123</documentId>
232
- <documentName>Contract.pdf</documentName>
233
- <project>
234
- <name>Client Project</name>
235
- </project>
236
- <folderPath>Legal/Contracts</folderPath>
237
- <author>John Doe</author>
238
- <createdDate>2024-01-15T10:30:00Z</createdDate>
239
- <exportedAt>2024-09-11T13:42:10.829Z</exportedAt>
240
- <originalDownloadUrl>https://hubdoc.example.com/download/doc_123</originalDownloadUrl>
241
- </document>
148
+ ```bash
149
+ # Lancer l'assistant guidé
150
+ hubdoc-tool --interactive
151
+ hubdoc-tool -i
242
152
  ```
243
153
 
244
- ## 🔐 OAuth2 Authentication
154
+ ---
245
155
 
246
- The tool uses **OAuth 2.0 Authorization Code Flow** with automatic token management:
156
+ ## 📋 Format CSV Mapping
247
157
 
248
- ### How It Works
158
+ ### Structure Basique
159
+
160
+ ```csv
161
+ File Path;Target Folder;Workspace;Metadata (key: value, parent.child: value);Permissions (users:r:email users:w:email | groups:Name);Auto Classify;Status;Error;Document ID;Bulk Upload ID
162
+ ```
249
163
 
250
- 1. **First Run**: If no valid token exists, the CLI automatically:
251
- - Starts a local HTTP server on `localhost:8082`
252
- - Opens your browser to the OAuth authorization page
253
- - Receives the authorization code via callback
254
- - Exchanges the code for an access token
255
- - Saves the token and refresh token to `.hubdoc-config.json`
164
+ ### Exemple Simple
256
165
 
257
- 2. **Subsequent Runs**: The CLI automatically:
258
- - Loads the saved token from config file or environment
259
- - Checks if token is expired (with 60s buffer)
260
- - Refreshes the token using refresh_token if needed
261
- - Proceeds with your command
166
+ ```csv
167
+ File Path;Target Folder;Workspace;Metadata (key: value, parent.child: value);Permissions (users:r:email users:w:email | groups:Name);Auto Classify;Status;Error;Document ID;Bulk Upload ID
168
+ /invoices/inv-001.pdf;Factures/2024;Comptabilité;invoice_number: INV-001, amount: 1500;;true;pending;;;
169
+ /contracts/c-a.pdf;Contrats;Juridique;type: service, duration: 24;users:r:legal@ex.com users:w:ceo@ex.com;false;pending;;;
170
+ ```
262
171
 
263
- 3. **No Manual Intervention**: You never need to manually manage tokens!
172
+ **Voir [Exemples](./docs/examples.md) pour plus de cas d'usage**
264
173
 
265
- ### Environment Variables
174
+ ---
266
175
 
267
- Priority order (highest to lowest):
268
- 1. **Environment variables** (override everything)
269
- 2. **`.env` file** (loaded automatically)
270
- 3. **`.hubdoc-config.json`** (saved tokens)
176
+ ## 🔐 Permissions (Format Naturel)
271
177
 
272
- ```bash
273
- # Required for automatic OAuth
274
- export HUBDOC_API_URL=https://rec.hubdoc.sinoia.cloud
275
- export HUBDOC_OAUTH_CLIENT_ID=your-client-id
276
- export HUBDOC_OAUTH_CLIENT_SECRET=your-client-secret
277
- export HUBDOC_OAUTH_SCOPES="read write admin"
178
+ ### Format
278
179
 
279
- # Optional: provide a valid token directly (skips OAuth flow)
280
- export HUBDOC_TOKEN=your-existing-token
281
180
  ```
181
+ users:email1,email2 | users:w:admin@ex.com | groups:Group Name | groups:w:Admin Group
182
+ ```
183
+
184
+ ### Règles
282
185
 
283
- ### Token Expiration
186
+ - **Sans suffixe** = READ par défaut : `users:john@ex.com | groups:Finance`
187
+ - **:r** = READ explicite : `users:r:viewer@ex.com`
188
+ - **:w** = WRITE : `users:w:editor@ex.com | groups:w:Admins`
189
+ - **Espaces supportés** dans les noms de groupes : `groups:Senior Management`
284
190
 
285
- - Tokens typically expire after **2 hours** (7200 seconds)
286
- - The CLI checks expiration **60 seconds before** actual expiration
287
- - Automatic refresh using the refresh_token (no browser required)
288
- - If refresh fails, a new OAuth flow is initiated automatically
191
+ ### Exemples
289
192
 
290
- ### Security Notes
193
+ ```csv
194
+ # Lecture seule
195
+ users:john@ex.com,jane@ex.com | groups:All Staff
291
196
 
292
- - Tokens are stored in `.hubdoc-config.json` (add to `.gitignore`!)
293
- - Client secrets should be stored in environment variables or `.env` file
294
- - The local OAuth callback server only binds to `127.0.0.1` (localhost)
295
- - Authorization codes are single-use and expire quickly
197
+ # Mixte READ + WRITE
198
+ users:viewer@ex.com | users:w:admin@ex.com | groups:Finance | groups:w:Direction
296
199
 
297
- ### API Configuration
200
+ # Groupes avec espaces et accents
201
+ groups:Comptabilité France | groups:w:Présidence Direction
202
+ ```
298
203
 
299
- The tool supports HubDoc APIs with endpoints like:
300
- - `https://rec.hubdoc.sinoia.cloud`
301
- - `https://demo.hubdoc.sinoia.cloud`
204
+ **Voir [Documentation Permissions](./docs/permissions.md) pour détails complets**
302
205
 
303
- Configuration can be stored as:
304
- - Environment variables (recommended for credentials)
305
- - `.env` file (for local development)
306
- - `.hubdoc-config.json` file (for saved tokens)
206
+ ---
307
207
 
308
- ## Plugin Architecture
208
+ ## 📝 Metadata (Format Simplifié)
309
209
 
310
- Le système supporte des plugins pour différentes sources documentaires avec sélection interactive :
210
+ ### Format
311
211
 
312
- ```bash
313
- # Interface unifiée avec sélection d'engine
314
- npm run dev -- --interactive # Mode interactif
315
- npm run dev -- --engine onedrive # OneDrive direct
316
- npm run dev -- --engine core --limit 10 # Core avec limite
317
- npm run dev # Filesystem par défaut
212
+ ```
213
+ key: value, parent.child: value
318
214
  ```
319
215
 
320
- ### Engines disponibles
216
+ ### Exemples
321
217
 
322
- #### 🗂️ **Filesystem** (par défaut)
323
- Import depuis le système de fichiers local avec support des métadonnées XML.
218
+ ```csv
219
+ # Simple
220
+ invoice_number: INV-001, amount: 1500, paid: true
324
221
 
325
- **Fonctionnalités :**
326
- - 📋 **Métadonnées XML** : Support automatique des fichiers `*_metadata.xml`
327
- - 🔍 **Détection intelligente** : Association automatique document ↔ métadonnées
328
- - 📊 **Mapping HubDoc** : Conversion vers champs standard (title, author, project, etc.)
329
- - ⚡ **Formats supportés** : Excel XML, XML simple
222
+ # Objets imbriqués (notation point)
223
+ supplier.name: Acme Corp, supplier.vat: FR123, amount: 2500
330
224
 
331
- ```bash
332
- npm run dev -- --engine filesystem --source /path/to/documents
225
+ # Types auto-détectés
226
+ year: 2024, amount: 1500.50, active: true, optional: null
333
227
  ```
334
228
 
335
- **Exemple avec métadonnées XML :**
336
- ```
337
- documents/
338
- ├── rapport.pdf # Document principal
339
- ├── rapport_metadata.xml # Métadonnées XML associées
340
- └── autre-doc.docx # Autre document
341
- ```
229
+ **Voir [Documentation Metadata](./docs/metadata.md) pour détails complets**
342
230
 
343
- Le système détecte automatiquement `rapport_metadata.xml` et associe les métadonnées (author, title, project, phase, etc.) au document `rapport.pdf`.
231
+ ---
344
232
 
345
- #### ☁️ **OneDrive** - Microsoft OneDrive/SharePoint
233
+ ## 🔌 Plugins / Sources Externes
346
234
 
347
- **Obtention du token :**
348
- 1. Aller sur [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer)
349
- 2. Se connecter avec votre compte Microsoft/Office 365
350
- 3. Demander les permissions `Files.Read.All`
351
- 4. Copier le token généré
235
+ ### OneDrive/SharePoint
352
236
 
353
237
  ```bash
354
- npm run dev -- --engine onedrive --limit 5
355
- # Le système demande le token interactivement
356
- ```
238
+ export ONEDRIVE_CLIENT_ID=your-client-id
239
+ export ONEDRIVE_CLIENT_SECRET=your-client-secret
240
+ export ONEDRIVE_TENANT_ID=your-tenant-id
357
241
 
358
- #### 📁 **Core** - Core Document Management System
242
+ hubdoc-tool --engine onedrive import --source "/Shared Documents/Invoices"
243
+ ```
359
244
 
360
- **Obtention du token :**
361
- 1. Aller sur votre instance Core (ex: `https://rec.plugandwork.fr`)
362
- 2. Naviguer vers : `/users/token`
363
- 3. Copier le token Bearer affiché
245
+ ### Google Drive
364
246
 
365
247
  ```bash
366
- npm run dev -- --engine core --limit 10
367
- # Configuration requise: baseUrl, bearerToken
368
- ```
248
+ export GOOGLE_DRIVE_CLIENT_ID=your-client-id
249
+ export GOOGLE_DRIVE_CLIENT_SECRET=your-client-secret
250
+ export GOOGLE_DRIVE_CREDENTIALS_PATH=./credentials.json
369
251
 
370
- #### 🟢 **Google Drive**
252
+ hubdoc-tool --engine googledrive import --source "My Drive/Documents"
253
+ ```
371
254
 
372
- **Obtention du token :**
373
- 1. Créer une application dans [Google Cloud Console](https://console.cloud.google.com/)
374
- 2. Activer l'API Google Drive
375
- 3. Créer des identifiants OAuth 2.0
376
- 4. Configurer les permissions `https://www.googleapis.com/auth/drive.readonly`
377
- 5. Obtenir `clientId`, `clientSecret`, et effectuer le flow OAuth2
255
+ ### AWS S3
378
256
 
379
257
  ```bash
380
- npm run dev -- --engine googledrive
381
- # Configuration requise: clientId, clientSecret, redirectUri, accessToken
258
+ export AWS_ACCESS_KEY_ID=your-key
259
+ export AWS_SECRET_ACCESS_KEY=your-secret
260
+ export AWS_REGION=us-east-1
261
+
262
+ hubdoc-tool --engine s3 import --source "s3://my-bucket/documents/"
382
263
  ```
383
264
 
384
- #### 📦 **Dropbox**
265
+ **Voir [Exemples](./docs/examples.md) pour configuration détaillée**
385
266
 
386
- **Obtention du token :**
387
- 1. Créer une app sur [Dropbox App Console](https://www.dropbox.com/developers/apps)
388
- 2. Choisir "Scoped access" et "Full Dropbox"
389
- 3. Générer un access token dans les settings de l'app
390
- 4. Copier le token généré
267
+ ---
268
+
269
+ ## 🛠️ Développement
270
+
271
+ ### Installation pour Développement
391
272
 
392
273
  ```bash
393
- npm run dev -- --engine dropbox
394
- # Configuration requise: accessToken
274
+ git clone https://github.com/your-org/hubdoc-tools.git
275
+ cd hubdoc-tools
276
+ npm install
277
+ npm run build
395
278
  ```
396
279
 
397
- ## 🔌 Connecteurs disponibles
280
+ ### Tests
398
281
 
399
- Le système supporte de nombreux connecteurs pour différentes sources documentaires :
282
+ ```bash
283
+ # Tous les tests
284
+ npm test
400
285
 
401
- | Connecteur | Type | Documentation |
402
- |------------|------|---------------|
403
- | 📁 **Filesystem** | Local | Intégré (défaut) |
404
- | ☁️ **OneDrive** | Cloud | Intégré |
405
- | 🗂️ **Google Drive** | Cloud | Intégré |
406
- | 📦 **Dropbox** | Cloud | Intégré |
407
- | 📋 **Core DMS** | GED | Intégré |
408
- | 📦 **Box** | Cloud | [📖 docs/connectors/box.md](./docs/connectors/box.md) |
409
- | ☁️ **AWS S3** | Cloud | [📖 docs/connectors/aws-s3.md](./docs/connectors/aws-s3.md) |
410
- | 🔵 **Azure Blob** | Cloud | [📖 docs/connectors/azure-blob.md](./docs/connectors/azure-blob.md) |
411
- | 📚 **Alfresco** | ECM | [📖 docs/connectors/alfresco.md](./docs/connectors/alfresco.md) |
412
- | 📄 **SharePoint** | Office 365 | [📖 docs/connectors/sharepoint.md](./docs/connectors/sharepoint.md) |
413
- | 🏛️ **Nuxeo** | ECM | [📖 docs/connectors/nuxeo.md](./docs/connectors/nuxeo.md) |
414
- | 🏢 **OpenText** | ECM | [📖 docs/connectors/opentext.md](./docs/connectors/opentext.md) |
286
+ # Tests spécifiques
287
+ npm test -- permissions
288
+ npm test -- metadata
415
289
 
416
- ### Utilisation des connecteurs
290
+ # Coverage
291
+ npm run test:coverage
292
+ ```
417
293
 
418
- ```bash
419
- # Sélection interactive
420
- npm run dev -- --interactive
294
+ ### Build
421
295
 
422
- # Connecteur spécifique
423
- npm run dev -- --engine [nom-connecteur]
296
+ ```bash
297
+ # Build TypeScript
298
+ npm run build
424
299
 
425
- # Avec options
426
- npm run dev -- --engine box --limit 10
427
- npm run dev -- --engine s3 --limit 100
300
+ # Watch mode
301
+ npm run dev
428
302
  ```
429
303
 
430
- Chaque connecteur a sa propre documentation détaillée avec :
431
- - ✅ Instructions de configuration
432
- - 🔑 Obtention des tokens/credentials
433
- - ⚙️ Paramètres supportés
434
- - 🛠️ Troubleshooting
435
- - 📋 Bonnes pratiques
304
+ ---
436
305
 
437
- ### Configuration des tokens
306
+ ## 📖 Documentation Complète
438
307
 
439
- #### Option 1: Interface interactive
440
- ```bash
441
- npm run dev -- --engine onedrive
442
- # Le système demande automatiquement les paramètres requis
443
- ```
308
+ - **[Configuration Détaillée](./docs/configuration.md)** : OAuth2, env vars, troubleshooting
309
+ - **[Système de Permissions](./docs/permissions.md)** : Format, exemples, cas d'usage
310
+ - **[Gestion des Metadata](./docs/metadata.md)** : Format simplifié, objets imbriqués
311
+ - **[Exemples Pratiques](./docs/examples.md)** : Scripts, automatisation, cron jobs
444
312
 
445
- #### Option 2: Fichiers de configuration
446
- ```bash
447
- # Créer onedrive-config.json
448
- {
449
- "accessToken": "votre_token_graph_explorer",
450
- "limit": 10
451
- }
452
-
453
- # Créer core-config.json
454
- {
455
- "baseUrl": "https://votre-instance.core.fr",
456
- "bearerToken": "votre_token_depuis_/users/token",
457
- "limit": 10
458
- }
459
- ```
313
+ ---
460
314
 
461
- ### 🔑 Guide détaillé d'obtention des tokens
462
-
463
- #### **Core Token (le plus simple)**
464
- 1. 🌐 Ouvrez votre instance Core : `https://rec.plugandwork.fr` (ou votre URL)
465
- 2. 🔐 Connectez-vous avec vos identifiants
466
- 3. 📍 Naviguez vers : `https://rec.plugandwork.fr/users/token`
467
- 4. 📋 Copiez le token Bearer affiché sur la page
468
-
469
- #### **OneDrive Token (Graph Explorer)**
470
- 1. 🌐 Ouvrez [Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer)
471
- 2. 🔐 Cliquez "Sign in to Graph Explorer"
472
- 3. 🔑 Connectez-vous avec votre compte Microsoft/Office 365
473
- 4. ⚙️ Cliquez sur l'onglet "Permissions"
474
- 5. ✅ Recherchez et demandez `Files.Read.All`
475
- 6. 🔄 Acceptez les permissions demandées
476
- 7. 📋 Copiez le token depuis l'en-tête `Authorization: Bearer ...`
477
-
478
- #### **Dropbox Token (App Console)**
479
- 1. 🌐 Ouvrez [Dropbox App Console](https://www.dropbox.com/developers/apps)
480
- 2. ➕ Créez une nouvelle app
481
- 3. 🔧 Choisissez "Scoped access" et "Full Dropbox"
482
- 4. ⚙️ Allez dans les settings de votre app
483
- 5. 🔑 Générez un "Access Token"
484
- 6. 📋 Copiez le token généré
485
-
486
- #### **Google Drive Token (plus complexe)**
487
- 1. 🌐 Ouvrez [Google Cloud Console](https://console.cloud.google.com/)
488
- 2. 📁 Créez un nouveau projet ou sélectionnez-en un
489
- 3. 🔧 Activez l'API Google Drive
490
- 4. 🔑 Créez des identifiants OAuth 2.0
491
- 5. ⚙️ Configurez les permissions et redirections
492
- 6. 🔄 Effectuez le flow OAuth2 pour obtenir un access token
493
-
494
- 💡 **Conseil** : Pour les tests, commencez par **Core** (le plus simple) ou **OneDrive** (Graph Explorer).
495
-
496
- ### Utilisation avancée
315
+ ## 🤝 Support & Contributions
497
316
 
498
- ```bash
499
- # Lister les plugins disponibles
500
- npm run dev -- plugins
317
+ ### Signaler un Bug
501
318
 
502
- # Configurer une connexion manuellement
503
- npm run dev -- connect onedrive --interactive
319
+ [Ouvrir une issue](https://github.com/your-org/hubdoc-tools/issues)
504
320
 
505
- # Scanner une source externe
506
- npm run dev -- plugin-scan connection-id --limit 5
321
+ ### Proposer une Fonctionnalité
507
322
 
508
- # Importer depuis une source externe
509
- npm run dev -- plugin-import mapping.csv
510
- ```
323
+ [Créer une Feature Request](https://github.com/your-org/hubdoc-tools/issues/new?template=feature_request.md)
511
324
 
512
- ## Project Structure
325
+ ### Contribuer
513
326
 
514
- ```
515
- hubdoc-tools/
516
- ├── src/
517
- │ ├── commands/ # Import commands
518
- │ ├── services/ # HubDoc API integration
519
- │ ├── types/ # TypeScript type definitions
520
- │ ├── utils/ # Utilities (CSV, config)
521
- │ └── cli.ts # Main CLI entry point
522
- ├── plugins/ # External source plugins
523
- │ ├── core/ # Core DMS plugin
524
- │ ├── onedrive/ # OneDrive plugin
525
- │ ├── googledrive/ # Google Drive plugin
526
- │ ├── dropbox/ # Dropbox plugin
527
- │ ├── box/ # Box cloud storage plugin
528
- │ ├── aws-s3/ # AWS S3 plugin
529
- │ ├── azure-blob/ # Azure Blob Storage plugin
530
- │ ├── alfresco/ # Alfresco ECM plugin
531
- │ ├── sharepoint/ # SharePoint Online plugin
532
- │ ├── nuxeo/ # Nuxeo ECM plugin
533
- │ └── opentext/ # OpenText Content Server plugin
534
- ├── package.json
535
- ├── tsconfig.json
536
- └── README-hubdoc-tool.md # Detailed documentation
537
- ```
327
+ 1. Fork le repo
328
+ 2. Créer une branche : `git checkout -b feature/amazing-feature`
329
+ 3. Commit : `git commit -m 'Add amazing feature'`
330
+ 4. Push : `git push origin feature/amazing-feature`
331
+ 5. Ouvrir une Pull Request
332
+
333
+ ---
334
+
335
+ ## 📄 Licence
336
+
337
+ MIT © [Sinoia]
338
+
339
+ ---
538
340
 
539
- ## Contributing
341
+ ## 🎯 Roadmap
540
342
 
541
- This project is part of the Sinoia CoreX ecosystem for HubDoc document management.
343
+ - [ ] Support Azure Blob Storage
344
+ - [ ] Support Dropbox
345
+ - [ ] Interface Web (dashboard)
346
+ - [ ] Webhooks pour import temps-réel
347
+ - [ ] API REST pour intégrations
348
+ - [ ] Support multi-tenant
542
349
 
543
- ## License
350
+ ---
544
351
 
545
- MIT License
352
+ **Made with ❤️ by Sinoia**