@venizia/ignis-docs 0.2.0 → 0.2.1-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 (142) hide show
  1. package/README.md +14 -14
  2. package/content/best-practices/api-usage-examples.md +39 -19
  3. package/content/best-practices/architectural-patterns.md +22 -11
  4. package/content/best-practices/architecture-decisions.md +29 -16
  5. package/content/best-practices/code-style-standards/advanced-patterns.md +43 -31
  6. package/content/best-practices/code-style-standards/constants-configuration.md +19 -4
  7. package/content/best-practices/code-style-standards/control-flow.md +33 -1
  8. package/content/best-practices/code-style-standards/documentation.md +28 -8
  9. package/content/best-practices/code-style-standards/function-patterns.md +15 -4
  10. package/content/best-practices/code-style-standards/index.md +7 -2
  11. package/content/best-practices/code-style-standards/naming-conventions.md +26 -2
  12. package/content/best-practices/code-style-standards/route-definitions.md +9 -5
  13. package/content/best-practices/code-style-standards/tooling.md +14 -1
  14. package/content/best-practices/code-style-standards/type-safety.md +39 -6
  15. package/content/best-practices/common-pitfalls.md +59 -35
  16. package/content/best-practices/contribution-workflow.md +6 -2
  17. package/content/best-practices/data-modeling.md +78 -62
  18. package/content/best-practices/deployment-strategies.md +56 -19
  19. package/content/best-practices/error-handling.md +182 -93
  20. package/content/best-practices/index.md +6 -0
  21. package/content/best-practices/performance-optimization.md +26 -13
  22. package/content/best-practices/security-guidelines.md +35 -9
  23. package/content/best-practices/testing-strategies.md +7 -2
  24. package/content/best-practices/troubleshooting-tips.md +27 -17
  25. package/content/extensions/components/api-reference.md +107 -322
  26. package/content/extensions/components/authentication/api.md +454 -603
  27. package/content/extensions/components/authentication/errors.md +121 -498
  28. package/content/extensions/components/authentication/index.md +88 -801
  29. package/content/extensions/components/authentication/usage.md +207 -956
  30. package/content/extensions/components/authorization/api.md +736 -656
  31. package/content/extensions/components/authorization/errors.md +168 -206
  32. package/content/extensions/components/authorization/index.md +82 -797
  33. package/content/extensions/components/authorization/usage.md +194 -527
  34. package/content/extensions/components/health-check.md +71 -243
  35. package/content/extensions/components/mail/api.md +504 -287
  36. package/content/extensions/components/mail/errors.md +73 -61
  37. package/content/extensions/components/mail/index.md +96 -467
  38. package/content/extensions/components/mail/usage.md +130 -172
  39. package/content/extensions/components/request-tracker.md +66 -173
  40. package/content/extensions/components/socket-io/api.md +195 -13
  41. package/content/extensions/components/socket-io/errors.md +3 -3
  42. package/content/extensions/components/socket-io/index.md +50 -337
  43. package/content/extensions/components/socket-io/usage.md +143 -26
  44. package/content/extensions/components/static-asset/api.md +410 -142
  45. package/content/extensions/components/static-asset/errors.md +110 -53
  46. package/content/extensions/components/static-asset/index.md +79 -608
  47. package/content/extensions/components/static-asset/usage.md +180 -300
  48. package/content/extensions/components/websocket/api.md +275 -399
  49. package/content/extensions/components/websocket/errors.md +47 -56
  50. package/content/extensions/components/websocket/index.md +74 -407
  51. package/content/extensions/components/websocket/usage.md +110 -341
  52. package/content/extensions/helpers/cron/index.md +51 -160
  53. package/content/extensions/helpers/crypto/index.md +62 -483
  54. package/content/extensions/helpers/crypto/reference.md +456 -0
  55. package/content/extensions/helpers/env/index.md +60 -178
  56. package/content/extensions/helpers/error/index.md +221 -207
  57. package/content/extensions/helpers/inversion/index.md +65 -556
  58. package/content/extensions/helpers/inversion/reference.md +522 -0
  59. package/content/extensions/helpers/kafka/admin.md +20 -1
  60. package/content/extensions/helpers/kafka/compile-binary.md +41 -35
  61. package/content/extensions/helpers/kafka/consumer.md +54 -20
  62. package/content/extensions/helpers/kafka/examples.md +21 -16
  63. package/content/extensions/helpers/kafka/index.md +80 -610
  64. package/content/extensions/helpers/kafka/producer.md +134 -5
  65. package/content/extensions/helpers/kafka/schema-registry.md +45 -70
  66. package/content/extensions/helpers/logger/hf-logger.md +193 -0
  67. package/content/extensions/helpers/logger/index.md +64 -563
  68. package/content/extensions/helpers/logger/pino.md +85 -0
  69. package/content/extensions/helpers/logger/reference.md +746 -0
  70. package/content/extensions/helpers/network/api.md +241 -195
  71. package/content/extensions/helpers/network/index.md +72 -530
  72. package/content/extensions/helpers/queue/index.md +72 -900
  73. package/content/extensions/helpers/queue/reference.md +467 -0
  74. package/content/extensions/helpers/redis/index.md +73 -645
  75. package/content/extensions/helpers/redis/reference.md +727 -0
  76. package/content/extensions/helpers/secrets/index.md +66 -0
  77. package/content/extensions/helpers/socket-io/api.md +305 -203
  78. package/content/extensions/helpers/socket-io/index.md +66 -432
  79. package/content/extensions/helpers/storage/api.md +564 -462
  80. package/content/extensions/helpers/storage/index.md +77 -573
  81. package/content/extensions/helpers/types/index.md +66 -499
  82. package/content/extensions/helpers/types/reference.md +650 -0
  83. package/content/extensions/helpers/uid/index.md +58 -227
  84. package/content/extensions/helpers/websocket/api.md +329 -216
  85. package/content/extensions/helpers/websocket/index.md +65 -503
  86. package/content/extensions/helpers/worker-thread/index.md +58 -396
  87. package/content/extensions/helpers/worker-thread/reference.md +428 -0
  88. package/content/guides/core-concepts/persistent/models.md +1 -1
  89. package/content/guides/core-concepts/persistent/search-typesense.md +3 -3
  90. package/content/guides/core-concepts/persistent/transactions.md +1 -1
  91. package/content/guides/core-concepts/secrets-vault.md +177 -0
  92. package/content/guides/core-concepts/services.md +1 -1
  93. package/content/guides/migrations/redis-helpers-migration.md +1 -1
  94. package/content/guides/migrations/unified-connectors-migration.md +2 -2
  95. package/content/guides/tutorials/ecommerce-api.md +3 -8
  96. package/content/references/base/application.md +1 -1
  97. package/content/references/base/connectors.md +79 -136
  98. package/content/references/base/datasources-reference.md +599 -0
  99. package/content/references/base/datasources.md +84 -444
  100. package/content/references/base/dependency-injection.md +17 -39
  101. package/content/references/base/filter-system/application-usage.md +69 -121
  102. package/content/references/base/filter-system/array-operators.md +12 -0
  103. package/content/references/base/filter-system/comparison-operators.md +12 -0
  104. package/content/references/base/filter-system/default-filter.md +136 -348
  105. package/content/references/base/filter-system/fields-order-pagination.md +38 -16
  106. package/content/references/base/filter-system/index.md +106 -257
  107. package/content/references/base/filter-system/json-filtering.md +12 -2
  108. package/content/references/base/filter-system/list-operators.md +16 -2
  109. package/content/references/base/filter-system/logical-operators.md +13 -0
  110. package/content/references/base/filter-system/null-operators.md +13 -0
  111. package/content/references/base/filter-system/pattern-matching.md +12 -0
  112. package/content/references/base/filter-system/quick-reference.md +11 -2
  113. package/content/references/base/filter-system/range-operators.md +12 -0
  114. package/content/references/base/filter-system/tips.md +70 -133
  115. package/content/references/base/filter-system/use-cases.md +156 -233
  116. package/content/references/base/middlewares.md +35 -21
  117. package/content/references/base/models-reference.md +886 -0
  118. package/content/references/base/models.md +80 -1452
  119. package/content/references/base/repositories/advanced.md +156 -192
  120. package/content/references/base/repositories/index.md +77 -650
  121. package/content/references/base/repositories/mixins.md +22 -18
  122. package/content/references/base/repositories/relations.md +123 -171
  123. package/content/references/base/repositories/soft-deletable.md +58 -56
  124. package/content/references/base/secrets.md +263 -0
  125. package/content/references/base/services.md +2 -2
  126. package/content/references/configuration/environment-variables.md +48 -4
  127. package/content/references/configuration/index.md +49 -31
  128. package/content/references/quick-reference.md +3 -16
  129. package/content/references/utilities/crypto.md +35 -76
  130. package/content/references/utilities/date.md +33 -73
  131. package/content/references/utilities/index.md +1 -1
  132. package/content/references/utilities/jsx-reference.md +298 -0
  133. package/content/references/utilities/jsx.md +82 -525
  134. package/content/references/utilities/module.md +29 -62
  135. package/content/references/utilities/parse.md +34 -64
  136. package/content/references/utilities/performance.md +33 -58
  137. package/content/references/utilities/promise.md +28 -62
  138. package/content/references/utilities/request.md +57 -218
  139. package/content/references/utilities/schema.md +43 -137
  140. package/content/references/utilities/statuses-reference.md +361 -0
  141. package/content/references/utilities/statuses.md +63 -667
  142. package/package.json +8 -8
@@ -0,0 +1,361 @@
1
+ ---
2
+ title: Statuses - Full Reference
3
+ description: Complete reference for every status code, group set, specialized status class, and binding-namespace constant
4
+ difficulty: beginner
5
+ lastUpdated: 2026-07-16
6
+ ---
7
+
8
+ # Statuses - Full Reference
9
+
10
+ Exhaustive reference for `Statuses`, its specialized subclasses, and the `BindingNamespaces`/`CoreBindings` constant catalogs. For an introduction and the common tasks, start with the [Statuses overview](/references/utilities/statuses).
11
+
12
+ **Files:**
13
+
14
+ - [`packages/core/src/common/statuses.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core/src/common/statuses.ts)
15
+ - [`packages/core/src/common/bindings.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core/src/common/bindings.ts)
16
+
17
+ ## `Statuses`
18
+
19
+ A static class of `'NNN_NAME'` status code constants, grouped by an HTTP-inspired numeric prefix, plus `Set` groupings and validator methods.
20
+
21
+ `Source ->` [`packages/core/src/common/statuses.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core/src/common/statuses.ts)
22
+
23
+ ### Status code scheme
24
+
25
+ | Prefix | Category | Meaning | Reversibility |
26
+ |--------|----------|---------|----------------|
27
+ | `0xx` | Initial | Entity creation/draft state | N/A |
28
+ | `1xx` | Pending | Awaiting action or decision | Reversible |
29
+ | `2xx` | Active | In progress or running | Reversible |
30
+ | `3xx` | Completed | Positive terminal state | Terminal |
31
+ | `4xx` | Inactive | Negative but reversible | Reversible |
32
+ | `5xx` | Failed | Negative terminal state | Terminal |
33
+
34
+ ### `0xx` - Initial states
35
+
36
+ | Constant | Value | Description |
37
+ |----------|-------|-------------|
38
+ | `UNKNOWN` | `'000_UNKNOWN'` | Unknown or uninitialized state |
39
+ | `DRAFT` | `'001_DRAFT'` | Draft state, not yet finalized |
40
+
41
+ ### `1xx` - Pending/waiting states
42
+
43
+ | Constant | Value | Description |
44
+ |----------|-------|-------------|
45
+ | `NEW` | `'100_NEW'` | Newly created, not yet processed |
46
+ | `QUEUED` | `'101_QUEUED'` | Queued for processing |
47
+ | `SCHEDULED` | `'102_SCHEDULED'` | Scheduled for future execution |
48
+ | `PENDING` | `'103_PENDING'` | Awaiting action or decision |
49
+ | `IN_REVIEW` | `'104_IN_REVIEW'` | Under review or approval process |
50
+
51
+ ### `2xx` - Active/running states
52
+
53
+ | Constant | Value | Description |
54
+ |----------|-------|-------------|
55
+ | `ENABLED` | `'200_ENABLED'` | Feature or entity is enabled |
56
+ | `ACTIVATED` | `'201_ACTIVATED'` | Account or service is active |
57
+ | `RUNNING` | `'202_RUNNING'` | Process is currently running |
58
+ | `PROCESSING` | `'203_PROCESSING'` | Being actively processed |
59
+ | `SENT` | `'204_SENT'` | Message/item has been sent |
60
+ | `RECEIVED` | `'205_RECEIVED'` | Message/item has been received |
61
+
62
+ ### `3xx` - Completed states
63
+
64
+ Positive terminal states.
65
+
66
+ | Constant | Value | Description |
67
+ |----------|-------|-------------|
68
+ | `PARTIAL` | `'300_PARTIAL'` | Partially completed |
69
+ | `APPROVED` | `'301_APPROVED'` | Approved by reviewer |
70
+ | `SUCCESS` | `'302_SUCCESS'` | Successfully completed |
71
+ | `COMPLETED` | `'303_COMPLETED'` | Fully completed |
72
+ | `SETTLED` | `'304_SETTLED'` | Finalized or settled |
73
+ | `CONFIRMED` | `'305_CONFIRMED'` | Confirmed by user or system |
74
+
75
+ ### `4xx` - Inactive states
76
+
77
+ Negative but reversible - the entity can be reactivated.
78
+
79
+ | Constant | Value | Description |
80
+ |----------|-------|-------------|
81
+ | `DISABLED` | `'400_DISABLED'` | Feature or entity is disabled |
82
+ | `DEACTIVATED` | `'401_DEACTIVATED'` | Account or service is deactivated |
83
+ | `SUSPENDED` | `'402_SUSPENDED'` | Temporarily suspended |
84
+ | `BLOCKED` | `'403_BLOCKED'` | Access blocked (e.g. banned user) |
85
+ | `CLOSED` | `'404_CLOSED'` | Closed but can be reopened |
86
+ | `ARCHIVED` | `'405_ARCHIVED'` | Archived for record keeping |
87
+ | `PAUSED` | `'406_PAUSED'` | Paused, can be resumed |
88
+ | `REVOKED` | `'407_REVOKED'` | Permission or access revoked |
89
+ | `REFUNDED` | `'408_REFUNDED'` | Payment or transaction refunded |
90
+
91
+ ### `5xx` - Failed/error states
92
+
93
+ Negative terminal states - permanent failure or cancellation.
94
+
95
+ | Constant | Value | Description |
96
+ |----------|-------|-------------|
97
+ | `FAIL` | `'500_FAIL'` | General failure |
98
+ | `EXPIRED` | `'501_EXPIRED'` | Expired and no longer valid |
99
+ | `TIMEOUT` | `'502_TIMEOUT'` | Operation timed out |
100
+ | `SKIPPED` | `'503_SKIPPED'` | Intentionally skipped |
101
+ | `ABORTED` | `'504_ABORTED'` | Aborted by system |
102
+ | `CANCELLED` | `'505_CANCELLED'` | Cancelled by user/admin |
103
+ | `DELETED` | `'506_DELETED'` | Soft deleted |
104
+ | `REJECTED` | `'507_REJECTED'` | Rejected by reviewer |
105
+
106
+ ### Group sets
107
+
108
+ Each phase has a static `Set<string>` of its member statuses, plus `SCHEME_SET`, the union of all six.
109
+
110
+ | Set | Members |
111
+ |-----|---------|
112
+ | `INITIAL_SCHEME_SET` | `UNKNOWN`, `DRAFT` |
113
+ | `PENDING_SCHEME_SET` | `NEW`, `QUEUED`, `SCHEDULED`, `PENDING`, `IN_REVIEW` |
114
+ | `ACTIVE_SCHEME_SET` | `ENABLED`, `ACTIVATED`, `RUNNING`, `PROCESSING`, `SENT`, `RECEIVED` |
115
+ | `COMPLETED_SCHEME_SET` | `COMPLETED`, `SUCCESS`, `PARTIAL`, `SETTLED`, `APPROVED`, `CONFIRMED` |
116
+ | `INACTIVE_SCHEME_SET` | `DISABLED`, `DEACTIVATED`, `SUSPENDED`, `BLOCKED`, `CLOSED`, `ARCHIVED`, `PAUSED`, `REVOKED`, `REFUNDED` |
117
+ | `FAILED_SCHEME_SET` | `FAIL`, `EXPIRED`, `TIMEOUT`, `SKIPPED`, `ABORTED`, `CANCELLED`, `DELETED`, `REJECTED` |
118
+ | `SCHEME_SET` | All statuses across all six sets combined |
119
+
120
+ ```typescript
121
+ import { Statuses } from '@venizia/ignis';
122
+
123
+ // Membership check
124
+ Statuses.ACTIVE_SCHEME_SET.has(order.status);
125
+
126
+ // Spread into a query operator
127
+ await jobRepository.find({
128
+ filter: { where: { status: { inq: [...Statuses.FAILED_SCHEME_SET] } } },
129
+ });
130
+ ```
131
+
132
+ ### Validation methods
133
+
134
+ Each method checks membership in the matching `*_SCHEME_SET`; all take a `string` and return `boolean`.
135
+
136
+ | Method | Checks against |
137
+ |--------|-----------------|
138
+ | `isInitial(status)` | `INITIAL_SCHEME_SET` |
139
+ | `isPending(status)` | `PENDING_SCHEME_SET` |
140
+ | `isActive(status)` | `ACTIVE_SCHEME_SET` |
141
+ | `isCompleted(status)` | `COMPLETED_SCHEME_SET` |
142
+ | `isInactive(status)` | `INACTIVE_SCHEME_SET` |
143
+ | `isFailed(status)` | `FAILED_SCHEME_SET` |
144
+ | `isValid(status)` | `SCHEME_SET` (all statuses) |
145
+
146
+ ```typescript
147
+ export class Statuses {
148
+ static isInitial(status: string): boolean;
149
+ static isPending(status: string): boolean;
150
+ static isActive(status: string): boolean;
151
+ static isCompleted(status: string): boolean;
152
+ static isInactive(status: string): boolean;
153
+ static isFailed(status: string): boolean;
154
+ static isValid(status: string): boolean;
155
+ }
156
+ ```
157
+
158
+ ## Specialized status classes
159
+
160
+ Each specialized class references `Statuses` values directly - it does not define new status strings, only a named subset plus its own `SCHEME_SET` and `isValid()`.
161
+
162
+ ### `MigrationStatuses`
163
+
164
+ Database migration tracking.
165
+
166
+ ```typescript
167
+ export class MigrationStatuses {
168
+ static readonly UNKNOWN = Statuses.UNKNOWN; // '000_UNKNOWN'
169
+ static readonly SUCCESS = Statuses.SUCCESS; // '302_SUCCESS'
170
+ static readonly FAIL = Statuses.FAIL; // '500_FAIL'
171
+
172
+ static readonly SCHEME_SET = new Set([this.UNKNOWN, this.SUCCESS, this.FAIL]);
173
+
174
+ static isValid(scheme: string): boolean;
175
+ }
176
+ ```
177
+
178
+ ### `CommonStatuses`
179
+
180
+ Shared statuses reused across entity types.
181
+
182
+ ```typescript
183
+ export class CommonStatuses {
184
+ static readonly UNKNOWN = Statuses.UNKNOWN; // '000_UNKNOWN'
185
+ static readonly ACTIVATED = Statuses.ACTIVATED; // '201_ACTIVATED'
186
+ static readonly DEACTIVATED = Statuses.DEACTIVATED; // '401_DEACTIVATED'
187
+ static readonly BLOCKED = Statuses.BLOCKED; // '403_BLOCKED'
188
+ static readonly ARCHIVED = Statuses.ARCHIVED; // '405_ARCHIVED'
189
+
190
+ static readonly SCHEME_SET = new Set([
191
+ this.UNKNOWN,
192
+ this.ACTIVATED,
193
+ this.DEACTIVATED,
194
+ this.BLOCKED,
195
+ this.ARCHIVED,
196
+ ]);
197
+
198
+ static isValid(scheme: string): boolean;
199
+ }
200
+ ```
201
+
202
+ ### `UserStatuses` / `RoleStatuses`
203
+
204
+ Both classes `extend CommonStatuses` with an empty body - they add no members of their own, inheriting every constant, `SCHEME_SET`, and `isValid()` unchanged. They exist as distinct, named types for user- and role-domain statuses.
205
+
206
+ ```typescript
207
+ export class UserStatuses extends CommonStatuses {}
208
+ export class RoleStatuses extends CommonStatuses {}
209
+ ```
210
+
211
+ ### `UserTypes`
212
+
213
+ Not a status class - a separate classification of user origin. Unrelated to lifecycle phase.
214
+
215
+ ```typescript
216
+ export class UserTypes {
217
+ static readonly SYSTEM = 'SYSTEM'; // System-generated users
218
+ static readonly LINKED = 'LINKED'; // External auth (OAuth, SAML, etc.)
219
+
220
+ static readonly SCHEME_SET = new Set([this.SYSTEM, this.LINKED]);
221
+
222
+ static isValid(orgType: string): boolean;
223
+ }
224
+ ```
225
+
226
+ ## Binding namespaces
227
+
228
+ Organizes dependency-injection binding keys by artifact type. Distinct from `Statuses` - not a lifecycle catalog.
229
+
230
+ `Source ->` [`packages/core/src/common/bindings.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core/src/common/bindings.ts)
231
+
232
+ ### `BindingNamespaces`
233
+
234
+ ```typescript
235
+ export class BindingNamespaces {
236
+ static readonly COMPONENT = 'components';
237
+ static readonly DATASOURCE = 'datasources';
238
+ static readonly REPOSITORY = 'repositories';
239
+ static readonly MODEL = 'models';
240
+ static readonly SERVICE = 'services';
241
+ static readonly MIDDLEWARE = 'middlewares';
242
+ static readonly PROVIDER = 'providers';
243
+ static readonly CONTROLLER = 'controllers';
244
+ static readonly BOOTERS = 'booters';
245
+
246
+ static createNamespace(opts: { name: string }): string;
247
+ }
248
+ ```
249
+
250
+ Each namespace constant is itself built via `createNamespace()`; the method is also public for constructing custom namespace strings.
251
+
252
+ `TBindingNamespace` (`TConstValue<typeof BindingNamespaces>`) is the union type of all `BindingNamespaces` values, derived at compile time rather than hand-maintained.
253
+
254
+ ### `CoreBindings`
255
+
256
+ Application-level binding keys. Extends `BindingKeys` from `@venizia/ignis-inversion`.
257
+
258
+ ```typescript
259
+ export class CoreBindings extends BindingKeys {
260
+ static readonly APPLICATION_INSTANCE = '@app/instance';
261
+ static readonly APPLICATION_SERVER = '@app/server';
262
+ static readonly APPLICATION_CONFIG = '@app/config';
263
+ static readonly APPLICATION_PROJECT_ROOT = '@app/project_root';
264
+ static readonly APPLICATION_ROOT_ROUTER = '@app/router/root';
265
+ static readonly APPLICATION_ENVIRONMENTS = '@app/environments';
266
+ static readonly APPLICATION_MIDDLEWARE_OPTIONS = '@app/middleware_options';
267
+ }
268
+ ```
269
+
270
+ | Constant | Value | Description |
271
+ |----------|-------|-------------|
272
+ | `APPLICATION_INSTANCE` | `'@app/instance'` | The running application instance |
273
+ | `APPLICATION_SERVER` | `'@app/server'` | The underlying HTTP server |
274
+ | `APPLICATION_CONFIG` | `'@app/config'` | Resolved application configuration |
275
+ | `APPLICATION_PROJECT_ROOT` | `'@app/project_root'` | Absolute path to the project root |
276
+ | `APPLICATION_ROOT_ROUTER` | `'@app/router/root'` | The root Hono router |
277
+ | `APPLICATION_ENVIRONMENTS` | `'@app/environments'` | Loaded environment variables |
278
+ | `APPLICATION_MIDDLEWARE_OPTIONS` | `'@app/middleware_options'` | Global middleware configuration |
279
+
280
+ ```typescript
281
+ import { CoreBindings } from '@venizia/ignis';
282
+
283
+ const app = container.get(CoreBindings.APPLICATION_INSTANCE);
284
+ const config = container.get(CoreBindings.APPLICATION_CONFIG);
285
+ ```
286
+
287
+ ## Usage patterns
288
+
289
+ ### Entity lifecycle in a service
290
+
291
+ ```typescript
292
+ import { Statuses } from '@venizia/ignis';
293
+
294
+ class OrderService extends BaseService {
295
+ async createOrder(data: CreateOrderDto) {
296
+ return this.orderRepository.create({ data: { ...data, status: Statuses.NEW } });
297
+ }
298
+
299
+ async processOrder(orderId: string) {
300
+ await this.orderRepository.updateById({
301
+ id: orderId,
302
+ data: { status: Statuses.PROCESSING, startedAt: new Date() },
303
+ });
304
+
305
+ try {
306
+ await this.paymentService.charge(orderId);
307
+ await this.orderRepository.updateById({
308
+ id: orderId,
309
+ data: { status: Statuses.COMPLETED, completedAt: new Date() },
310
+ });
311
+ } catch (error) {
312
+ await this.orderRepository.updateById({
313
+ id: orderId,
314
+ data: { status: Statuses.FAIL, failedAt: new Date() },
315
+ });
316
+ throw error;
317
+ }
318
+ }
319
+
320
+ async cancelOrder(orderId: string) {
321
+ const order = await this.orderRepository.findById({ id: orderId });
322
+ if (Statuses.isCompleted(order.status) || Statuses.isFailed(order.status)) {
323
+ throw getError({ message: 'Cannot cancel a completed or failed order' });
324
+ }
325
+ await this.orderRepository.updateById({
326
+ id: orderId,
327
+ data: { status: Statuses.CANCELLED },
328
+ });
329
+ }
330
+ }
331
+ ```
332
+
333
+ ### Validating a status transition
334
+
335
+ ```typescript
336
+ import { Statuses } from '@venizia/ignis';
337
+
338
+ function validateStatusTransition(from: string, to: string) {
339
+ if (!Statuses.isValid(to)) {
340
+ throw getError({ message: `Invalid status: ${to}` });
341
+ }
342
+ if (Statuses.isCompleted(from) || Statuses.isFailed(from)) {
343
+ throw getError({ message: 'Cannot transition from a terminal state' });
344
+ }
345
+ return true;
346
+ }
347
+ ```
348
+
349
+ ## Best practices
350
+
351
+ - **Use the constants, not magic strings.** `Statuses.COMPLETED`, never `'303_COMPLETED'` - typos in a raw string pass type checking silently.
352
+ - **Validate before writing.** Call `Statuses.isValid()` on any status that originates outside the constant catalog (request body, external system) before persisting it.
353
+ - **Prefer the `is*` helpers over raw set checks.** `Statuses.isActive(x)` reads better than `Statuses.ACTIVE_SCHEME_SET.has(x)` at call sites, though both are equivalent.
354
+ - **Check terminal states before mutating.** `isCompleted()` and `isFailed()` both signal a terminal status - guard state-changing operations against both.
355
+
356
+ ## See also
357
+
358
+ - [Statuses overview](/references/utilities/statuses) - introduction and common tasks
359
+ - [Models](/references/base/models) - entity definitions using statuses
360
+ - [Repositories](/references/base/repositories/) - querying and updating by status
361
+ - [Filter System](/references/base/filter-system/) - `inq`/`nin` operators for `*_SCHEME_SET`