@venizia/ignis-docs 0.0.3 → 0.0.4-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 (131) hide show
  1. package/README.md +1 -1
  2. package/package.json +4 -2
  3. package/wiki/best-practices/api-usage-examples.md +591 -0
  4. package/wiki/best-practices/architectural-patterns.md +415 -0
  5. package/wiki/best-practices/architecture-decisions.md +488 -0
  6. package/wiki/{get-started/best-practices → best-practices}/code-style-standards.md +406 -17
  7. package/wiki/{get-started/best-practices → best-practices}/common-pitfalls.md +109 -4
  8. package/wiki/{get-started/best-practices → best-practices}/contribution-workflow.md +34 -7
  9. package/wiki/best-practices/data-modeling.md +376 -0
  10. package/wiki/best-practices/deployment-strategies.md +698 -0
  11. package/wiki/best-practices/index.md +27 -0
  12. package/wiki/best-practices/performance-optimization.md +196 -0
  13. package/wiki/best-practices/security-guidelines.md +218 -0
  14. package/wiki/{get-started/best-practices → best-practices}/troubleshooting-tips.md +97 -1
  15. package/wiki/changelogs/2025-12-16-initial-architecture.md +1 -1
  16. package/wiki/changelogs/2025-12-16-model-repo-datasource-refactor.md +1 -1
  17. package/wiki/changelogs/2025-12-17-refactor.md +1 -1
  18. package/wiki/changelogs/2025-12-18-performance-optimizations.md +5 -5
  19. package/wiki/changelogs/2025-12-18-repository-validation-security.md +13 -7
  20. package/wiki/changelogs/2025-12-26-nested-relations-and-generics.md +2 -2
  21. package/wiki/changelogs/2025-12-29-dynamic-binding-registration.md +104 -0
  22. package/wiki/changelogs/2025-12-29-snowflake-uid-helper.md +100 -0
  23. package/wiki/changelogs/2025-12-30-repository-enhancements.md +214 -0
  24. package/wiki/changelogs/2025-12-31-json-path-filtering-array-operators.md +214 -0
  25. package/wiki/changelogs/2025-12-31-string-id-custom-generator.md +137 -0
  26. package/wiki/changelogs/2026-01-02-default-filter-and-repository-mixins.md +418 -0
  27. package/wiki/changelogs/index.md +6 -0
  28. package/wiki/changelogs/planned-schema-migrator.md +0 -8
  29. package/wiki/{get-started/core-concepts → guides/core-concepts/application}/bootstrapping.md +18 -5
  30. package/wiki/{get-started/core-concepts/application.md → guides/core-concepts/application/index.md} +47 -104
  31. package/wiki/guides/core-concepts/components-guide.md +509 -0
  32. package/wiki/{get-started → guides}/core-concepts/components.md +24 -17
  33. package/wiki/{get-started → guides}/core-concepts/controllers.md +30 -13
  34. package/wiki/{get-started → guides}/core-concepts/dependency-injection.md +97 -0
  35. package/wiki/guides/core-concepts/persistent/datasources.md +179 -0
  36. package/wiki/guides/core-concepts/persistent/index.md +119 -0
  37. package/wiki/guides/core-concepts/persistent/models.md +241 -0
  38. package/wiki/guides/core-concepts/persistent/repositories.md +219 -0
  39. package/wiki/guides/core-concepts/persistent/transactions.md +170 -0
  40. package/wiki/{get-started → guides}/core-concepts/services.md +26 -3
  41. package/wiki/{get-started → guides/get-started}/5-minute-quickstart.md +59 -14
  42. package/wiki/guides/get-started/philosophy.md +682 -0
  43. package/wiki/guides/get-started/setup.md +157 -0
  44. package/wiki/guides/index.md +89 -0
  45. package/wiki/guides/reference/glossary.md +243 -0
  46. package/wiki/{get-started → guides/reference}/mcp-docs-server.md +0 -10
  47. package/wiki/{get-started → guides/tutorials}/building-a-crud-api.md +134 -132
  48. package/wiki/{get-started/quickstart.md → guides/tutorials/complete-installation.md} +107 -71
  49. package/wiki/guides/tutorials/ecommerce-api.md +1399 -0
  50. package/wiki/guides/tutorials/realtime-chat.md +1261 -0
  51. package/wiki/guides/tutorials/testing.md +723 -0
  52. package/wiki/index.md +176 -37
  53. package/wiki/references/base/application.md +27 -0
  54. package/wiki/references/base/bootstrapping.md +31 -26
  55. package/wiki/references/base/components.md +24 -7
  56. package/wiki/references/base/controllers.md +50 -20
  57. package/wiki/references/base/datasources.md +30 -0
  58. package/wiki/references/base/dependency-injection.md +39 -3
  59. package/wiki/references/base/filter-system/application-usage.md +224 -0
  60. package/wiki/references/base/filter-system/array-operators.md +132 -0
  61. package/wiki/references/base/filter-system/comparison-operators.md +109 -0
  62. package/wiki/references/base/filter-system/default-filter.md +428 -0
  63. package/wiki/references/base/filter-system/fields-order-pagination.md +155 -0
  64. package/wiki/references/base/filter-system/index.md +127 -0
  65. package/wiki/references/base/filter-system/json-filtering.md +197 -0
  66. package/wiki/references/base/filter-system/list-operators.md +71 -0
  67. package/wiki/references/base/filter-system/logical-operators.md +156 -0
  68. package/wiki/references/base/filter-system/null-operators.md +58 -0
  69. package/wiki/references/base/filter-system/pattern-matching.md +108 -0
  70. package/wiki/references/base/filter-system/quick-reference.md +431 -0
  71. package/wiki/references/base/filter-system/range-operators.md +63 -0
  72. package/wiki/references/base/filter-system/tips.md +190 -0
  73. package/wiki/references/base/filter-system/use-cases.md +452 -0
  74. package/wiki/references/base/index.md +90 -0
  75. package/wiki/references/base/middlewares.md +604 -0
  76. package/wiki/references/base/models.md +215 -23
  77. package/wiki/references/base/providers.md +731 -0
  78. package/wiki/references/base/repositories/advanced.md +555 -0
  79. package/wiki/references/base/repositories/index.md +228 -0
  80. package/wiki/references/base/repositories/mixins.md +331 -0
  81. package/wiki/references/base/repositories/relations.md +486 -0
  82. package/wiki/references/base/repositories.md +40 -635
  83. package/wiki/references/base/services.md +28 -4
  84. package/wiki/references/components/authentication.md +22 -2
  85. package/wiki/references/components/health-check.md +12 -0
  86. package/wiki/references/components/index.md +23 -0
  87. package/wiki/references/components/mail.md +687 -0
  88. package/wiki/references/components/request-tracker.md +16 -0
  89. package/wiki/references/components/socket-io.md +18 -0
  90. package/wiki/references/components/static-asset.md +14 -26
  91. package/wiki/references/components/swagger.md +17 -0
  92. package/wiki/references/configuration/environment-variables.md +427 -0
  93. package/wiki/references/configuration/index.md +73 -0
  94. package/wiki/references/helpers/cron.md +14 -0
  95. package/wiki/references/helpers/crypto.md +15 -0
  96. package/wiki/references/helpers/env.md +16 -0
  97. package/wiki/references/helpers/error.md +17 -0
  98. package/wiki/references/helpers/index.md +14 -0
  99. package/wiki/references/helpers/inversion.md +24 -4
  100. package/wiki/references/helpers/logger.md +19 -0
  101. package/wiki/references/helpers/network.md +11 -0
  102. package/wiki/references/helpers/queue.md +19 -0
  103. package/wiki/references/helpers/redis.md +21 -0
  104. package/wiki/references/helpers/socket-io.md +24 -5
  105. package/wiki/references/helpers/storage.md +18 -10
  106. package/wiki/references/helpers/testing.md +18 -0
  107. package/wiki/references/helpers/types.md +16 -0
  108. package/wiki/references/helpers/uid.md +167 -0
  109. package/wiki/references/helpers/worker-thread.md +16 -0
  110. package/wiki/references/index.md +177 -0
  111. package/wiki/references/quick-reference.md +634 -0
  112. package/wiki/references/src-details/boot.md +3 -3
  113. package/wiki/references/src-details/dev-configs.md +0 -4
  114. package/wiki/references/src-details/docs.md +2 -2
  115. package/wiki/references/src-details/index.md +86 -0
  116. package/wiki/references/src-details/inversion.md +1 -6
  117. package/wiki/references/src-details/mcp-server.md +3 -15
  118. package/wiki/references/utilities/index.md +86 -10
  119. package/wiki/references/utilities/jsx.md +577 -0
  120. package/wiki/references/utilities/request.md +0 -2
  121. package/wiki/references/utilities/statuses.md +740 -0
  122. package/wiki/get-started/best-practices/api-usage-examples.md +0 -266
  123. package/wiki/get-started/best-practices/architectural-patterns.md +0 -170
  124. package/wiki/get-started/best-practices/data-modeling.md +0 -177
  125. package/wiki/get-started/best-practices/deployment-strategies.md +0 -121
  126. package/wiki/get-started/best-practices/performance-optimization.md +0 -97
  127. package/wiki/get-started/best-practices/security-guidelines.md +0 -99
  128. package/wiki/get-started/core-concepts/persistent.md +0 -539
  129. package/wiki/get-started/index.md +0 -65
  130. package/wiki/get-started/philosophy.md +0 -296
  131. package/wiki/get-started/prerequisites.md +0 -113
@@ -92,3 +92,17 @@ Creates a new `CronHelper` instance with the same configuration but a new `cronT
92
92
  const anotherJob = myJob.duplicate({ cronTime: '0 0 * * *' }); // Runs once at midnight
93
93
  anotherJob.start();
94
94
  ```
95
+
96
+ ## See Also
97
+
98
+ - **Related Concepts:**
99
+ - [Services](/guides/core-concepts/services) - Scheduling jobs in services
100
+ - [Application](/guides/core-concepts/application/) - Scheduling on app startup
101
+
102
+ - **Other Helpers:**
103
+ - [Helpers Index](./index) - All available helpers
104
+ - [Queue Helper](./queue) - Message queue processing
105
+
106
+ - **External Resources:**
107
+ - [Cron Expression Guide](https://crontab.guru/) - Cron syntax reference
108
+ - [node-cron Documentation](https://github.com/node-cron/node-cron) - Cron library
@@ -115,3 +115,18 @@ const sha256Hash = hash('some text', {
115
115
  outputType: 'hex',
116
116
  });
117
117
  ```
118
+
119
+ ## See Also
120
+
121
+ - **Related Concepts:**
122
+ - [Services](/guides/core-concepts/services) - Password hashing in user service
123
+
124
+ - **Other Helpers:**
125
+ - [Helpers Index](./index) - All available helpers
126
+
127
+ - **References:**
128
+ - [Crypto Utility](/references/utilities/crypto) - Pure crypto utilities
129
+ - [Authentication Component](/references/components/authentication) - JWT and password verification
130
+
131
+ - **Best Practices:**
132
+ - [Security Guidelines](/best-practices/security-guidelines) - Cryptographic best practices
@@ -65,3 +65,19 @@ APPLICATION_ENV_PREFIX=MY_APP_ENV
65
65
  MY_APP_ENV_SERVER_HOST=0.0.0.0
66
66
  MY_APP_ENV_SERVER_PORT=3000
67
67
  ```
68
+
69
+ ## See Also
70
+
71
+ - **Related Concepts:**
72
+ - [Application](/guides/core-concepts/application/) - Environment validation
73
+ - [DataSources](/guides/core-concepts/persistent/datasources) - Database configuration
74
+
75
+ - **Other Helpers:**
76
+ - [Helpers Index](./index) - All available helpers
77
+
78
+ - **References:**
79
+ - [Environment Variables](/references/configuration/environment-variables) - Complete environment reference
80
+
81
+ - **Best Practices:**
82
+ - [Security Guidelines](/best-practices/security-guidelines) - Environment variable security
83
+ - [Deployment Strategies](/best-practices/deployment-strategies) - Environment management
@@ -78,3 +78,20 @@ In development mode, the response will include the stack trace and error cause f
78
78
  "path": "/api/users/123"
79
79
  }
80
80
  ```
81
+
82
+ ## See Also
83
+
84
+ - **Related Concepts:**
85
+ - [Controllers](/guides/core-concepts/controllers) - Throwing errors in controllers
86
+ - [Services](/guides/core-concepts/services) - Error handling in services
87
+
88
+ - **Other Helpers:**
89
+ - [Helpers Index](./index) - All available helpers
90
+ - [Logger Helper](./logger) - Logging errors
91
+
92
+ - **References:**
93
+ - [Middlewares](/references/base/middlewares) - Error handler middleware
94
+
95
+ - **Best Practices:**
96
+ - [Common Pitfalls](/best-practices/common-pitfalls) - Error handling anti-patterns
97
+ - [Troubleshooting Tips](/best-practices/troubleshooting-tips) - Debugging errors
@@ -19,4 +19,18 @@ Reusable classes and functions providing common functionality - designed for eas
19
19
  | [Socket.IO](./socket-io.md) | Real-time communication | Socket.IO client/server helpers |
20
20
  | [Storage](./storage.md) | File storage | In-memory, Minio object storage |
21
21
  | [Testing](./testing.md) | Test utilities | Test plan runner, base test classes |
22
+ | [UID](./uid.md) | Unique ID generation | Snowflake IDs, Base62 encoding |
22
23
  | [Worker Thread](./worker-thread.md) | Worker threads | Node.js worker management |
24
+
25
+ ## See Also
26
+
27
+ - **Related Concepts:**
28
+ - [Services](/guides/core-concepts/services) - Using helpers in service layer
29
+ - [Controllers](/guides/core-concepts/controllers) - Using helpers in controllers
30
+
31
+ - **References:**
32
+ - [Utilities](/references/utilities/) - Pure utility functions
33
+ - [Components](/references/components/) - Framework components
34
+
35
+ - **Best Practices:**
36
+ - [Code Style Standards](/best-practices/code-style-standards) - Helper usage patterns
@@ -111,12 +111,13 @@ import { UserService } from '../services/user.service';
111
111
  @controller({ path: '/users' })
112
112
  export class UserController extends BaseController {
113
113
  constructor(
114
- @inject({ key: 'services.UserService' }) private userService: UserService
114
+ @inject({ key: 'services.UserService' })
115
+ private _userService: UserService
115
116
  ) {
116
117
  super({ scope: UserController.name, path: '/users' });
117
118
  }
118
119
 
119
- // ... use this.userService
120
+ // ... use this._userService
120
121
  }
121
122
  ```
122
123
 
@@ -131,13 +132,13 @@ import { UserService } from '../services/user.service';
131
132
  @controller({ path: '/users' })
132
133
  export class UserController extends BaseController {
133
134
  @inject({ key: 'services.UserService' })
134
- private userService: UserService;
135
+ private _userService: UserService;
135
136
 
136
137
  constructor() {
137
138
  super({ scope: UserController.name, path: '/users' });
138
139
  }
139
140
 
140
- // ... use this.userService
141
+ // ... use this._userService
141
142
  }
142
143
  ```
143
144
 
@@ -154,3 +155,22 @@ The `MetadataRegistry` is a crucial part of the DI and routing systems. It's a s
154
155
  - When the `Container` instantiates a class, it queries the `MetadataRegistry` to find out which dependencies need to be injected and where.
155
156
 
156
157
  You typically won't interact with the `MetadataRegistry` directly, but it's the underlying mechanism that makes the decorator-based DI and routing systems work seamlessly.
158
+
159
+ ## See Also
160
+
161
+ - **Related Concepts:**
162
+ - [Dependency Injection Guide](/guides/core-concepts/dependency-injection) - DI fundamentals
163
+ - [Application](/guides/core-concepts/application/) - Application extends Container
164
+
165
+ - **Other Helpers:**
166
+ - [Helpers Index](./index) - All available helpers
167
+
168
+ - **References:**
169
+ - [Dependency Injection API](/references/base/dependency-injection) - Complete DI reference
170
+ - [Glossary](/guides/reference/glossary#dependency-injection-di) - DI concepts
171
+
172
+ - **Tutorials:**
173
+ - [Testing](/guides/tutorials/testing) - Unit testing with DI
174
+
175
+ - **Best Practices:**
176
+ - [Architectural Patterns](/best-practices/architectural-patterns) - DI patterns
@@ -96,3 +96,22 @@ const myCustomWinstonLogger = defineCustomLogger({
96
96
  const myLogger = new Logger({ customLogger: myCustomWinstonLogger });
97
97
  myLogger.withScope('CustomScope').info('This is a custom log message.');
98
98
  ```
99
+
100
+ ## See Also
101
+
102
+ - **Related Concepts:**
103
+ - [Services](/guides/core-concepts/services) - Logging in services
104
+ - [Controllers](/guides/core-concepts/controllers) - Logging in controllers
105
+
106
+ - **Other Helpers:**
107
+ - [Helpers Index](./index) - All available helpers
108
+ - [Error Helper](./error) - Error handling utilities
109
+
110
+ - **References:**
111
+ - [Request Tracker Component](/references/components/request-tracker) - Request logging
112
+
113
+ - **External Resources:**
114
+ - [Winston Documentation](https://github.com/winstonjs/winston) - Winston logging library
115
+
116
+ - **Best Practices:**
117
+ - [Troubleshooting Tips](/best-practices/troubleshooting-tips) - Using logs for debugging
@@ -141,3 +141,14 @@ const udpClient = new NetworkUdpClient({
141
141
 
142
142
  udpClient.connect();
143
143
  ```
144
+
145
+ ## See Also
146
+
147
+ - **Related Concepts:**
148
+ - [Services](/guides/core-concepts/services) - Network operations in services
149
+
150
+ - **Other Helpers:**
151
+ - [Helpers Index](./index) - All available helpers
152
+
153
+ - **Best Practices:**
154
+ - [Security Guidelines](/best-practices/security-guidelines) - Network security
@@ -129,3 +129,22 @@ const myQueue = new QueueHelper<string>({
129
129
  myQueue.enqueue('message 1');
130
130
  myQueue.enqueue('message 2');
131
131
  ```
132
+
133
+ ## See Also
134
+
135
+ - **Related Concepts:**
136
+ - [Services](/guides/core-concepts/services) - Background job processing
137
+
138
+ - **Other Helpers:**
139
+ - [Helpers Index](./index) - All available helpers
140
+ - [Cron Helper](./cron) - Scheduled tasks
141
+ - [Redis Helper](./redis) - Redis pub/sub
142
+
143
+ - **References:**
144
+ - [Mail Component](/references/components/mail) - Email queue integration
145
+
146
+ - **External Resources:**
147
+ - [BullMQ Documentation](https://docs.bullmq.io/) - BullMQ queue library
148
+
149
+ - **Best Practices:**
150
+ - [Performance Optimization](/best-practices/performance-optimization) - Queue optimization
@@ -119,3 +119,24 @@ await redisClient.publish({
119
119
  payload: { data: 'some important update' },
120
120
  });
121
121
  ```
122
+
123
+ ## See Also
124
+
125
+ - **Related Concepts:**
126
+ - [Services](/guides/core-concepts/services) - Using Redis in services
127
+
128
+ - **Other Helpers:**
129
+ - [Helpers Index](./index) - All available helpers
130
+ - [Queue Helper](./queue) - BullMQ uses Redis as backend
131
+
132
+ - **References:**
133
+ - [DataSources](/references/base/datasources) - Database connections
134
+
135
+ - **External Resources:**
136
+ - [ioredis Documentation](https://github.com/redis/ioredis) - Redis client library
137
+ - [Redis Commands](https://redis.io/commands/) - Redis command reference
138
+ - [RedisJSON](https://redis.io/docs/stack/json/) - JSON module documentation
139
+
140
+ - **Best Practices:**
141
+ - [Performance Optimization](/best-practices/performance-optimization) - Caching strategies
142
+ - [Security Guidelines](/best-practices/security-guidelines) - Redis security
@@ -40,14 +40,14 @@ import { SocketIOServerHelper, SocketIOBindingKeys, inject } from '@venizia/igni
40
40
  // ... in a service or controller
41
41
 
42
42
  @inject({ key: SocketIOBindingKeys.SOCKET_IO_INSTANCE })
43
- private io: SocketIOServerHelper;
43
+ private _io: SocketIOServerHelper;
44
44
 
45
- sendNotification(userId: string, message: string) {
46
- this.io.send({
47
- destination: userId, // Room or socket ID
45
+ sendNotification(opts: { userId: string; message: string }) {
46
+ this._io.send({
47
+ destination: opts.userId, // Room or socket ID
48
48
  payload: {
49
49
  topic: 'notification',
50
- data: { message },
50
+ data: { message: opts.message },
51
51
  },
52
52
  });
53
53
  }
@@ -101,3 +101,22 @@ socketClient.subscribe({
101
101
  },
102
102
  });
103
103
  ```
104
+
105
+ ## See Also
106
+
107
+ - **Related Concepts:**
108
+ - [Services](/guides/core-concepts/services) - Real-time communication in services
109
+
110
+ - **Other Helpers:**
111
+ - [Helpers Index](./index) - All available helpers
112
+ - [Redis Helper](./redis) - For Socket.IO scaling with Redis adapter
113
+
114
+ - **References:**
115
+ - [Socket.IO Component](/references/components/socket-io) - Full component setup
116
+
117
+ - **External Resources:**
118
+ - [Socket.IO Documentation](https://socket.io/docs/) - Official Socket.IO docs
119
+ - [Socket.IO Redis Adapter](https://socket.io/docs/v4/redis-adapter/) - Scaling guide
120
+
121
+ - **Tutorials:**
122
+ - [Real-Time Chat Application](/guides/tutorials/realtime-chat) - Socket.IO tutorial
@@ -128,7 +128,6 @@ const allKeys = memoryStore.keys();
128
128
  memoryStore.clear();
129
129
  ```
130
130
 
131
- ---
132
131
 
133
132
  ## `DiskHelper`
134
133
 
@@ -345,7 +344,6 @@ const cloudStorage = new MinioHelper({ /* ... */ });
345
344
  const localStorage = new DiskHelper({ basePath: './system-files' });
346
345
  ```
347
346
 
348
- ---
349
347
 
350
348
  ## `MinioHelper`
351
349
 
@@ -443,7 +441,6 @@ await minioClient.removeObject({ bucket: 'my-bucket', name: 'my-file.txt' });
443
441
  await minioClient.removeObjects({ bucket: 'my-bucket', names: ['file1.txt', 'file2.txt'] });
444
442
  ```
445
443
 
446
- ---
447
444
 
448
445
  ## DiskHelper vs MinioHelper Comparison
449
446
 
@@ -495,7 +492,6 @@ const systemStorage = new DiskHelper({ basePath: './system' });
495
492
  const tempStorage = new DiskHelper({ basePath: './temp' });
496
493
  ```
497
494
 
498
- ---
499
495
 
500
496
  ## Common Patterns
501
497
 
@@ -573,15 +569,27 @@ const storage = new ResilientStorage(
573
569
  );
574
570
  ```
575
571
 
576
- ---
577
572
 
578
- ## Related Documentation
573
+ ## See Also
579
574
 
580
- - [Static Asset Component](../components/static-asset.md) - Uses storage helpers
581
- - [Request Utilities](../utilities/request.md) - `parseMultipartBody`
582
- - [Base Helpers](./index.md) - Helper architecture
575
+ - **Related Concepts:**
576
+ - [Services](/guides/core-concepts/services) - File storage in services
577
+
578
+ - **Other Helpers:**
579
+ - [Helpers Index](./index) - All available helpers
580
+
581
+ - **References:**
582
+ - [Static Asset Component](/references/components/static-asset) - Serving stored files
583
+ - [Request Utilities](/references/utilities/request) - `parseMultipartBody` for file uploads
584
+
585
+ - **External Resources:**
586
+ - [MinIO Documentation](https://min.io/docs/minio/linux/index.html) - MinIO object storage
587
+ - [AWS S3 API](https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html) - S3-compatible API reference
588
+
589
+ - **Best Practices:**
590
+ - [Security Guidelines](/best-practices/security-guidelines) - File upload security
591
+ - [Deployment Strategies](/best-practices/deployment-strategies) - Storage in production
583
592
 
584
- ---
585
593
 
586
594
  ## TypeScript Interfaces Reference
587
595
 
@@ -113,3 +113,21 @@ const authTestPlan = TestPlan.newInstance({
113
113
 
114
114
  TestDescribe.withTestPlan({ testPlan: authTestPlan }).run();
115
115
  ```
116
+
117
+ ## See Also
118
+
119
+ - **Related Concepts:**
120
+ - [Dependency Injection](/guides/core-concepts/dependency-injection) - Testing with DI
121
+ - [Application](/guides/core-concepts/application/) - Application lifecycle in tests
122
+
123
+ - **Other Helpers:**
124
+ - [Helpers Index](./index) - All available helpers
125
+
126
+ - **External Resources:**
127
+ - [Node.js Test Runner](https://nodejs.org/api/test.html) - Native test module
128
+
129
+ - **Tutorials:**
130
+ - [Testing Guide](/guides/tutorials/testing) - Complete testing tutorial
131
+
132
+ - **Best Practices:**
133
+ - [Troubleshooting Tips](/best-practices/troubleshooting-tips) - Debugging tests
@@ -149,3 +149,19 @@ type TConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string | number>;
149
149
  ```
150
150
 
151
151
  Extract constant value types from a class.
152
+
153
+ ## See Also
154
+
155
+ - **Related Concepts:**
156
+ - [Dependency Injection](/guides/core-concepts/dependency-injection) - DI types and patterns
157
+ - [Repositories](/guides/core-concepts/persistent/repositories) - Repository mixins use these types
158
+
159
+ - **Other Helpers:**
160
+ - [Helpers Index](./index) - All available helpers
161
+
162
+ - **References:**
163
+ - [Repository Mixins](/references/base/repositories/mixins) - Uses mixin types
164
+ - [Utilities Index](/references/utilities/index) - Type utilities
165
+
166
+ - **Best Practices:**
167
+ - [Architectural Patterns](/best-practices/architectural-patterns) - TypeScript patterns
@@ -0,0 +1,167 @@
1
+ # UID Helper
2
+
3
+ Snowflake ID generator with Base62 encoding for generating unique, time-sortable IDs suitable for distributed systems.
4
+
5
+ ## Quick Reference
6
+
7
+ | Class | Purpose | Key Features |
8
+ |-------|---------|--------------|
9
+ | **SnowflakeConfig** | Configuration constants | Bit structure, limits, defaults |
10
+ | **SnowflakeUidHelper** | ID generation | Snowflake IDs, Base62 encoding/decoding |
11
+
12
+ ### Snowflake ID Structure (70 bits)
13
+
14
+ | Component | Bits | Range | Purpose |
15
+ |-----------|------|-------|---------|
16
+ | Timestamp | 48 | ~8,919 years | Time since epoch |
17
+ | Worker ID | 10 | 0-1023 | Unique worker identifier |
18
+ | Sequence | 12 | 0-4095 | IDs per millisecond |
19
+
20
+ ### Key Specifications
21
+
22
+ | Spec | Value |
23
+ |------|-------|
24
+ | Base62 Output | 10-12 characters |
25
+ | Throughput | 4,096,000 IDs/second/worker |
26
+ | Max Workers | 1024 |
27
+ | Lifespan | Until ~10,944 AD |
28
+ | Default Epoch | 2025-01-01 00:00:00 UTC |
29
+
30
+ ## Basic Usage
31
+
32
+ ### Creating an Instance
33
+
34
+ ```typescript
35
+ import { SnowflakeUidHelper, SnowflakeConfig } from '@venizia/ignis-helpers';
36
+
37
+ // Use defaults (workerId: 199, epoch: 2025-01-01 00:00:00 UTC)
38
+ const generator = new SnowflakeUidHelper();
39
+
40
+ // Or with custom values
41
+ const customGenerator = new SnowflakeUidHelper({
42
+ workerId: 123,
43
+ epoch: BigInt(1735689600000),
44
+ });
45
+ ```
46
+
47
+ ### Generating IDs
48
+
49
+ ```typescript
50
+ // Generate Base62 encoded ID (recommended for most use cases)
51
+ const id = generator.nextId();
52
+ // => e.g., "9du1sJXO88"
53
+
54
+ // Generate raw Snowflake ID as bigint
55
+ const snowflakeId = generator.nextSnowflake();
56
+ // => e.g., 130546360012247045n
57
+ ```
58
+
59
+ ## Base62 Encoding/Decoding
60
+
61
+ ### Encode a BigInt to Base62
62
+
63
+ ```typescript
64
+ const encoded = generator.encodeBase62(130546360012247045n);
65
+ // => "9du1sJXO88"
66
+ ```
67
+
68
+ ### Decode Base62 to BigInt
69
+
70
+ ```typescript
71
+ const decoded = generator.decodeBase62("9du1sJXO88");
72
+ // => 130546360012247045n
73
+ ```
74
+
75
+ ## Parsing and Extracting Components
76
+
77
+ ### Parse a Base62 ID
78
+
79
+ ```typescript
80
+ const parsed = generator.parseId("9du1sJXO88");
81
+ // => {
82
+ // raw: 130546360012247045n,
83
+ // timestamp: Date,
84
+ // workerId: 199,
85
+ // sequence: 0
86
+ // }
87
+ ```
88
+
89
+ ### Extract Individual Components
90
+
91
+ ```typescript
92
+ const snowflakeId = generator.nextSnowflake();
93
+
94
+ // Extract timestamp
95
+ const timestamp = generator.extractTimestamp(snowflakeId);
96
+ // => Date object
97
+
98
+ // Extract worker ID
99
+ const workerId = generator.extractWorkerId(snowflakeId);
100
+ // => 199
101
+
102
+ // Extract sequence
103
+ const sequence = generator.extractSequence(snowflakeId);
104
+ // => 0-4095
105
+ ```
106
+
107
+ ## Configuration
108
+
109
+ ### SnowflakeConfig Constants
110
+
111
+ ```typescript
112
+ import { SnowflakeConfig } from '@venizia/ignis-helpers';
113
+
114
+ SnowflakeConfig.DEFAULT_EPOCH // BigInt(1735689600000) - 2025-01-01 00:00:00 UTC
115
+ SnowflakeConfig.MAX_WORKER_ID // 1023n
116
+ SnowflakeConfig.MAX_SEQUENCE // 4095n
117
+ SnowflakeConfig.TIMESTAMP_SHIFT // 22n
118
+ SnowflakeConfig.WORKER_ID_SHIFT // 12n
119
+ ```
120
+
121
+ ### Constructor Options
122
+
123
+ | Option | Type | Default | Description |
124
+ |--------|------|---------|-------------|
125
+ | `workerId` | `number` | `199` | Worker ID (0-1023) |
126
+ | `epoch` | `bigint` | `SnowflakeConfig.DEFAULT_EPOCH` | Custom epoch timestamp in milliseconds |
127
+
128
+ ## Error Handling
129
+
130
+ The helper throws errors in these cases:
131
+
132
+ - **Invalid Worker ID**: Worker ID outside 0-1023 range
133
+ - **Invalid Epoch**: Epoch is zero, negative, or in the future
134
+ - **Clock Backward**: System clock moved backward by more than 100ms
135
+ - **Invalid Base62**: Decoding a string with invalid characters
136
+
137
+ ```typescript
138
+ try {
139
+ const generator = new SnowflakeUidHelper({ workerId: 2000 }); // Invalid
140
+ } catch (error) {
141
+ // Worker ID must be between 0 and 1023
142
+ }
143
+ ```
144
+
145
+ ## Best Practices
146
+
147
+ 1. **Use unique worker IDs** in distributed systems to prevent ID collisions
148
+ 2. **Keep epoch consistent** across all instances to ensure proper ID ordering
149
+ 3. **Use `nextId()`** for most cases (returns compact Base62 string)
150
+ 4. **Use `nextSnowflake()`** when you need the raw bigint for arithmetic operations
151
+
152
+ ## See Also
153
+
154
+ - **Related Concepts:**
155
+ - [Models](/guides/core-concepts/persistent/models) - Using UIDs as primary keys
156
+ - [Services](/guides/core-concepts/services) - Generating unique IDs
157
+
158
+ - **Other Helpers:**
159
+ - [Helpers Index](./index) - All available helpers
160
+ - [Crypto Helper](./crypto) - For cryptographic random values
161
+
162
+ - **External Resources:**
163
+ - [Snowflake ID](https://en.wikipedia.org/wiki/Snowflake_ID) - Snowflake algorithm explained
164
+ - [Base62 Encoding](https://en.wikipedia.org/wiki/Base62) - Base62 encoding overview
165
+
166
+ - **Best Practices:**
167
+ - [Data Modeling](/best-practices/data-modeling) - ID generation strategies
@@ -160,3 +160,19 @@ const workerBus = new BaseWorkerBusHelper({
160
160
  }),
161
161
  });
162
162
  ```
163
+
164
+ ## See Also
165
+
166
+ - **Related Concepts:**
167
+ - [Services](/guides/core-concepts/services) - CPU-intensive tasks in services
168
+
169
+ - **Other Helpers:**
170
+ - [Helpers Index](./index) - All available helpers
171
+ - [Queue Helper](./queue) - For I/O-bound background tasks
172
+
173
+ - **External Resources:**
174
+ - [Node.js Worker Threads](https://nodejs.org/api/worker_threads.html) - Official worker_threads API
175
+ - [MessageChannel](https://nodejs.org/api/worker_threads.html#class-messagechannel) - Two-way communication
176
+
177
+ - **Best Practices:**
178
+ - [Performance Optimization](/best-practices/performance-optimization) - Worker thread strategies