@reldens/storage 0.87.0 → 0.88.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/CLAUDE.md CHANGED
@@ -413,8 +413,8 @@ PrismaClientLoader.load(projectPath, customPath, connectionData)
413
413
 
414
414
  **Parameters:**
415
415
  - `projectPath` (string): Project root directory path
416
- - `customPath` (string|null): Optional custom path to Prisma client (overrides default)
417
- - `connectionData` (object): Database connection configuration with properties:
416
+ - `customPath` (string|null): Optional custom path to a Prisma client (overrides default)
417
+ - `connectionData` (object|null): Optional database connection configuration with properties:
418
418
  - `client` (string): Database client type (mysql, postgresql, etc.)
419
419
  - `user` (string): Database username
420
420
  - `password` (string): Database password
@@ -426,13 +426,27 @@ PrismaClientLoader.load(projectPath, customPath, connectionData)
426
426
 
427
427
  **Behavior:**
428
428
  - If `customPath` is provided, uses that path
429
- - Otherwise uses default path: `projectPath/prisma/client`
429
+ - Otherwise, uses a default path: `projectPath/prisma/client`
430
430
  - Validates that Prisma Client exists at the path
431
431
  - Requires `prismaModule.PrismaClient` export
432
- - Builds connection string from connectionData
433
- - Returns initialized PrismaClient with connection configuration
432
+ - If `connectionData` is null: Uses default connection from Prisma schema datasource
433
+ - If `connectionData` is provided: Builds custom connection string and overrides datasource
434
+ - Returns initialized PrismaClient instance
434
435
 
435
- **Usage Example:**
436
+ **Usage Examples:**
437
+
438
+ Using the default connection from schema:
439
+ ```javascript
440
+ const { PrismaClientLoader } = require('@reldens/storage');
441
+
442
+ const prismaClient = PrismaClientLoader.load(process.cwd(), null, null);
443
+ if(!prismaClient){
444
+ console.error('Failed to load Prisma client');
445
+ process.exit(1);
446
+ }
447
+ ```
448
+
449
+ Using custom connection:
436
450
  ```javascript
437
451
  const { PrismaClientLoader } = require('@reldens/storage');
438
452
 
package/README.md CHANGED
@@ -186,6 +186,18 @@ Note: The PrismaDataServer requires the Prisma schema to be generated first. Mak
186
186
 
187
187
  If you need to load a Prisma Client instance in your CLI tools or applications:
188
188
 
189
+ Using the default connection from schema:
190
+ ```javascript
191
+ const { PrismaClientLoader } = require('@reldens/storage');
192
+
193
+ const prismaClient = PrismaClientLoader.load(process.cwd(), null, null);
194
+ if(!prismaClient){
195
+ console.error('Failed to load Prisma client');
196
+ process.exit(1);
197
+ }
198
+ ```
199
+
200
+ Using custom connection:
189
201
  ```javascript
190
202
  const { PrismaClientLoader } = require('@reldens/storage');
191
203
 
@@ -210,8 +222,8 @@ if(!prismaClient){
210
222
 
211
223
  Parameters:
212
224
  - `projectPath`: Project root directory
213
- - `customPath`: Optional custom path to Prisma client (null for default)
214
- - `connectionData`: Database connection configuration object
225
+ - `customPath`: Optional custom path to a Prisma client (null for default)
226
+ - `connectionData`: Optional database connection configuration object (null to use schema default)
215
227
 
216
228
  ## Custom Drivers
217
229
 
@@ -26,6 +26,10 @@ class PrismaClientLoader
26
26
  Logger.critical('PrismaClient class not found at: '+prismaClientPath);
27
27
  return null;
28
28
  }
29
+ if(!connectionData){
30
+ Logger.info('Creating PrismaClient with default connection from schema');
31
+ return new prismaModule.PrismaClient({log: ['error']});
32
+ }
29
33
  let connectionString = connectionData.client+'://'
30
34
  +connectionData.user
31
35
  +(connectionData.password ? ':'+connectionData.password : '')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/storage",
3
3
  "scope": "@reldens",
4
- "version": "0.87.0",
4
+ "version": "0.88.0",
5
5
  "description": "Reldens - Storage",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",