@memberjunction/storage 3.2.0 → 3.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.
Files changed (36) hide show
  1. package/dist/__tests__/FileStorageBase.test.js +66 -5
  2. package/dist/__tests__/FileStorageBase.test.js.map +1 -1
  3. package/dist/drivers/AWSFileStorage.d.ts +26 -3
  4. package/dist/drivers/AWSFileStorage.d.ts.map +1 -1
  5. package/dist/drivers/AWSFileStorage.js +61 -4
  6. package/dist/drivers/AWSFileStorage.js.map +1 -1
  7. package/dist/drivers/AzureFileStorage.d.ts +26 -2
  8. package/dist/drivers/AzureFileStorage.d.ts.map +1 -1
  9. package/dist/drivers/AzureFileStorage.js +74 -2
  10. package/dist/drivers/AzureFileStorage.js.map +1 -1
  11. package/dist/drivers/BoxFileStorage.d.ts +19 -14
  12. package/dist/drivers/BoxFileStorage.d.ts.map +1 -1
  13. package/dist/drivers/BoxFileStorage.js +43 -15
  14. package/dist/drivers/BoxFileStorage.js.map +1 -1
  15. package/dist/drivers/DropboxFileStorage.d.ts +21 -3
  16. package/dist/drivers/DropboxFileStorage.d.ts.map +1 -1
  17. package/dist/drivers/DropboxFileStorage.js +43 -4
  18. package/dist/drivers/DropboxFileStorage.js.map +1 -1
  19. package/dist/drivers/GoogleDriveFileStorage.d.ts +21 -3
  20. package/dist/drivers/GoogleDriveFileStorage.d.ts.map +1 -1
  21. package/dist/drivers/GoogleDriveFileStorage.js +51 -4
  22. package/dist/drivers/GoogleDriveFileStorage.js.map +1 -1
  23. package/dist/drivers/GoogleFileStorage.d.ts +25 -1
  24. package/dist/drivers/GoogleFileStorage.d.ts.map +1 -1
  25. package/dist/drivers/GoogleFileStorage.js +78 -1
  26. package/dist/drivers/GoogleFileStorage.js.map +1 -1
  27. package/dist/drivers/SharePointFileStorage.d.ts +30 -5
  28. package/dist/drivers/SharePointFileStorage.d.ts.map +1 -1
  29. package/dist/drivers/SharePointFileStorage.js +59 -6
  30. package/dist/drivers/SharePointFileStorage.js.map +1 -1
  31. package/dist/generic/FileStorageBase.d.ts +77 -42
  32. package/dist/generic/FileStorageBase.d.ts.map +1 -1
  33. package/dist/generic/FileStorageBase.js +58 -36
  34. package/dist/generic/FileStorageBase.js.map +1 -1
  35. package/package.json +5 -5
  36. package/readme.md +103 -30
@@ -216,26 +216,41 @@ export declare class UnsupportedOperationError extends Error {
216
216
  * Configuration options for initializing a storage provider.
217
217
  * This interface defines the standard configuration that can be passed to initialize().
218
218
  *
219
- * In the enterprise model, every storage driver instance is associated with a
220
- * FileStorageAccount entity. The accountId is required to link the driver to
221
- * the specific organizational storage account it operates on behalf of.
219
+ * ## Usage Patterns
220
+ *
221
+ * ### Simple Deployment (Environment Variables)
222
+ * - Omit accountId when using environment variables
223
+ * - Constructor loads credentials automatically
224
+ * - Call initialize() with no config or empty object
225
+ *
226
+ * ### Multi-Tenant Enterprise (Database)
227
+ * - Provide accountId to link driver to FileStorageAccount
228
+ * - Include decrypted credentials from database
229
+ * - Or use initializeDriverWithAccountCredentials() utility
222
230
  */
223
231
  export interface StorageProviderConfig {
224
232
  /**
225
233
  * The ID of the FileStorageAccount entity this driver instance is operating for.
226
234
  * This links the driver to a specific organizational storage account.
227
235
  *
228
- * Required in the enterprise model - every driver instance must be associated
229
- * with a FileStorageAccount.
236
+ * **Optional**: Provide for multi-tenant mode to track account association.
237
+ * Omit for simple deployment using environment variables.
230
238
  */
231
- accountId: string;
239
+ accountId?: string;
232
240
  /**
233
241
  * The name of the account (for logging/display purposes).
242
+ *
243
+ * **Optional**: Useful for logging and debugging in multi-tenant scenarios.
234
244
  */
235
245
  accountName?: string;
236
246
  /**
237
247
  * Provider-specific configuration values (e.g., API keys, bucket names, etc.).
238
- * These are typically decrypted from the Credential entity at runtime.
248
+ *
249
+ * **Simple Deployment**: Not needed - constructor loads from environment variables.
250
+ * **Multi-Tenant**: Provide decrypted credentials from Credential entity.
251
+ *
252
+ * If provided, these values override the constructor defaults.
253
+ * If omitted, uses credentials already loaded by constructor.
239
254
  */
240
255
  [key: string]: unknown;
241
256
  }
@@ -654,52 +669,72 @@ export declare abstract class FileStorageBase {
654
669
  */
655
670
  abstract DirectoryExists(directoryPath: string): Promise<boolean>;
656
671
  /**
657
- * Initialization method for storage providers.
672
+ * Initialize storage provider with optional configuration.
658
673
  *
659
- * This method must be called before using the storage provider. It sets up the
660
- * account association and can be overridden by subclasses to perform provider-specific
661
- * initialization such as setting up access tokens, establishing connections, or
662
- * verifying permissions.
674
+ * ## Standard Usage Pattern
663
675
  *
664
- * The base implementation extracts and stores accountId and accountName from the config.
665
- * Subclass implementations should call super.initialize(config) first to ensure these
666
- * values are properly set before performing provider-specific initialization.
676
+ * **ALWAYS call this method** after creating a provider instance.
667
677
  *
668
- * @param config - Configuration object containing account information and provider-specific
669
- * settings. The accountId property is required and links this driver instance
670
- * to a specific FileStorageAccount entity. Additional provider-specific values
671
- * (e.g., API keys, bucket names) are typically decrypted from the associated
672
- * Credential entity.
678
+ * ### Simple Deployment (Environment Variables)
679
+ * Constructor loads credentials from environment variables, then call
680
+ * initialize() with no config to complete setup:
673
681
  *
674
- * @example
675
682
  * ```typescript
676
- * // In a specific provider implementation:
677
- * public async initialize(config: StorageProviderConfig): Promise<void> {
678
- * // Always call super first to set accountId and accountName
679
- * await super.initialize(config);
680
- *
681
- * // Then handle provider-specific configuration
682
- * if (config.accessToken) {
683
- * this._client = new ProviderClient({ accessToken: config.accessToken as string });
684
- * }
685
- * await this.verifyBucketAccess();
686
- * }
683
+ * // Set environment variables:
684
+ * // STORAGE_AWS_ACCESS_KEY_ID=...
685
+ * // STORAGE_AWS_SECRET_ACCESS_KEY=...
686
+ * // STORAGE_AWS_BUCKET_NAME=...
687
+ * // STORAGE_AWS_REGION=...
688
+ *
689
+ * const storage = new AWSFileStorage(); // Constructor loads env vars
690
+ * await storage.initialize(); // No config - uses env vars
691
+ * await storage.ListObjects('/'); // Ready to use
692
+ * ```
687
693
  *
688
- * // Usage:
689
- * const storage = new MyStorageProvider();
694
+ * ### Multi-Tenant Enterprise (Database)
695
+ * Constructor loads defaults, then call initialize() with configuration
696
+ * to override with database credentials and track account:
697
+ *
698
+ * ```typescript
699
+ * // Preferred: Use infrastructure utility
700
+ * const storage = await initializeDriverWithAccountCredentials({
701
+ * accountEntity,
702
+ * providerEntity,
703
+ * contextUser
704
+ * });
705
+ *
706
+ * // Alternative: Manual initialization
707
+ * const storage = new AWSFileStorage();
690
708
  * await storage.initialize({
691
- * accountId: 'F1234567-89AB-CDEF-0123-456789ABCDEF',
692
- * accountName: 'Company AWS S3 Storage',
693
- * accessKeyId: 'AKIA...',
694
- * secretAccessKey: '...',
695
- * bucket: 'my-bucket'
709
+ * accountId: account.id,
710
+ * accountName: account.name,
711
+ * accessKeyID: creds.accessKeyID,
712
+ * secretAccessKey: creds.secretAccessKey,
713
+ * region: creds.region,
714
+ * defaultBucket: creds.bucket
696
715
  * });
697
- * // Now the provider is ready to use
698
716
  * ```
699
717
  *
700
- * @returns A Promise that resolves when initialization is complete.
718
+ * ## How It Works
719
+ *
720
+ * - **No config**: Uses credentials already loaded by constructor from environment variables
721
+ * - **With config**: Overrides constructor credentials with provided values
722
+ * - **accountId**: Optional - provide for multi-tenant tracking
723
+ *
724
+ * ## Implementation Notes for Subclasses
725
+ *
726
+ * Subclass implementations should:
727
+ * 1. Call super.initialize(config) first to set accountId and accountName
728
+ * 2. Check if config is provided before attempting to override credentials
729
+ * 3. Only override values that are present in config
730
+ * 4. Reinitialize client/connection if credentials changed
731
+ *
732
+ * @param config - Optional configuration object
733
+ * - Omit for simple deployment (uses env vars from constructor)
734
+ * - Provide for multi-tenant (overrides with database credentials)
735
+ * @returns A Promise that resolves when initialization is complete
701
736
  */
702
- initialize(config: StorageProviderConfig): Promise<void>;
737
+ initialize(config?: StorageProviderConfig): Promise<void>;
703
738
  /**
704
739
  * Checks whether this storage provider is properly configured and ready to use.
705
740
  *
@@ -1 +1 @@
1
- {"version":3,"file":"FileStorageBase.d.ts","s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,MAAM,EAAE,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAErG;;;;;;;;;;;;;;;;;;;OAmBG;aACa,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAElE;;;;;;;;;;;;;;;;;;;OAmBG;aACa,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiEG;IACU,UAAU,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,aAAoB,YAAY,IAAI,OAAO,CAAC;IAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4DG;aACa,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CACtG"}
@@ -76,55 +76,77 @@ class FileStorageBase {
76
76
  throw new UnsupportedOperationError(methodName, this.providerName);
77
77
  }
78
78
  /**
79
- * Initialization method for storage providers.
79
+ * Initialize storage provider with optional configuration.
80
80
  *
81
- * This method must be called before using the storage provider. It sets up the
82
- * account association and can be overridden by subclasses to perform provider-specific
83
- * initialization such as setting up access tokens, establishing connections, or
84
- * verifying permissions.
81
+ * ## Standard Usage Pattern
85
82
  *
86
- * The base implementation extracts and stores accountId and accountName from the config.
87
- * Subclass implementations should call super.initialize(config) first to ensure these
88
- * values are properly set before performing provider-specific initialization.
83
+ * **ALWAYS call this method** after creating a provider instance.
89
84
  *
90
- * @param config - Configuration object containing account information and provider-specific
91
- * settings. The accountId property is required and links this driver instance
92
- * to a specific FileStorageAccount entity. Additional provider-specific values
93
- * (e.g., API keys, bucket names) are typically decrypted from the associated
94
- * Credential entity.
85
+ * ### Simple Deployment (Environment Variables)
86
+ * Constructor loads credentials from environment variables, then call
87
+ * initialize() with no config to complete setup:
95
88
  *
96
- * @example
97
89
  * ```typescript
98
- * // In a specific provider implementation:
99
- * public async initialize(config: StorageProviderConfig): Promise<void> {
100
- * // Always call super first to set accountId and accountName
101
- * await super.initialize(config);
90
+ * // Set environment variables:
91
+ * // STORAGE_AWS_ACCESS_KEY_ID=...
92
+ * // STORAGE_AWS_SECRET_ACCESS_KEY=...
93
+ * // STORAGE_AWS_BUCKET_NAME=...
94
+ * // STORAGE_AWS_REGION=...
102
95
  *
103
- * // Then handle provider-specific configuration
104
- * if (config.accessToken) {
105
- * this._client = new ProviderClient({ accessToken: config.accessToken as string });
106
- * }
107
- * await this.verifyBucketAccess();
108
- * }
96
+ * const storage = new AWSFileStorage(); // Constructor loads env vars
97
+ * await storage.initialize(); // No config - uses env vars
98
+ * await storage.ListObjects('/'); // Ready to use
99
+ * ```
100
+ *
101
+ * ### Multi-Tenant Enterprise (Database)
102
+ * Constructor loads defaults, then call initialize() with configuration
103
+ * to override with database credentials and track account:
104
+ *
105
+ * ```typescript
106
+ * // Preferred: Use infrastructure utility
107
+ * const storage = await initializeDriverWithAccountCredentials({
108
+ * accountEntity,
109
+ * providerEntity,
110
+ * contextUser
111
+ * });
109
112
  *
110
- * // Usage:
111
- * const storage = new MyStorageProvider();
113
+ * // Alternative: Manual initialization
114
+ * const storage = new AWSFileStorage();
112
115
  * await storage.initialize({
113
- * accountId: 'F1234567-89AB-CDEF-0123-456789ABCDEF',
114
- * accountName: 'Company AWS S3 Storage',
115
- * accessKeyId: 'AKIA...',
116
- * secretAccessKey: '...',
117
- * bucket: 'my-bucket'
116
+ * accountId: account.id,
117
+ * accountName: account.name,
118
+ * accessKeyID: creds.accessKeyID,
119
+ * secretAccessKey: creds.secretAccessKey,
120
+ * region: creds.region,
121
+ * defaultBucket: creds.bucket
118
122
  * });
119
- * // Now the provider is ready to use
120
123
  * ```
121
124
  *
122
- * @returns A Promise that resolves when initialization is complete.
125
+ * ## How It Works
126
+ *
127
+ * - **No config**: Uses credentials already loaded by constructor from environment variables
128
+ * - **With config**: Overrides constructor credentials with provided values
129
+ * - **accountId**: Optional - provide for multi-tenant tracking
130
+ *
131
+ * ## Implementation Notes for Subclasses
132
+ *
133
+ * Subclass implementations should:
134
+ * 1. Call super.initialize(config) first to set accountId and accountName
135
+ * 2. Check if config is provided before attempting to override credentials
136
+ * 3. Only override values that are present in config
137
+ * 4. Reinitialize client/connection if credentials changed
138
+ *
139
+ * @param config - Optional configuration object
140
+ * - Omit for simple deployment (uses env vars from constructor)
141
+ * - Provide for multi-tenant (overrides with database credentials)
142
+ * @returns A Promise that resolves when initialization is complete
123
143
  */
124
144
  async initialize(config) {
125
- // Extract and store account information from the config
126
- this._accountId = config.accountId;
127
- this._accountName = config.accountName;
145
+ // Extract and store account information from the config if provided
146
+ if (config) {
147
+ this._accountId = config.accountId;
148
+ this._accountName = config.accountName;
149
+ }
128
150
  }
129
151
  }
130
152
  exports.FileStorageBase = FileStorageBase;
@@ -1 +1 @@
1
- {"version":3,"file":"FileStorageBase.js","sourceRoot":"","sources":["../../src/generic/FileStorageBase.ts"],"names":[],"mappings":";;;AAkOA;;;;GAIG;AACH,MAAa,yBAA0B,SAAQ,KAAK;IAClD;;;;;OAKG;IACH,YAAY,UAAkB,EAAE,YAAoB;QAClD,KAAK,CAAC,cAAc,UAAU,6BAA6B,YAAY,WAAW,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAXD,8DAWC;AAgCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAsB,eAAe;IAOnC;;;OAGG;IACO,UAAU,CAAqB;IAEzC;;OAEG;IACO,YAAY,CAAqB;IAE3C;;;OAGG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiEG;IACI,KAAK,CAAC,UAAU,CAAC,MAA8B;QACpD,oEAAoE;QACpE,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;YACnC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC;QACzC,CAAC;IACH,CAAC;CA8GF;AAvlBD,0CAulBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/storage",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "This library provides a set of objects that handle the interface between the server-side API and various cloud storage providers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,10 +30,10 @@
30
30
  "@azure/identity": "^4.0.1",
31
31
  "@azure/storage-blob": "^12.17.0",
32
32
  "@google-cloud/storage": "^7.9.0",
33
- "@memberjunction/core": "3.2.0",
34
- "@memberjunction/core-entities": "3.2.0",
35
- "@memberjunction/credentials": "3.2.0",
36
- "@memberjunction/global": "3.2.0",
33
+ "@memberjunction/core": "3.4.0",
34
+ "@memberjunction/core-entities": "3.4.0",
35
+ "@memberjunction/credentials": "3.4.0",
36
+ "@memberjunction/global": "3.4.0",
37
37
  "@microsoft/mgt-element": "^3.1.3",
38
38
  "@microsoft/mgt-msal2-provider": "^3.1.3",
39
39
  "@microsoft/mgt-sharepoint-provider": "^3.1.3",
package/readme.md CHANGED
@@ -53,19 +53,71 @@ This package depends on:
53
53
 
54
54
  ## Usage
55
55
 
56
- ### Basic Setup
56
+ ### Standard Usage Pattern
57
57
 
58
- First, configure the environment variables required for your chosen storage provider(s). You can implement multiple providers simultaneously and switch between them based on your application requirements.
58
+ **CRITICAL**: Always follow these steps when using storage providers:
59
59
 
60
- Refer to the documentation for each storage provider for detailed configuration requirements (see the "Storage Provider Configuration" section below).
60
+ 1. Create provider instance
61
+ 2. **Call `initialize()`** (with or without config)
62
+ 3. Use provider
63
+
64
+ The `initialize()` method is smart enough to handle both simple deployments (environment variables) and multi-tenant deployments (database credentials).
65
+
66
+ ### Basic Setup - Simple Deployment (Environment Variables)
67
+
68
+ For single-tenant applications, development, testing, or simple production deployments:
61
69
 
62
- #### Azure Blob Storage Example
63
70
  ```bash
64
- STORAGE_AZURE_CONTAINER=your-container-name
65
- STORAGE_AZURE_ACCOUNT_NAME=your-account-name
66
- STORAGE_AZURE_ACCOUNT_KEY=your-account-key
71
+ # Example: Azure Blob Storage
72
+ export STORAGE_AZURE_CONTAINER=your-container-name
73
+ export STORAGE_AZURE_ACCOUNT_NAME=your-account-name
74
+ export STORAGE_AZURE_ACCOUNT_KEY=your-account-key
75
+ ```
76
+
77
+ ```typescript
78
+ import { AzureFileStorage } from '@memberjunction/storage';
79
+
80
+ // Constructor loads environment variables
81
+ const storage = new AzureFileStorage();
82
+
83
+ // ALWAYS call initialize() - no config needed for env var deployments
84
+ await storage.initialize();
85
+
86
+ // Provider is now ready to use
87
+ await storage.ListObjects('/');
88
+ ```
89
+
90
+ ### Multi-Tenant Enterprise (Database Credentials)
91
+
92
+ For enterprise applications managing multiple storage accounts:
93
+
94
+ ```typescript
95
+ import { FileStorageEngine } from '@memberjunction/core-entities';
96
+ import { initializeDriverWithAccountCredentials } from '@memberjunction/storage/util';
97
+
98
+ // Load account from database
99
+ const engine = FileStorageEngine.Instance;
100
+ await engine.Config(false, contextUser);
101
+
102
+ const accountWithProvider = engine.GetAccountWithProvider(accountId);
103
+
104
+ // Infrastructure utility handles credential decryption and initialization
105
+ const storage = await initializeDriverWithAccountCredentials({
106
+ accountEntity: accountWithProvider.account,
107
+ providerEntity: accountWithProvider.provider,
108
+ contextUser
109
+ });
110
+
111
+ // Provider is ready - credentials were automatically decrypted and initialized
112
+ await storage.ListObjects('/');
67
113
  ```
68
114
 
115
+ **Key Advantage**: The `initializeDriverWithAccountCredentials()` utility:
116
+ - Automatically retrieves the credential by ID
117
+ - Decrypts it using CredentialEngine
118
+ - Calls `initialize()` with the decrypted values
119
+ - Returns a fully configured provider instance
120
+
69
121
  ### Using Utility Functions (Recommended)
70
122
 
71
123
  The library provides high-level utility functions that work with MemberJunction's entity system:
@@ -119,27 +171,41 @@ async function fileOperationsExample() {
119
171
 
120
172
  ### Direct Provider Usage
121
173
 
122
- You can also work directly with a storage provider by instantiating it using the MemberJunction class factory:
174
+ You can work directly with a storage provider by instantiating it:
123
175
 
124
176
  ```typescript
125
177
  import { FileStorageBase } from '@memberjunction/storage';
126
178
  import { MJGlobal } from '@memberjunction/global';
127
179
 
128
180
  async function directProviderExample() {
129
- // Create storage instance using the class factory (recommended)
130
- const storage = MJGlobal.Instance.ClassFactory.CreateInstance<FileStorageBase>(
131
- FileStorageBase,
181
+ // Method 1: Direct instantiation (simple deployment with env vars)
182
+ const storage = new AzureFileStorage(); // Constructor loads env vars
183
+ await storage.initialize(); // ALWAYS call initialize()
184
+
185
+ // Method 2: Using class factory (dynamic provider selection)
186
+ const storage2 = MJGlobal.Instance.ClassFactory.CreateInstance<FileStorageBase>(
187
+ FileStorageBase,
132
188
  'Azure Blob Storage'
133
189
  );
134
-
135
- // Initialize the storage provider if needed
136
- await storage.initialize();
137
-
190
+ await storage2.initialize(); // ALWAYS call initialize()
191
+
192
+ // Method 3: Multi-tenant with manual initialization
193
+ const storage3 = new AzureFileStorage();
194
+ await storage3.initialize({
195
+ accountId: '12345',
196
+ accountName: 'Azure Account',
197
+ accountName: 'myaccount',
198
+ accountKey: '...',
199
+ defaultContainer: 'my-container'
200
+ });
201
+
202
+ // Now you can use any of the storage methods:
203
+
138
204
  // List all files in a directory
139
205
  const result = await storage.ListObjects('documents/');
140
206
  console.log('Files:', result.objects);
141
207
  console.log('Directories:', result.prefixes);
142
-
208
+
143
209
  // Display detailed metadata for each file
144
210
  for (const file of result.objects) {
145
211
  console.log(`\nFile: ${file.name}`);
@@ -150,54 +216,61 @@ async function directProviderExample() {
150
216
  console.log(` Modified: ${file.lastModified}`);
151
217
  console.log(` Is Directory: ${file.isDirectory}`);
152
218
  }
153
-
219
+
154
220
  // Create a directory
155
221
  const dirCreated = await storage.CreateDirectory('documents/reports/');
156
222
  console.log(`Directory created: ${dirCreated}`);
157
-
223
+
158
224
  // Upload a file directly with metadata
159
225
  const content = Buffer.from('Hello, World!');
160
226
  const uploaded = await storage.PutObject(
161
- 'documents/reports/hello.txt',
162
- content,
227
+ 'documents/reports/hello.txt',
228
+ content,
163
229
  'text/plain',
164
- {
230
+ {
165
231
  author: 'John Doe',
166
232
  department: 'Engineering',
167
- version: '1.0'
233
+ version: '1.0'
168
234
  }
169
235
  );
170
236
  console.log(`File uploaded: ${uploaded}`);
171
-
237
+
172
238
  // Get file metadata without downloading content
173
239
  const metadata = await storage.GetObjectMetadata('documents/reports/hello.txt');
174
240
  console.log('File metadata:', metadata);
175
-
241
+
176
242
  // Download file content
177
243
  const fileContent = await storage.GetObject('documents/reports/hello.txt');
178
244
  console.log('File content:', fileContent.toString('utf8'));
179
-
245
+
180
246
  // Copy a file
181
247
  const copied = await storage.CopyObject(
182
- 'documents/reports/hello.txt',
248
+ 'documents/reports/hello.txt',
183
249
  'documents/archive/hello-backup.txt'
184
250
  );
185
251
  console.log(`File copied: ${copied}`);
186
-
252
+
187
253
  // Check if a file exists
188
254
  const exists = await storage.ObjectExists('documents/reports/hello.txt');
189
255
  console.log(`File exists: ${exists}`);
190
-
256
+
191
257
  // Check if a directory exists
192
258
  const dirExists = await storage.DirectoryExists('documents/reports/');
193
259
  console.log(`Directory exists: ${dirExists}`);
194
-
260
+
195
261
  // Delete a directory and all its contents
196
262
  const dirDeleted = await storage.DeleteDirectory('documents/reports/', true);
197
263
  console.log(`Directory deleted: ${dirDeleted}`);
198
264
  }
199
265
  ```
200
266
 
267
+ ### Key Principle
268
+
269
+ **Always call `initialize()`** after creating a provider instance. It's smart enough to:
270
+ - Use environment variables when called with no config
271
+ - Override with database credentials when called with config
272
+ - Handle both simple and multi-tenant deployments seamlessly
273
+
201
274
  ### Searching Files
202
275
 
203
276
  Providers with native search capabilities support the `SearchFiles` method for finding files by name, content, and metadata:
@@ -345,6 +418,7 @@ type FileSearchResultSet = {
345
418
 
346
419
  All storage providers implement these methods:
347
420
 
421
+ - **`initialize(config?: StorageProviderConfig): Promise<void>`** - **REQUIRED**: Always call after creating instance. Omit config for env vars, provide config for multi-tenant.
348
422
  - `CreatePreAuthUploadUrl(objectName: string): Promise<CreatePreAuthUploadUrlPayload>`
349
423
  - `CreatePreAuthDownloadUrl(objectName: string): Promise<string>`
350
424
  - `MoveObject(oldObjectName: string, newObjectName: string): Promise<boolean>`
@@ -359,7 +433,6 @@ All storage providers implement these methods:
359
433
  - `ObjectExists(objectName: string): Promise<boolean>`
360
434
  - `DirectoryExists(directoryPath: string): Promise<boolean>`
361
435
  - `SearchFiles(query: string, options?: FileSearchOptions): Promise<FileSearchResultSet>` (throws `UnsupportedOperationError` for providers without native search)
362
- - `initialize(): Promise<void>` (optional, for async initialization)
363
436
 
364
437
  ### Utility Functions
365
438