@ciscode/database-kit 1.0.0 → 1.0.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 (48) hide show
  1. package/CHANGELOG.md +50 -4
  2. package/README.md +487 -148
  3. package/dist/adapters/mongo.adapter.d.ts +53 -3
  4. package/dist/adapters/mongo.adapter.d.ts.map +1 -1
  5. package/dist/adapters/mongo.adapter.js +410 -27
  6. package/dist/adapters/mongo.adapter.js.map +1 -1
  7. package/dist/adapters/postgres.adapter.d.ts +50 -3
  8. package/dist/adapters/postgres.adapter.d.ts.map +1 -1
  9. package/dist/adapters/postgres.adapter.js +439 -45
  10. package/dist/adapters/postgres.adapter.js.map +1 -1
  11. package/dist/config/database.config.d.ts +1 -1
  12. package/dist/config/database.config.d.ts.map +1 -1
  13. package/dist/config/database.config.js +13 -13
  14. package/dist/config/database.config.js.map +1 -1
  15. package/dist/config/database.constants.js +7 -7
  16. package/dist/contracts/database.contracts.d.ts +283 -6
  17. package/dist/contracts/database.contracts.d.ts.map +1 -1
  18. package/dist/contracts/database.contracts.js +6 -1
  19. package/dist/contracts/database.contracts.js.map +1 -1
  20. package/dist/database-kit.module.d.ts +2 -2
  21. package/dist/database-kit.module.d.ts.map +1 -1
  22. package/dist/database-kit.module.js +1 -2
  23. package/dist/database-kit.module.js.map +1 -1
  24. package/dist/filters/database-exception.filter.d.ts +1 -1
  25. package/dist/filters/database-exception.filter.d.ts.map +1 -1
  26. package/dist/filters/database-exception.filter.js +43 -43
  27. package/dist/filters/database-exception.filter.js.map +1 -1
  28. package/dist/index.d.ts +10 -10
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/middleware/database.decorators.d.ts.map +1 -1
  32. package/dist/middleware/database.decorators.js.map +1 -1
  33. package/dist/services/database.service.d.ts +83 -5
  34. package/dist/services/database.service.d.ts.map +1 -1
  35. package/dist/services/database.service.js +136 -16
  36. package/dist/services/database.service.js.map +1 -1
  37. package/dist/services/logger.service.d.ts +1 -1
  38. package/dist/services/logger.service.d.ts.map +1 -1
  39. package/dist/services/logger.service.js +1 -1
  40. package/dist/services/logger.service.js.map +1 -1
  41. package/dist/utils/pagination.utils.d.ts +2 -2
  42. package/dist/utils/pagination.utils.d.ts.map +1 -1
  43. package/dist/utils/pagination.utils.js +9 -6
  44. package/dist/utils/pagination.utils.js.map +1 -1
  45. package/dist/utils/validation.utils.d.ts.map +1 -1
  46. package/dist/utils/validation.utils.js +5 -5
  47. package/dist/utils/validation.utils.js.map +1 -1
  48. package/package.json +28 -8
package/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
11
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12
+
13
+ ---
14
+
10
15
  ## [Unreleased]
11
16
 
12
17
  ### Planned
@@ -14,16 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
19
  - MySQL adapter support
15
20
  - Redis caching layer
16
21
  - Query builder interface
17
- - Soft delete built-in support
22
+ - Aggregation pipeline support
18
23
  - Audit logging
19
24
 
20
25
  ---
21
26
 
22
- ## [1.0.0] - 2026-01-31
27
+ ## [1.0.0] - 2026-02-01
23
28
 
24
- ### 🎉 Initial Release
29
+ ### 🎉 Production-Ready Release
25
30
 
26
- Complete refactoring following CISCODE AuthKit patterns and best practices.
31
+ Complete refactoring following CISCODE AuthKit patterns and best practices, with advanced features for production use.
27
32
 
28
33
  ### Added
29
34
 
@@ -32,12 +37,53 @@ Complete refactoring following CISCODE AuthKit patterns and best practices.
32
37
  - **Unified Repository API** - Same interface for MongoDB and PostgreSQL
33
38
  - `create(data)` - Create new records
34
39
  - `findById(id)` - Find by primary key
40
+ - `findOne(filter)` - Find single record by filter _(NEW)_
35
41
  - `findAll(filter)` - Find all matching records
36
42
  - `findPage(options)` - Paginated queries
37
43
  - `updateById(id, data)` - Update by primary key
38
44
  - `deleteById(id)` - Delete by primary key
39
45
  - `count(filter)` - Count matching records
40
46
  - `exists(filter)` - Check if records exist
47
+ - `upsert(filter, data)` - Update or insert _(NEW)_
48
+ - `distinct(field, filter)` - Get distinct values _(NEW)_
49
+ - `select(filter, fields)` - Projection/field selection _(NEW)_
50
+
51
+ - **Transaction Support** - ACID transactions with session management
52
+ - `withTransaction(callback, options)` - Execute callback in transaction
53
+ - Configurable retry logic for transient errors
54
+ - Automatic session handling
55
+
56
+ - **Bulk Operations** - Efficient batch processing
57
+ - `insertMany(data)` - Bulk insert
58
+ - `updateMany(filter, update)` - Bulk update
59
+ - `deleteMany(filter)` - Bulk delete
60
+
61
+ - **Soft Delete** - Non-destructive deletion
62
+ - `softDelete(id)` - Mark as deleted
63
+ - `restore(id)` - Restore deleted record
64
+ - `findWithDeleted(filter)` - Include deleted records
65
+ - Configurable field name (default: `deletedAt`/`deleted_at`)
66
+
67
+ - **Timestamps** - Automatic created/updated tracking
68
+ - `createdAt`/`created_at` field on create
69
+ - `updatedAt`/`updated_at` field on update
70
+ - Configurable field names
71
+
72
+ - **Health Checks** - Database monitoring
73
+ - `healthCheck()` - Connection status, response time, pool info
74
+
75
+ - **Connection Pool Configuration** - Performance tuning _(NEW)_
76
+ - `PoolConfig` interface with min, max, idle timeout, acquire timeout
77
+ - MongoDB: maxPoolSize, minPoolSize, serverSelectionTimeoutMS, socketTimeoutMS
78
+ - PostgreSQL: min, max, idleTimeoutMillis, acquireTimeoutMillis
79
+
80
+ - **Repository Hooks** - Lifecycle event callbacks _(NEW)_
81
+ - `beforeCreate(context)` - Called before insert, can modify data
82
+ - `afterCreate(entity)` - Called after insert
83
+ - `beforeUpdate(context)` - Called before update, can modify data
84
+ - `afterUpdate(entity)` - Called after update
85
+ - `beforeDelete(id)` - Called before delete
86
+ - `afterDelete(success)` - Called after delete
41
87
 
42
88
  #### NestJS Integration
43
89