@gl-life/gl-life-database 1.1.0 โ†’ 1.1.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.
package/API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gl-life/gl-life-database API Reference
2
2
 
3
- **Version**: 1.1.0
3
+ **Version**: 1.1.1
4
4
  **Package**: `@gl-life/gl-life-database`
5
5
  **License**: Apache-2.0
6
6
  **Homepage**: https://gl.life
@@ -9,11 +9,13 @@
9
9
 
10
10
  - [Core Types](#core-types)
11
11
  - [Connection Management](#connection-management)
12
+ - [Enterprise Database Support](#enterprise-database-support)
12
13
  - [Query Builder](#query-builder)
13
14
  - [Transactions](#transactions)
14
15
  - [Multi-Tenancy](#multi-tenancy)
15
16
  - [Caching](#caching)
16
17
  - [Migrations](#migrations)
18
+ - [Flex Table System](#flex-table-system)
17
19
  - [CloudForge Adapters](#cloudforge-adapters)
18
20
  - [Error Handling](#error-handling)
19
21
  - [Usage Patterns](#usage-patterns)
@@ -137,6 +139,205 @@ Returns an available connection from the pool.
137
139
 
138
140
  ---
139
141
 
142
+ ## Enterprise Database Support
143
+
144
+ Full support for enterprise databases with bring-your-own-database (BYOD) deployments.
145
+
146
+ ### Supported Databases
147
+
148
+ #### SQL Server (Microsoft)
149
+
150
+ ```typescript
151
+ interface SQLServerConfig {
152
+ type: 'sqlserver';
153
+ host: string;
154
+ port?: number; // Default: 1433
155
+ database: string;
156
+ username: string;
157
+ password: string;
158
+ options?: {
159
+ encrypt?: boolean; // Required for Azure SQL
160
+ trustServerCertificate?: boolean;
161
+ connectionTimeout?: number;
162
+ requestTimeout?: number;
163
+ pool?: {
164
+ max?: number;
165
+ min?: number;
166
+ idleTimeoutMillis?: number;
167
+ };
168
+ };
169
+ }
170
+ ```
171
+
172
+ **Example**:
173
+ ```typescript
174
+ const connection = await manager.connect({
175
+ type: 'sqlserver',
176
+ host: 'sql-server.database.windows.net',
177
+ port: 1433,
178
+ database: 'production',
179
+ username: 'admin',
180
+ password: process.env.DB_PASSWORD,
181
+ options: {
182
+ encrypt: true,
183
+ trustServerCertificate: false,
184
+ connectionTimeout: 30000,
185
+ pool: {
186
+ max: 20,
187
+ min: 5,
188
+ idleTimeoutMillis: 30000
189
+ }
190
+ }
191
+ });
192
+ ```
193
+
194
+ #### PostgreSQL
195
+
196
+ ```typescript
197
+ interface PostgreSQLConfig {
198
+ type: 'postgres';
199
+ host: string;
200
+ port?: number; // Default: 5432
201
+ database: string;
202
+ username: string;
203
+ password: string;
204
+ options?: {
205
+ ssl?: boolean | object;
206
+ poolSize?: number;
207
+ idleTimeoutMillis?: number;
208
+ connectionTimeoutMillis?: number;
209
+ schema?: string;
210
+ };
211
+ }
212
+ ```
213
+
214
+ **Example**:
215
+ ```typescript
216
+ const connection = await manager.connect({
217
+ type: 'postgres',
218
+ host: 'postgres-cluster.company.com',
219
+ port: 5432,
220
+ database: 'production',
221
+ username: 'dbuser',
222
+ password: process.env.DB_PASSWORD,
223
+ options: {
224
+ ssl: { rejectUnauthorized: false },
225
+ poolSize: 20,
226
+ schema: 'public'
227
+ }
228
+ });
229
+ ```
230
+
231
+ #### MySQL / MariaDB
232
+
233
+ ```typescript
234
+ interface MySQLConfig {
235
+ type: 'mysql';
236
+ host: string;
237
+ port?: number; // Default: 3306
238
+ database: string;
239
+ username: string;
240
+ password: string;
241
+ options?: {
242
+ connectionLimit?: number;
243
+ charset?: string;
244
+ timezone?: string;
245
+ ssl?: boolean | object;
246
+ };
247
+ }
248
+ ```
249
+
250
+ **Example**:
251
+ ```typescript
252
+ const connection = await manager.connect({
253
+ type: 'mysql',
254
+ host: 'mysql-primary.internal.com',
255
+ port: 3306,
256
+ database: 'production',
257
+ username: 'app_user',
258
+ password: process.env.DB_PASSWORD,
259
+ options: {
260
+ connectionLimit: 10,
261
+ charset: 'utf8mb4',
262
+ timezone: 'Z'
263
+ }
264
+ });
265
+ ```
266
+
267
+ #### Oracle Database
268
+
269
+ ```typescript
270
+ interface OracleConfig {
271
+ type: 'oracle';
272
+ host: string;
273
+ port?: number; // Default: 1521
274
+ database: string; // Service name
275
+ username: string;
276
+ password: string;
277
+ options?: {
278
+ poolMax?: number;
279
+ poolMin?: number;
280
+ poolIncrement?: number;
281
+ poolTimeout?: number;
282
+ };
283
+ }
284
+ ```
285
+
286
+ **Example**:
287
+ ```typescript
288
+ const connection = await manager.connect({
289
+ type: 'oracle',
290
+ host: 'oracle-db.company.com',
291
+ port: 1521,
292
+ database: 'ORCL',
293
+ username: 'system',
294
+ password: process.env.DB_PASSWORD,
295
+ options: {
296
+ poolMax: 10,
297
+ poolMin: 2,
298
+ poolIncrement: 1
299
+ }
300
+ });
301
+ ```
302
+
303
+ ### Enterprise Features
304
+
305
+ All features work identically across all database engines:
306
+
307
+ - โœ… **Flex Table System** - Dynamic schemas work on any database
308
+ - โœ… **Multi-Tenancy** - Row-Level Security on all engines
309
+ - โœ… **Caching** - Cache layer independent of database type
310
+ - โœ… **Migrations** - Version control for any database
311
+ - โœ… **Transactions** - ACID compliance on all supported databases
312
+ - โœ… **Connection Pooling** - Automatic connection management
313
+
314
+ ### Hybrid Deployments
315
+
316
+ Mix cloud and on-premise databases in the same application:
317
+
318
+ ```typescript
319
+ // Cloud database for non-sensitive data
320
+ const cloudConn = await manager.connect({
321
+ type: 'd1',
322
+ binding: env.DB
323
+ });
324
+
325
+ // Enterprise database for sensitive data
326
+ const enterpriseConn = await manager.connect({
327
+ type: 'sqlserver',
328
+ host: 'on-premise-sql.company.local',
329
+ database: 'customer_data',
330
+ username: 'app_user',
331
+ password: process.env.DB_PASSWORD
332
+ });
333
+
334
+ // Use both in same application
335
+ const products = await cloudConn.execute('SELECT * FROM products');
336
+ const customers = await enterpriseConn.execute('SELECT * FROM customers WHERE tenant_id = ?', [tenantId]);
337
+ ```
338
+
339
+ ---
340
+
140
341
  ## Query Builder
141
342
 
142
343
  ### TypeSafeQueryBuilder
package/README.md CHANGED
@@ -4,16 +4,17 @@ Enhanced gl-life-data wrapper with CloudForge features - Type-safe database abst
4
4
 
5
5
  ## About
6
6
 
7
- `@gl-life/gl-life-database` is a comprehensive database abstraction layer that extends gl-life-data with enterprise features for multi-tenant SaaS applications running on Cloudflare Workers. Built with TypeScript and designed for type safety, it provides a robust foundation for building scalable database-driven applications.
7
+ `@gl-life/gl-life-database` is a comprehensive database abstraction layer that extends gl-life-data with enterprise features for multi-tenant SaaS applications. Built with TypeScript and designed for type safety, it supports both cloud-native deployments (Cloudflare Workers) and enterprise bring-your-own-database (BYOD) scenarios with SQL Server, MySQL, PostgreSQL, Oracle, and more. Perfect for pro users who want to leverage their existing infrastructure while gaining powerful features like Flex tables, multi-tenancy, and intelligent caching.
8
8
 
9
9
  ### Key Features
10
10
 
11
11
  - ๐Ÿ—„๏ธ **Type-Safe Query Builder** - Fluent API with full TypeScript support extending gl-life-data
12
12
  - ๐Ÿ”€ **Flex Table System** - Dynamic schema without ALTER TABLE, metadata-driven field mapping
13
+ - ๐Ÿข **Enterprise Database Support** - Full support for SQL Server, MySQL, PostgreSQL, Oracle, and more
13
14
  - ๐Ÿ‘ฅ **Multi-Tenancy** - Built-in tenant isolation with Row-Level Security (RLS)
14
- - โšก **Caching Layer** - High-performance query result caching with memory and Cloudflare KV backends
15
+ - โšก **Flexible Caching** - Memory cache, Redis, or Cloudflare KV backends
15
16
  - ๐Ÿ”„ **Migrations** - Version-controlled database migrations with rollback support
16
- - โ˜๏ธ **CloudForge Integration** - Native support for D1, Durable Objects, Workers KV, and R2
17
+ - โ˜๏ธ **Cloud + On-Premise** - Deploy on Cloudflare Workers OR bring your own infrastructure
17
18
  - ๐Ÿ”’ **SQL Injection Protection** - Parameterized queries with automatic sanitization
18
19
  - ๐Ÿงช **Well-Tested** - >95% test coverage with comprehensive security tests
19
20
  - ๐Ÿ“Š **Performance Optimized** - Query building overhead <1ms (P95)
@@ -181,6 +182,108 @@ export default {
181
182
  };
182
183
  ```
183
184
 
185
+ ### Enterprise Database Support (BYOD - Bring Your Own Database)
186
+
187
+ Pro users can connect to their existing enterprise databases instead of using Cloudflare Workers. Full support for:
188
+
189
+ #### SQL Server (Microsoft)
190
+
191
+ ```typescript
192
+ import { ConnectionManager, Logger } from '@gl-life/gl-life-database';
193
+
194
+ const logger = new Logger({ level: 'info' });
195
+ const manager = new ConnectionManager(logger);
196
+
197
+ const connection = await manager.connect({
198
+ type: 'sqlserver',
199
+ host: 'your-sql-server.database.windows.net',
200
+ port: 1433,
201
+ database: 'production_db',
202
+ username: 'admin',
203
+ password: process.env.DB_PASSWORD,
204
+ options: {
205
+ encrypt: true, // Azure SQL requires encryption
206
+ trustServerCertificate: false,
207
+ connectionTimeout: 30000
208
+ }
209
+ });
210
+
211
+ // All features work identically: Flex tables, multi-tenancy, caching, migrations
212
+ const builder = new TypeSafeQueryBuilder('users', metaDataService, logger);
213
+ // ... same as any other database
214
+ ```
215
+
216
+ #### PostgreSQL
217
+
218
+ ```typescript
219
+ const connection = await manager.connect({
220
+ type: 'postgres',
221
+ host: 'your-postgres-instance.com',
222
+ port: 5432,
223
+ database: 'production_db',
224
+ username: 'dbuser',
225
+ password: process.env.DB_PASSWORD,
226
+ options: {
227
+ ssl: { rejectUnauthorized: false },
228
+ poolSize: 20,
229
+ idleTimeoutMillis: 30000
230
+ }
231
+ });
232
+ ```
233
+
234
+ #### MySQL / MariaDB
235
+
236
+ ```typescript
237
+ const connection = await manager.connect({
238
+ type: 'mysql',
239
+ host: 'mysql-cluster.internal.com',
240
+ port: 3306,
241
+ database: 'production_db',
242
+ username: 'dbuser',
243
+ password: process.env.DB_PASSWORD,
244
+ options: {
245
+ connectionLimit: 10,
246
+ charset: 'utf8mb4',
247
+ timezone: 'Z'
248
+ }
249
+ });
250
+ ```
251
+
252
+ #### Oracle Database
253
+
254
+ ```typescript
255
+ const connection = await manager.connect({
256
+ type: 'oracle',
257
+ host: 'oracle-enterprise.company.com',
258
+ port: 1521,
259
+ database: 'ORCL', // Service name
260
+ username: 'system',
261
+ password: process.env.DB_PASSWORD,
262
+ options: {
263
+ poolMax: 10,
264
+ poolMin: 2,
265
+ poolIncrement: 1
266
+ }
267
+ });
268
+ ```
269
+
270
+ #### SQLite (Development/Testing)
271
+
272
+ ```typescript
273
+ const connection = await manager.connect({
274
+ type: 'sqlite',
275
+ filename: './dev.db' // Or ':memory:' for in-memory
276
+ });
277
+ ```
278
+
279
+ **Key Benefits for Enterprise Users:**
280
+ - โœ… **Use Existing Infrastructure** - No migration required, connect to your current databases
281
+ - โœ… **All Features Work** - Flex tables, multi-tenancy, caching, migrations work on any database
282
+ - โœ… **Security Compliant** - Keep data on-premise, meet regulatory requirements
283
+ - โœ… **Cost Control** - Use your existing database licenses and hardware
284
+ - โœ… **Hybrid Deployments** - Mix cloud (D1) and on-premise databases in same application
285
+ - โœ… **Connection Pooling** - Built-in connection management for all enterprise databases
286
+
184
287
  ### Flex Table System
185
288
 
186
289
  The Flex Table System is a powerful feature from gl-life-data that provides dynamic schema capabilities without ALTER TABLE operations. Perfect for multi-tenant SaaS applications where each tenant needs custom fields.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for @gl-life/gl-life-database v1.1.0
1
+ // Type definitions for @gl-life/gl-life-database v1.1.1
2
2
  // Manual declarations due to tsup build limitations with Result type
3
3
 
4
4
  // Re-export from gl-life-core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gl-life/gl-life-database",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Enhanced gl-life-data wrapper with CloudForge features - Type-safe database abstraction layer with multi-tenancy, caching, migrations, and Cloudflare Workers support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",