@memberjunction/storage 2.38.0 → 2.40.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.
Files changed (38) hide show
  1. package/dist/drivers/AWSFileStorage.d.ts +360 -4
  2. package/dist/drivers/AWSFileStorage.d.ts.map +1 -1
  3. package/dist/drivers/AWSFileStorage.js +357 -4
  4. package/dist/drivers/AWSFileStorage.js.map +1 -1
  5. package/dist/drivers/AzureFileStorage.d.ts +362 -2
  6. package/dist/drivers/AzureFileStorage.d.ts.map +1 -1
  7. package/dist/drivers/AzureFileStorage.js +357 -2
  8. package/dist/drivers/AzureFileStorage.js.map +1 -1
  9. package/dist/drivers/BoxFileStorage.d.ts +539 -20
  10. package/dist/drivers/BoxFileStorage.d.ts.map +1 -1
  11. package/dist/drivers/BoxFileStorage.js +521 -20
  12. package/dist/drivers/BoxFileStorage.js.map +1 -1
  13. package/dist/drivers/DropboxFileStorage.d.ts +437 -15
  14. package/dist/drivers/DropboxFileStorage.d.ts.map +1 -1
  15. package/dist/drivers/DropboxFileStorage.js +431 -15
  16. package/dist/drivers/DropboxFileStorage.js.map +1 -1
  17. package/dist/drivers/GoogleDriveFileStorage.d.ts +342 -16
  18. package/dist/drivers/GoogleDriveFileStorage.d.ts.map +1 -1
  19. package/dist/drivers/GoogleDriveFileStorage.js +340 -16
  20. package/dist/drivers/GoogleDriveFileStorage.js.map +1 -1
  21. package/dist/drivers/GoogleFileStorage.d.ts +358 -2
  22. package/dist/drivers/GoogleFileStorage.d.ts.map +1 -1
  23. package/dist/drivers/GoogleFileStorage.js +356 -2
  24. package/dist/drivers/GoogleFileStorage.js.map +1 -1
  25. package/dist/drivers/SharePointFileStorage.d.ts +434 -20
  26. package/dist/drivers/SharePointFileStorage.d.ts.map +1 -1
  27. package/dist/drivers/SharePointFileStorage.js +453 -22
  28. package/dist/drivers/SharePointFileStorage.js.map +1 -1
  29. package/dist/generic/FileStorageBase.d.ts +326 -108
  30. package/dist/generic/FileStorageBase.d.ts.map +1 -1
  31. package/dist/generic/FileStorageBase.js +54 -6
  32. package/dist/generic/FileStorageBase.js.map +1 -1
  33. package/dist/util.d.ts +125 -18
  34. package/dist/util.d.ts.map +1 -1
  35. package/dist/util.js +125 -18
  36. package/dist/util.js.map +1 -1
  37. package/package.json +4 -4
  38. package/readme.md +211 -1
@@ -37,12 +37,79 @@ const global_1 = require("@memberjunction/global");
37
37
  const env = __importStar(require("env-var"));
38
38
  const mime = __importStar(require("mime-types"));
39
39
  const FileStorageBase_1 = require("../generic/FileStorageBase");
40
+ /**
41
+ * FileStorageBase implementation for Box.com cloud storage
42
+ *
43
+ * This provider allows working with files stored in Box.com. It supports
44
+ * authentication via access token, refresh token, or client credentials (JWT).
45
+ *
46
+ * @remarks
47
+ * This implementation requires at least one of the following authentication methods:
48
+ *
49
+ * 1. Access Token:
50
+ * - STORAGE_BOX_ACCESS_TOKEN - A valid Box API access token
51
+ *
52
+ * 2. Refresh Token:
53
+ * - STORAGE_BOX_REFRESH_TOKEN - A valid Box API refresh token
54
+ * - STORAGE_BOX_CLIENT_ID - Your Box application client ID
55
+ * - STORAGE_BOX_CLIENT_SECRET - Your Box application client secret
56
+ *
57
+ * 3. Client Credentials (JWT):
58
+ * - STORAGE_BOX_CLIENT_ID - Your Box application client ID
59
+ * - STORAGE_BOX_CLIENT_SECRET - Your Box application client secret
60
+ * - STORAGE_BOX_ENTERPRISE_ID - Your Box enterprise ID
61
+ *
62
+ * Optional configuration:
63
+ * - STORAGE_BOX_ROOT_FOLDER_ID - ID of a Box folder to use as the root (defaults to '0' which is the root)
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Set required environment variables for JWT auth
68
+ * process.env.STORAGE_BOX_CLIENT_ID = 'your-client-id';
69
+ * process.env.STORAGE_BOX_CLIENT_SECRET = 'your-client-secret';
70
+ * process.env.STORAGE_BOX_ENTERPRISE_ID = 'your-enterprise-id';
71
+ *
72
+ * // Create the provider
73
+ * const storage = new BoxFileStorage();
74
+ * await storage.initialize(); // Required for JWT auth
75
+ *
76
+ * // Upload a file
77
+ * const fileContent = Buffer.from('Hello, Box!');
78
+ * await storage.PutObject('documents/hello.txt', fileContent, 'text/plain');
79
+ *
80
+ * // Download a file
81
+ * const downloadedContent = await storage.GetObject('documents/hello.txt');
82
+ *
83
+ * // Get a temporary download URL
84
+ * const downloadUrl = await storage.CreatePreAuthDownloadUrl('documents/hello.txt');
85
+ * ```
86
+ */
40
87
  let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageBase {
88
+ /**
89
+ * Creates a new BoxFileStorage instance
90
+ *
91
+ * This constructor reads the required Box authentication configuration
92
+ * from environment variables.
93
+ *
94
+ * @throws Error if refresh token is provided without client ID and secret
95
+ */
41
96
  constructor() {
42
97
  super();
98
+ /**
99
+ * The name of this storage provider
100
+ */
43
101
  this.providerName = 'Box';
102
+ /**
103
+ * Timestamp when current access token expires
104
+ */
44
105
  this._tokenExpiresAt = 0;
106
+ /**
107
+ * Base URL for Box API
108
+ */
45
109
  this._baseApiUrl = 'https://api.box.com/2.0';
110
+ /**
111
+ * Base URL for Box Upload API
112
+ */
46
113
  this._uploadApiUrl = 'https://upload.box.com/api/2.0';
47
114
  // Box auth can be via access token or refresh token
48
115
  this._accessToken = env.get('STORAGE_BOX_ACCESS_TOKEN').asString();
@@ -57,14 +124,36 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
57
124
  this._rootFolderId = env.get('STORAGE_BOX_ROOT_FOLDER_ID').default('0').asString();
58
125
  }
59
126
  /**
60
- * Initialize the storage driver by setting up the access token
61
- * This should be called after construction
127
+ * Initializes the Box storage driver
128
+ *
129
+ * This method must be called after creating a BoxFileStorage instance
130
+ * when using client credentials (JWT) authentication. It obtains the
131
+ * initial access token required for API calls.
132
+ *
133
+ * @returns A Promise that resolves when initialization is complete
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const storage = new BoxFileStorage();
138
+ * await storage.initialize();
139
+ * // Now the storage provider is ready to use
140
+ * ```
62
141
  */
63
142
  async initialize() {
64
143
  if (!this._accessToken && this._clientId && this._clientSecret && this._enterpriseId) {
65
144
  await this._setAccessToken();
66
145
  }
67
146
  }
147
+ /**
148
+ * Obtains an access token using client credentials flow
149
+ *
150
+ * This method requests a new access token using the Box client credentials
151
+ * flow (JWT) with the enterprise as the subject.
152
+ *
153
+ * @private
154
+ * @returns A Promise that resolves when the access token is obtained
155
+ * @throws Error if token acquisition fails
156
+ */
68
157
  async _setAccessToken() {
69
158
  try {
70
159
  const response = await fetch('https://api.box.com/oauth2/token', {
@@ -94,7 +183,14 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
94
183
  }
95
184
  }
96
185
  /**
97
- * Ensures we have a valid access token
186
+ * Ensures a valid access token is available for API requests
187
+ *
188
+ * This method checks if the current token is valid, and if not, attempts
189
+ * to refresh or obtain a new token using the configured authentication method.
190
+ *
191
+ * @private
192
+ * @returns A Promise that resolves to a valid access token
193
+ * @throws Error if no valid token can be obtained
98
194
  */
99
195
  async _ensureValidToken() {
100
196
  // If we have a valid token, use it
@@ -149,7 +245,19 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
149
245
  throw new Error('No valid Box access token available and no authentication method configured');
150
246
  }
151
247
  /**
152
- * Make an authenticated API request to Box
248
+ * Makes an authenticated API request to the Box API
249
+ *
250
+ * This helper method handles authentication, request formatting, and
251
+ * response parsing for all Box API calls.
252
+ *
253
+ * @private
254
+ * @param endpoint - The API endpoint to call (e.g., '/files/123')
255
+ * @param method - The HTTP method to use (default: 'GET')
256
+ * @param body - Optional request body (will be serialized as JSON unless it's FormData)
257
+ * @param headers - Optional additional headers
258
+ * @param baseUrl - Base URL to use (defaults to standard API URL)
259
+ * @returns A Promise that resolves to the API response data
260
+ * @throws Error if the API request fails
153
261
  */
154
262
  async _apiRequest(endpoint, method = 'GET', body, headers = {}, baseUrl = this._baseApiUrl) {
155
263
  const token = await this._ensureValidToken();
@@ -182,7 +290,14 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
182
290
  return data;
183
291
  }
184
292
  /**
185
- * Parse a Box API path into folder ID and name components
293
+ * Parses a path string into Box API components
294
+ *
295
+ * This helper method converts a standard path string (e.g., 'documents/reports/file.txt')
296
+ * into components used by the Box API (folder ID, name, parent path).
297
+ *
298
+ * @private
299
+ * @param path - The path to parse
300
+ * @returns An object containing the parsed components: id, name, and parent
186
301
  */
187
302
  _parsePath(path) {
188
303
  // Default to root folder
@@ -206,7 +321,15 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
206
321
  return { id: '', name, parent };
207
322
  }
208
323
  /**
209
- * Get item ID by path
324
+ * Resolves a path string to a Box item ID
325
+ *
326
+ * This helper method navigates the Box folder hierarchy to find
327
+ * the item at the specified path, returning its Box ID.
328
+ *
329
+ * @private
330
+ * @param path - The path to resolve
331
+ * @returns A Promise that resolves to the Box item ID
332
+ * @throws Error if the item does not exist
210
333
  */
211
334
  async _getIdFromPath(path) {
212
335
  const parsedPath = this._parsePath(path);
@@ -234,7 +357,15 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
234
357
  return item.id;
235
358
  }
236
359
  /**
237
- * Convert Box item to StorageObjectMetadata
360
+ * Converts a Box API item to StorageObjectMetadata
361
+ *
362
+ * This helper method transforms a Box API item representation into
363
+ * the standard StorageObjectMetadata format used by FileStorageBase.
364
+ *
365
+ * @private
366
+ * @param item - The Box API item object
367
+ * @param parentPath - The parent path string
368
+ * @returns A StorageObjectMetadata object
238
369
  */
239
370
  _convertToMetadata(item, parentPath = '') {
240
371
  const isDirectory = item.type === 'folder';
@@ -260,7 +391,42 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
260
391
  };
261
392
  }
262
393
  /**
263
- * Create a pre-authenticated upload URL
394
+ * Creates a pre-authenticated upload URL for a file
395
+ *
396
+ * This method creates a Box upload session and returns a URL that can be used
397
+ * to upload file content directly to Box without requiring authentication.
398
+ *
399
+ * @param objectName - Path where the file should be uploaded (e.g., 'documents/report.pdf')
400
+ * @returns A Promise that resolves to an object containing the upload URL and provider key
401
+ * @throws Error if the URL creation fails
402
+ *
403
+ * @remarks
404
+ * - The parent folder structure will be created automatically if it doesn't exist
405
+ * - The returned provider key contains the session ID needed to complete the upload
406
+ * - Box upload sessions expire after a certain period (typically 1 hour)
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * try {
411
+ * // Generate a pre-authenticated upload URL
412
+ * const uploadInfo = await storage.CreatePreAuthUploadUrl('presentations/quarterly-results.pptx');
413
+ *
414
+ * // The URL can be used to upload content directly
415
+ * console.log(`Upload URL: ${uploadInfo.UploadUrl}`);
416
+ *
417
+ * // Make sure to save the provider key, as it's needed to reference the upload
418
+ * console.log(`Provider Key: ${uploadInfo.ProviderKey}`);
419
+ *
420
+ * // You can use fetch or another HTTP client to upload to this URL
421
+ * await fetch(uploadInfo.UploadUrl, {
422
+ * method: 'PUT',
423
+ * headers: { 'Content-Type': 'application/octet-stream' },
424
+ * body: fileContent
425
+ * });
426
+ * } catch (error) {
427
+ * console.error('Error creating upload URL:', error.message);
428
+ * }
429
+ * ```
264
430
  */
265
431
  async CreatePreAuthUploadUrl(objectName) {
266
432
  try {
@@ -297,7 +463,34 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
297
463
  }
298
464
  }
299
465
  /**
300
- * Create a pre-authenticated download URL
466
+ * Creates a pre-authenticated download URL for a file
467
+ *
468
+ * This method generates a time-limited URL that can be used to download
469
+ * a file without authentication. The URL typically expires after 60 minutes.
470
+ *
471
+ * @param objectName - Path to the file to download (e.g., 'documents/report.pdf')
472
+ * @returns A Promise that resolves to the download URL string
473
+ * @throws Error if the file doesn't exist or URL creation fails
474
+ *
475
+ * @remarks
476
+ * - Cannot be used with upload sessions that haven't been completed
477
+ * - Box download URLs typically expire after 60 minutes
478
+ * - Generated URLs can be shared with users who don't have Box access
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * try {
483
+ * // Generate a pre-authenticated download URL
484
+ * const downloadUrl = await storage.CreatePreAuthDownloadUrl('documents/financial-report.pdf');
485
+ *
486
+ * console.log(`Download the file using this URL: ${downloadUrl}`);
487
+ *
488
+ * // The URL can be shared or used in a browser to download the file
489
+ * // without requiring Box authentication
490
+ * } catch (error) {
491
+ * console.error('Error creating download URL:', error.message);
492
+ * }
493
+ * ```
301
494
  */
302
495
  async CreatePreAuthDownloadUrl(objectName) {
303
496
  try {
@@ -320,7 +513,34 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
320
513
  }
321
514
  }
322
515
  /**
323
- * Move an object
516
+ * Moves a file or folder from one location to another
517
+ *
518
+ * This method moves a file or folder to a new location in Box storage.
519
+ * It handles both renaming and changing the parent folder.
520
+ *
521
+ * @param oldObjectName - Current path of the object (e.g., 'old-folder/document.docx')
522
+ * @param newObjectName - New path for the object (e.g., 'new-folder/renamed-document.docx')
523
+ * @returns A Promise that resolves to true if successful, false otherwise
524
+ *
525
+ * @remarks
526
+ * - Parent folders will be created automatically if they don't exist
527
+ * - Works with both files and folders
528
+ * - For folders, all contents will move with the folder
529
+ *
530
+ * @example
531
+ * ```typescript
532
+ * // Move a file to a different folder and rename it
533
+ * const moveResult = await storage.MoveObject(
534
+ * 'documents/old-report.pdf',
535
+ * 'archive/2023/annual-report.pdf'
536
+ * );
537
+ *
538
+ * if (moveResult) {
539
+ * console.log('File moved successfully');
540
+ * } else {
541
+ * console.error('Failed to move file');
542
+ * }
543
+ * ```
324
544
  */
325
545
  async MoveObject(oldObjectName, newObjectName) {
326
546
  try {
@@ -354,7 +574,34 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
354
574
  }
355
575
  }
356
576
  /**
357
- * Delete an object
577
+ * Deletes a file or folder from Box storage
578
+ *
579
+ * This method permanently deletes a file or folder. It can also
580
+ * handle special cases like incomplete upload sessions.
581
+ *
582
+ * @param objectName - Path to the object to delete (e.g., 'documents/old-report.docx')
583
+ * @returns A Promise that resolves to true if successful, false if an error occurs
584
+ *
585
+ * @remarks
586
+ * - Returns true if the object doesn't exist (for idempotency)
587
+ * - Can handle special provider keys like upload sessions
588
+ * - Box puts deleted items in the trash, where they can be recovered for a limited time
589
+ * - To permanently delete folder contents, use DeleteDirectory with recursive=true
590
+ *
591
+ * @example
592
+ * ```typescript
593
+ * // Delete a file
594
+ * const deleteResult = await storage.DeleteObject('temp/draft-document.docx');
595
+ *
596
+ * if (deleteResult) {
597
+ * console.log('File deleted successfully or already didn\'t exist');
598
+ * } else {
599
+ * console.error('Failed to delete file');
600
+ * }
601
+ *
602
+ * // Delete an upload session
603
+ * await storage.DeleteObject('session:1234567890:documents/large-file.zip');
604
+ * ```
358
605
  */
359
606
  async DeleteObject(objectName) {
360
607
  try {
@@ -381,7 +628,38 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
381
628
  }
382
629
  }
383
630
  /**
384
- * List objects in a directory
631
+ * Lists files and folders in a given directory
632
+ *
633
+ * This method retrieves all files and subfolders in the specified directory.
634
+ * It returns both a list of object metadata and a list of directory prefixes.
635
+ *
636
+ * @param prefix - Path to the directory to list (e.g., 'documents/reports')
637
+ * @param delimiter - Optional delimiter character (default: '/')
638
+ * @returns A Promise that resolves to a StorageListResult containing objects and prefixes
639
+ *
640
+ * @remarks
641
+ * - The `objects` array includes both files and folders
642
+ * - The `prefixes` array includes only folder paths (with trailing slashes)
643
+ * - Returns empty arrays if the directory doesn't exist
644
+ * - The delimiter parameter is included for interface compatibility but not used internally
645
+ *
646
+ * @example
647
+ * ```typescript
648
+ * // List all files and folders in the 'documents' directory
649
+ * const result = await storage.ListObjects('documents');
650
+ *
651
+ * // Process files and folders
652
+ * console.log(`Found ${result.objects.length} items:`);
653
+ * for (const obj of result.objects) {
654
+ * console.log(`- ${obj.name} (${obj.isDirectory ? 'Folder' : 'File'}, ${obj.size} bytes)`);
655
+ * }
656
+ *
657
+ * // List subfolders only
658
+ * console.log(`Found ${result.prefixes.length} subfolders:`);
659
+ * for (const prefix of result.prefixes) {
660
+ * console.log(`- ${prefix}`);
661
+ * }
662
+ * ```
385
663
  */
386
664
  async ListObjects(prefix, delimiter = '/') {
387
665
  try {
@@ -418,7 +696,37 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
418
696
  }
419
697
  }
420
698
  /**
421
- * Create a directory
699
+ * Creates a new directory (folder) in Box storage
700
+ *
701
+ * This method creates a folder at the specified path, automatically
702
+ * creating any parent folders that don't exist.
703
+ *
704
+ * @param directoryPath - Path where the directory should be created (e.g., 'documents/reports/2023')
705
+ * @returns A Promise that resolves to true if successful, false if an error occurs
706
+ *
707
+ * @remarks
708
+ * - Creates parent directories recursively if they don't exist
709
+ * - Returns true if the directory already exists (idempotent operation)
710
+ * - Trailing slashes in the path are automatically removed
711
+ *
712
+ * @example
713
+ * ```typescript
714
+ * // Create a nested directory structure
715
+ * const createResult = await storage.CreateDirectory('documents/reports/2023/Q1');
716
+ *
717
+ * if (createResult) {
718
+ * console.log('Directory created successfully');
719
+ *
720
+ * // Now we can put files in this directory
721
+ * await storage.PutObject(
722
+ * 'documents/reports/2023/Q1/financial-summary.xlsx',
723
+ * fileContent,
724
+ * 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
725
+ * );
726
+ * } else {
727
+ * console.error('Failed to create directory');
728
+ * }
729
+ * ```
422
730
  */
423
731
  async CreateDirectory(directoryPath) {
424
732
  try {
@@ -460,7 +768,35 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
460
768
  }
461
769
  }
462
770
  /**
463
- * Delete a directory
771
+ * Deletes a directory from Box storage
772
+ *
773
+ * This method deletes a folder and optionally its contents. By default,
774
+ * it will only delete empty folders unless recursive is set to true.
775
+ *
776
+ * @param directoryPath - Path to the directory to delete (e.g., 'documents/old-reports')
777
+ * @param recursive - If true, delete the directory and all its contents; if false, only delete if empty
778
+ * @returns A Promise that resolves to true if successful, false if an error occurs
779
+ *
780
+ * @remarks
781
+ * - Returns true if the directory doesn't exist (idempotent operation)
782
+ * - If recursive=false and the directory contains files, the operation will fail
783
+ * - Box puts deleted folders in the trash, where they can be recovered for a limited time
784
+ * - Trailing slashes in the path are automatically removed
785
+ *
786
+ * @example
787
+ * ```typescript
788
+ * // Try to delete an empty folder
789
+ * const deleteResult = await storage.DeleteDirectory('temp/empty-folder');
790
+ *
791
+ * // Delete a folder and all its contents
792
+ * const recursiveDeleteResult = await storage.DeleteDirectory('archive/old-data', true);
793
+ *
794
+ * if (recursiveDeleteResult) {
795
+ * console.log('Folder and all its contents deleted successfully');
796
+ * } else {
797
+ * console.error('Failed to delete folder');
798
+ * }
799
+ * ```
464
800
  */
465
801
  async DeleteDirectory(directoryPath, recursive = false) {
466
802
  try {
@@ -502,7 +838,34 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
502
838
  }
503
839
  }
504
840
  /**
505
- * Get object metadata
841
+ * Gets metadata for a file or folder
842
+ *
843
+ * This method retrieves metadata about a file or folder in Box storage,
844
+ * such as size, type, and modification date.
845
+ *
846
+ * @param objectName - Path to the object to get metadata for (e.g., 'documents/report.pdf')
847
+ * @returns A Promise that resolves to a StorageObjectMetadata object
848
+ * @throws Error if the object doesn't exist or cannot be accessed
849
+ *
850
+ * @example
851
+ * ```typescript
852
+ * try {
853
+ * // Get metadata for a file
854
+ * const metadata = await storage.GetObjectMetadata('presentations/quarterly-update.pptx');
855
+ *
856
+ * console.log(`Name: ${metadata.name}`);
857
+ * console.log(`Path: ${metadata.path}`);
858
+ * console.log(`Size: ${metadata.size} bytes`);
859
+ * console.log(`Content Type: ${metadata.contentType}`);
860
+ * console.log(`Last Modified: ${metadata.lastModified}`);
861
+ * console.log(`Is Directory: ${metadata.isDirectory}`);
862
+ *
863
+ * // Box-specific metadata is available in customMetadata
864
+ * console.log(`Box ID: ${metadata.customMetadata.id}`);
865
+ * } catch (error) {
866
+ * console.error('Error getting metadata:', error.message);
867
+ * }
868
+ * ```
506
869
  */
507
870
  async GetObjectMetadata(objectName) {
508
871
  try {
@@ -524,7 +887,35 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
524
887
  }
525
888
  }
526
889
  /**
527
- * Get an object's contents
890
+ * Downloads a file's contents
891
+ *
892
+ * This method retrieves the raw content of a file as a Buffer.
893
+ *
894
+ * @param objectName - Path to the file to download (e.g., 'documents/report.pdf')
895
+ * @returns A Promise that resolves to a Buffer containing the file's contents
896
+ * @throws Error if the file doesn't exist or cannot be downloaded
897
+ *
898
+ * @remarks
899
+ * - This method will throw an error if the object is a folder
900
+ * - For large files, consider using CreatePreAuthDownloadUrl instead
901
+ * - For upload sessions that haven't been completed, this method will fail
902
+ *
903
+ * @example
904
+ * ```typescript
905
+ * try {
906
+ * // Download a text file
907
+ * const fileContent = await storage.GetObject('documents/notes.txt');
908
+ *
909
+ * // Convert Buffer to string for text files
910
+ * const textContent = fileContent.toString('utf8');
911
+ * console.log('File content:', textContent);
912
+ *
913
+ * // For binary files, you can write the buffer to disk
914
+ * // or process it as needed
915
+ * } catch (error) {
916
+ * console.error('Error downloading file:', error.message);
917
+ * }
918
+ * ```
528
919
  */
529
920
  async GetObject(objectName) {
530
921
  try {
@@ -541,7 +932,47 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
541
932
  }
542
933
  }
543
934
  /**
544
- * Upload an object
935
+ * Uploads a file to Box storage
936
+ *
937
+ * This method uploads a file to the specified path in Box storage. It automatically
938
+ * determines whether to use a simple upload or chunked upload based on file size.
939
+ *
940
+ * @param objectName - Path where the file should be uploaded (e.g., 'documents/report.pdf')
941
+ * @param data - Buffer containing the file content
942
+ * @param contentType - Optional MIME type of the file (if not provided, it will be guessed from the filename)
943
+ * @param metadata - Optional metadata to associate with the file (not used in Box implementation)
944
+ * @returns A Promise that resolves to true if successful, false if an error occurs
945
+ *
946
+ * @remarks
947
+ * - Automatically creates parent directories if they don't exist
948
+ * - Files smaller than 50MB use a simple upload
949
+ * - Files 50MB or larger use a chunked upload process
950
+ * - If a file with the same name exists, it will be replaced
951
+ *
952
+ * @example
953
+ * ```typescript
954
+ * // Create a simple text file
955
+ * const textContent = Buffer.from('This is a sample document', 'utf8');
956
+ * const uploadResult = await storage.PutObject(
957
+ * 'documents/sample.txt',
958
+ * textContent,
959
+ * 'text/plain'
960
+ * );
961
+ *
962
+ * // Upload a large file using chunked upload
963
+ * const largeFileBuffer = fs.readFileSync('/path/to/large-presentation.pptx');
964
+ * const largeUploadResult = await storage.PutObject(
965
+ * 'presentations/quarterly-results.pptx',
966
+ * largeFileBuffer,
967
+ * 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
968
+ * );
969
+ *
970
+ * if (largeUploadResult) {
971
+ * console.log('Large file uploaded successfully');
972
+ * } else {
973
+ * console.error('Failed to upload large file');
974
+ * }
975
+ * ```
545
976
  */
546
977
  async PutObject(objectName, data, contentType, metadata) {
547
978
  try {
@@ -625,7 +1056,34 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
625
1056
  }
626
1057
  }
627
1058
  /**
628
- * Copy an object
1059
+ * Copies a file from one location to another
1060
+ *
1061
+ * This method creates a copy of a file at a new location. The original file
1062
+ * remains unchanged.
1063
+ *
1064
+ * @param sourceObjectName - Path to the source file (e.g., 'templates/report-template.docx')
1065
+ * @param destinationObjectName - Path where the copy should be created (e.g., 'documents/new-report.docx')
1066
+ * @returns A Promise that resolves to true if successful, false if an error occurs
1067
+ *
1068
+ * @remarks
1069
+ * - Only files can be copied; folders cannot be copied with this method
1070
+ * - Parent directories in the destination path will be created automatically if they don't exist
1071
+ * - If a file with the same name exists at the destination, it will be replaced
1072
+ *
1073
+ * @example
1074
+ * ```typescript
1075
+ * // Copy a template file to a new location with a different name
1076
+ * const copyResult = await storage.CopyObject(
1077
+ * 'templates/financial-report.xlsx',
1078
+ * 'reports/2023/q1-financial-report.xlsx'
1079
+ * );
1080
+ *
1081
+ * if (copyResult) {
1082
+ * console.log('File copied successfully');
1083
+ * } else {
1084
+ * console.error('Failed to copy file');
1085
+ * }
1086
+ * ```
629
1087
  */
630
1088
  async CopyObject(sourceObjectName, destinationObjectName) {
631
1089
  try {
@@ -661,7 +1119,26 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
661
1119
  }
662
1120
  }
663
1121
  /**
664
- * Check if an object exists
1122
+ * Checks if a file or folder exists
1123
+ *
1124
+ * This method verifies whether an object (file or folder) exists at the specified path.
1125
+ *
1126
+ * @param objectName - Path to check (e.g., 'documents/report.pdf')
1127
+ * @returns A Promise that resolves to true if the object exists, false otherwise
1128
+ *
1129
+ * @example
1130
+ * ```typescript
1131
+ * // Check if a file exists before attempting to download it
1132
+ * const exists = await storage.ObjectExists('presentations/quarterly-update.pptx');
1133
+ *
1134
+ * if (exists) {
1135
+ * // File exists, proceed with download
1136
+ * const fileContent = await storage.GetObject('presentations/quarterly-update.pptx');
1137
+ * // Process the file...
1138
+ * } else {
1139
+ * console.log('File does not exist');
1140
+ * }
1141
+ * ```
665
1142
  */
666
1143
  async ObjectExists(objectName) {
667
1144
  try {
@@ -673,7 +1150,31 @@ let BoxFileStorage = class BoxFileStorage extends FileStorageBase_1.FileStorageB
673
1150
  }
674
1151
  }
675
1152
  /**
676
- * Check if a directory exists
1153
+ * Checks if a directory exists
1154
+ *
1155
+ * This method verifies whether a folder exists at the specified path.
1156
+ * Unlike ObjectExists, this method also checks that the item is a folder.
1157
+ *
1158
+ * @param directoryPath - Path to check (e.g., 'documents/reports')
1159
+ * @returns A Promise that resolves to true if the directory exists, false otherwise
1160
+ *
1161
+ * @remarks
1162
+ * - Returns false if the path exists but points to a file instead of a folder
1163
+ * - Trailing slashes in the path are automatically removed
1164
+ *
1165
+ * @example
1166
+ * ```typescript
1167
+ * // Check if a directory exists before creating a file in it
1168
+ * const dirExists = await storage.DirectoryExists('documents/reports');
1169
+ *
1170
+ * if (!dirExists) {
1171
+ * // Create the directory first
1172
+ * await storage.CreateDirectory('documents/reports');
1173
+ * }
1174
+ *
1175
+ * // Now we can safely put a file in this directory
1176
+ * await storage.PutObject('documents/reports/annual-summary.pdf', fileContent, 'application/pdf');
1177
+ * ```
677
1178
  */
678
1179
  async DirectoryExists(directoryPath) {
679
1180
  try {