@explorins/pers-shared 2.1.36 → 2.1.37

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 (214) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/index.d.ts +2 -0
  3. package/dist/cjs/index.d.ts.map +1 -1
  4. package/dist/cjs/index.js +5 -2
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/shared-lib/errors/domains/wallet-errors.js.map +1 -1
  7. package/dist/cjs/shared-patterns/database/index.d.ts +6 -0
  8. package/dist/cjs/shared-patterns/database/index.d.ts.map +1 -0
  9. package/dist/cjs/shared-patterns/database/index.js +24 -0
  10. package/dist/cjs/shared-patterns/database/index.js.map +1 -0
  11. package/dist/cjs/shared-patterns/database/models/base.model.d.ts +7 -0
  12. package/dist/cjs/shared-patterns/database/models/base.model.d.ts.map +1 -0
  13. package/dist/cjs/shared-patterns/database/models/base.model.js +11 -0
  14. package/dist/cjs/shared-patterns/database/models/base.model.js.map +1 -0
  15. package/dist/cjs/shared-patterns/database/models/fixture.model.d.ts +4 -0
  16. package/dist/cjs/shared-patterns/database/models/fixture.model.d.ts.map +1 -0
  17. package/dist/cjs/shared-patterns/database/models/fixture.model.js +8 -0
  18. package/dist/cjs/shared-patterns/database/models/fixture.model.js.map +1 -0
  19. package/dist/cjs/shared-patterns/database/schemas/fixture-fields.schema.d.ts +5 -0
  20. package/dist/cjs/shared-patterns/database/schemas/fixture-fields.schema.d.ts.map +1 -0
  21. package/dist/cjs/shared-patterns/database/schemas/fixture-fields.schema.js +11 -0
  22. package/dist/cjs/shared-patterns/database/schemas/fixture-fields.schema.js.map +1 -0
  23. package/dist/cjs/shared-patterns/database/schemas/shared-fields.schema.d.ts +44 -0
  24. package/dist/cjs/shared-patterns/database/schemas/shared-fields.schema.d.ts.map +1 -0
  25. package/dist/cjs/shared-patterns/database/schemas/shared-fields.schema.js +64 -0
  26. package/dist/cjs/shared-patterns/database/schemas/shared-fields.schema.js.map +1 -0
  27. package/dist/cjs/shared-patterns/database/schemas/tenant-fields.schema.d.ts +51 -0
  28. package/dist/cjs/shared-patterns/database/schemas/tenant-fields.schema.d.ts.map +1 -0
  29. package/dist/cjs/shared-patterns/database/schemas/tenant-fields.schema.js +57 -0
  30. package/dist/cjs/shared-patterns/database/schemas/tenant-fields.schema.js.map +1 -0
  31. package/dist/cjs/shared-patterns/enums/lambda.enum.d.ts +28 -0
  32. package/dist/cjs/shared-patterns/enums/lambda.enum.d.ts.map +1 -0
  33. package/dist/cjs/shared-patterns/enums/lambda.enum.js +34 -0
  34. package/dist/cjs/shared-patterns/enums/lambda.enum.js.map +1 -0
  35. package/dist/cjs/shared-patterns/errors/error-factory.d.ts +150 -0
  36. package/dist/cjs/shared-patterns/errors/error-factory.d.ts.map +1 -0
  37. package/dist/cjs/shared-patterns/errors/error-factory.js +257 -0
  38. package/dist/cjs/shared-patterns/errors/error-factory.js.map +1 -0
  39. package/dist/cjs/shared-patterns/exceptions/base/error-classification-enums.d.ts +118 -0
  40. package/dist/cjs/shared-patterns/exceptions/base/error-classification-enums.d.ts.map +1 -0
  41. package/dist/cjs/shared-patterns/exceptions/base/error-classification-enums.js +111 -0
  42. package/dist/cjs/shared-patterns/exceptions/base/error-classification-enums.js.map +1 -0
  43. package/dist/cjs/shared-patterns/exceptions/base/error-classifier.d.ts +23 -0
  44. package/dist/cjs/shared-patterns/exceptions/base/error-classifier.d.ts.map +1 -0
  45. package/dist/cjs/shared-patterns/exceptions/base/error-classifier.js +165 -0
  46. package/dist/cjs/shared-patterns/exceptions/base/error-classifier.js.map +1 -0
  47. package/dist/cjs/shared-patterns/exceptions/index.d.ts +3 -0
  48. package/dist/cjs/shared-patterns/exceptions/index.d.ts.map +1 -0
  49. package/dist/cjs/shared-patterns/exceptions/index.js +24 -0
  50. package/dist/cjs/shared-patterns/exceptions/index.js.map +1 -0
  51. package/dist/cjs/shared-patterns/functions/crypto.functions.d.ts +16 -0
  52. package/dist/cjs/shared-patterns/functions/crypto.functions.d.ts.map +1 -0
  53. package/dist/cjs/shared-patterns/functions/crypto.functions.js +110 -0
  54. package/dist/cjs/shared-patterns/functions/crypto.functions.js.map +1 -0
  55. package/dist/cjs/shared-patterns/functions/helper.functions.d.ts +10 -0
  56. package/dist/cjs/shared-patterns/functions/helper.functions.d.ts.map +1 -0
  57. package/dist/cjs/shared-patterns/functions/helper.functions.js +38 -0
  58. package/dist/cjs/shared-patterns/functions/helper.functions.js.map +1 -0
  59. package/dist/cjs/shared-patterns/functions/index.d.ts +4 -0
  60. package/dist/cjs/shared-patterns/functions/index.d.ts.map +1 -0
  61. package/dist/cjs/shared-patterns/functions/index.js +21 -0
  62. package/dist/cjs/shared-patterns/functions/index.js.map +1 -0
  63. package/dist/cjs/shared-patterns/functions/request.functions.d.ts +14 -0
  64. package/dist/cjs/shared-patterns/functions/request.functions.d.ts.map +1 -0
  65. package/dist/cjs/shared-patterns/functions/request.functions.js +69 -0
  66. package/dist/cjs/shared-patterns/functions/request.functions.js.map +1 -0
  67. package/dist/cjs/shared-patterns/index.d.ts +15 -0
  68. package/dist/cjs/shared-patterns/index.d.ts.map +1 -0
  69. package/dist/cjs/shared-patterns/index.js +44 -0
  70. package/dist/cjs/shared-patterns/index.js.map +1 -0
  71. package/dist/cjs/shared-patterns/interfaces/index.d.ts +3 -0
  72. package/dist/cjs/shared-patterns/interfaces/index.d.ts.map +1 -0
  73. package/dist/cjs/shared-patterns/interfaces/index.js +19 -0
  74. package/dist/cjs/shared-patterns/interfaces/index.js.map +1 -0
  75. package/dist/cjs/shared-patterns/interfaces/request.interface.d.ts +21 -0
  76. package/dist/cjs/shared-patterns/interfaces/request.interface.d.ts.map +1 -0
  77. package/dist/cjs/shared-patterns/interfaces/request.interface.js +15 -0
  78. package/dist/cjs/shared-patterns/interfaces/request.interface.js.map +1 -0
  79. package/dist/cjs/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.d.ts +9 -0
  80. package/dist/cjs/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.d.ts.map +1 -0
  81. package/dist/cjs/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.js +3 -0
  82. package/dist/cjs/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.js.map +1 -0
  83. package/dist/cjs/shared-patterns/orchestrators/base-orchestrator.d.ts +90 -0
  84. package/dist/cjs/shared-patterns/orchestrators/base-orchestrator.d.ts.map +1 -0
  85. package/dist/cjs/shared-patterns/orchestrators/base-orchestrator.js +124 -0
  86. package/dist/cjs/shared-patterns/orchestrators/base-orchestrator.js.map +1 -0
  87. package/dist/cjs/shared-patterns/orchestrators/base-workflow.d.ts +50 -0
  88. package/dist/cjs/shared-patterns/orchestrators/base-workflow.d.ts.map +1 -0
  89. package/dist/cjs/shared-patterns/orchestrators/base-workflow.js +68 -0
  90. package/dist/cjs/shared-patterns/orchestrators/base-workflow.js.map +1 -0
  91. package/dist/cjs/shared-patterns/orchestrators/index.d.ts +26 -0
  92. package/dist/cjs/shared-patterns/orchestrators/index.d.ts.map +1 -0
  93. package/dist/cjs/shared-patterns/orchestrators/index.js +46 -0
  94. package/dist/cjs/shared-patterns/orchestrators/index.js.map +1 -0
  95. package/dist/cjs/shared-patterns/utils/error-message.utils.d.ts +175 -0
  96. package/dist/cjs/shared-patterns/utils/error-message.utils.d.ts.map +1 -0
  97. package/dist/cjs/shared-patterns/utils/error-message.utils.js +258 -0
  98. package/dist/cjs/shared-patterns/utils/error-message.utils.js.map +1 -0
  99. package/dist/cjs/shared-patterns/utils/index.d.ts +3 -0
  100. package/dist/cjs/shared-patterns/utils/index.d.ts.map +1 -0
  101. package/dist/cjs/shared-patterns/utils/index.js +20 -0
  102. package/dist/cjs/shared-patterns/utils/index.js.map +1 -0
  103. package/dist/cjs/shared-patterns/utils/validation.utils.d.ts +49 -0
  104. package/dist/cjs/shared-patterns/utils/validation.utils.d.ts.map +1 -0
  105. package/dist/cjs/shared-patterns/utils/validation.utils.js +76 -0
  106. package/dist/cjs/shared-patterns/utils/validation.utils.js.map +1 -0
  107. package/dist/esm/index.d.ts +2 -0
  108. package/dist/esm/index.d.ts.map +1 -1
  109. package/dist/esm/index.js +5 -2
  110. package/dist/esm/index.js.map +1 -1
  111. package/dist/esm/shared-lib/errors/domains/wallet-errors.js.map +1 -1
  112. package/dist/esm/shared-lib/interfaces/wallet-signing-scenario.interface.d.ts +0 -2
  113. package/dist/esm/shared-lib/interfaces/wallet-signing-scenario.interface.d.ts.map +1 -1
  114. package/dist/esm/shared-patterns/database/index.d.ts +6 -0
  115. package/dist/esm/shared-patterns/database/index.d.ts.map +1 -0
  116. package/dist/esm/shared-patterns/database/index.js +8 -0
  117. package/dist/esm/shared-patterns/database/index.js.map +1 -0
  118. package/dist/esm/shared-patterns/database/models/base.model.d.ts +7 -0
  119. package/dist/esm/shared-patterns/database/models/base.model.d.ts.map +1 -0
  120. package/dist/esm/shared-patterns/database/models/base.model.js +7 -0
  121. package/dist/esm/shared-patterns/database/models/base.model.js.map +1 -0
  122. package/dist/esm/shared-patterns/database/models/fixture.model.d.ts +4 -0
  123. package/dist/esm/shared-patterns/database/models/fixture.model.d.ts.map +1 -0
  124. package/dist/esm/shared-patterns/database/models/fixture.model.js +4 -0
  125. package/dist/esm/shared-patterns/database/models/fixture.model.js.map +1 -0
  126. package/dist/esm/shared-patterns/database/schemas/fixture-fields.schema.d.ts +5 -0
  127. package/dist/esm/shared-patterns/database/schemas/fixture-fields.schema.d.ts.map +1 -0
  128. package/dist/esm/shared-patterns/database/schemas/fixture-fields.schema.js +8 -0
  129. package/dist/esm/shared-patterns/database/schemas/fixture-fields.schema.js.map +1 -0
  130. package/dist/esm/shared-patterns/database/schemas/shared-fields.schema.d.ts +44 -0
  131. package/dist/esm/shared-patterns/database/schemas/shared-fields.schema.d.ts.map +1 -0
  132. package/dist/esm/shared-patterns/database/schemas/shared-fields.schema.js +61 -0
  133. package/dist/esm/shared-patterns/database/schemas/shared-fields.schema.js.map +1 -0
  134. package/dist/esm/shared-patterns/database/schemas/tenant-fields.schema.d.ts +51 -0
  135. package/dist/esm/shared-patterns/database/schemas/tenant-fields.schema.d.ts.map +1 -0
  136. package/dist/esm/shared-patterns/database/schemas/tenant-fields.schema.js +54 -0
  137. package/dist/esm/shared-patterns/database/schemas/tenant-fields.schema.js.map +1 -0
  138. package/dist/esm/shared-patterns/enums/lambda.enum.d.ts +28 -0
  139. package/dist/esm/shared-patterns/enums/lambda.enum.d.ts.map +1 -0
  140. package/dist/esm/shared-patterns/enums/lambda.enum.js +31 -0
  141. package/dist/esm/shared-patterns/enums/lambda.enum.js.map +1 -0
  142. package/dist/esm/shared-patterns/errors/error-factory.d.ts +150 -0
  143. package/dist/esm/shared-patterns/errors/error-factory.d.ts.map +1 -0
  144. package/dist/esm/shared-patterns/errors/error-factory.js +254 -0
  145. package/dist/esm/shared-patterns/errors/error-factory.js.map +1 -0
  146. package/dist/esm/shared-patterns/exceptions/base/error-classification-enums.d.ts +118 -0
  147. package/dist/esm/shared-patterns/exceptions/base/error-classification-enums.d.ts.map +1 -0
  148. package/dist/esm/shared-patterns/exceptions/base/error-classification-enums.js +108 -0
  149. package/dist/esm/shared-patterns/exceptions/base/error-classification-enums.js.map +1 -0
  150. package/dist/esm/shared-patterns/exceptions/base/error-classifier.d.ts +23 -0
  151. package/dist/esm/shared-patterns/exceptions/base/error-classifier.d.ts.map +1 -0
  152. package/dist/esm/shared-patterns/exceptions/base/error-classifier.js +161 -0
  153. package/dist/esm/shared-patterns/exceptions/base/error-classifier.js.map +1 -0
  154. package/dist/esm/shared-patterns/exceptions/index.d.ts +3 -0
  155. package/dist/esm/shared-patterns/exceptions/index.d.ts.map +1 -0
  156. package/dist/esm/shared-patterns/exceptions/index.js +6 -0
  157. package/dist/esm/shared-patterns/exceptions/index.js.map +1 -0
  158. package/dist/esm/shared-patterns/functions/crypto.functions.d.ts +16 -0
  159. package/dist/esm/shared-patterns/functions/crypto.functions.d.ts.map +1 -0
  160. package/dist/esm/shared-patterns/functions/crypto.functions.js +67 -0
  161. package/dist/esm/shared-patterns/functions/crypto.functions.js.map +1 -0
  162. package/dist/esm/shared-patterns/functions/helper.functions.d.ts +10 -0
  163. package/dist/esm/shared-patterns/functions/helper.functions.d.ts.map +1 -0
  164. package/dist/esm/shared-patterns/functions/helper.functions.js +32 -0
  165. package/dist/esm/shared-patterns/functions/helper.functions.js.map +1 -0
  166. package/dist/esm/shared-patterns/functions/index.d.ts +4 -0
  167. package/dist/esm/shared-patterns/functions/index.d.ts.map +1 -0
  168. package/dist/esm/shared-patterns/functions/index.js +5 -0
  169. package/dist/esm/shared-patterns/functions/index.js.map +1 -0
  170. package/dist/esm/shared-patterns/functions/request.functions.d.ts +14 -0
  171. package/dist/esm/shared-patterns/functions/request.functions.d.ts.map +1 -0
  172. package/dist/esm/shared-patterns/functions/request.functions.js +61 -0
  173. package/dist/esm/shared-patterns/functions/request.functions.js.map +1 -0
  174. package/dist/esm/shared-patterns/index.d.ts +15 -0
  175. package/dist/esm/shared-patterns/index.d.ts.map +1 -0
  176. package/dist/esm/shared-patterns/index.js +28 -0
  177. package/dist/esm/shared-patterns/index.js.map +1 -0
  178. package/dist/esm/shared-patterns/interfaces/index.d.ts +3 -0
  179. package/dist/esm/shared-patterns/interfaces/index.d.ts.map +1 -0
  180. package/dist/esm/shared-patterns/interfaces/index.js +3 -0
  181. package/dist/esm/shared-patterns/interfaces/index.js.map +1 -0
  182. package/dist/esm/shared-patterns/interfaces/request.interface.d.ts +21 -0
  183. package/dist/esm/shared-patterns/interfaces/request.interface.d.ts.map +1 -0
  184. package/dist/esm/shared-patterns/interfaces/request.interface.js +11 -0
  185. package/dist/esm/shared-patterns/interfaces/request.interface.js.map +1 -0
  186. package/dist/esm/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.d.ts +9 -0
  187. package/dist/esm/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.d.ts.map +1 -0
  188. package/dist/esm/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.js +2 -0
  189. package/dist/esm/shared-patterns/interfaces/stripe-payment-intent-metadata.interface.js.map +1 -0
  190. package/dist/esm/shared-patterns/orchestrators/base-orchestrator.d.ts +90 -0
  191. package/dist/esm/shared-patterns/orchestrators/base-orchestrator.d.ts.map +1 -0
  192. package/dist/esm/shared-patterns/orchestrators/base-orchestrator.js +116 -0
  193. package/dist/esm/shared-patterns/orchestrators/base-orchestrator.js.map +1 -0
  194. package/dist/esm/shared-patterns/orchestrators/base-workflow.d.ts +50 -0
  195. package/dist/esm/shared-patterns/orchestrators/base-workflow.d.ts.map +1 -0
  196. package/dist/esm/shared-patterns/orchestrators/base-workflow.js +64 -0
  197. package/dist/esm/shared-patterns/orchestrators/base-workflow.js.map +1 -0
  198. package/dist/esm/shared-patterns/orchestrators/index.d.ts +26 -0
  199. package/dist/esm/shared-patterns/orchestrators/index.d.ts.map +1 -0
  200. package/dist/esm/shared-patterns/orchestrators/index.js +30 -0
  201. package/dist/esm/shared-patterns/orchestrators/index.js.map +1 -0
  202. package/dist/esm/shared-patterns/utils/error-message.utils.d.ts +175 -0
  203. package/dist/esm/shared-patterns/utils/error-message.utils.d.ts.map +1 -0
  204. package/dist/esm/shared-patterns/utils/error-message.utils.js +244 -0
  205. package/dist/esm/shared-patterns/utils/error-message.utils.js.map +1 -0
  206. package/dist/esm/shared-patterns/utils/index.d.ts +3 -0
  207. package/dist/esm/shared-patterns/utils/index.d.ts.map +1 -0
  208. package/dist/esm/shared-patterns/utils/index.js +4 -0
  209. package/dist/esm/shared-patterns/utils/index.js.map +1 -0
  210. package/dist/esm/shared-patterns/utils/validation.utils.d.ts +49 -0
  211. package/dist/esm/shared-patterns/utils/validation.utils.d.ts.map +1 -0
  212. package/dist/esm/shared-patterns/utils/validation.utils.js +70 -0
  213. package/dist/esm/shared-patterns/utils/validation.utils.js.map +1 -0
  214. package/package.json +2 -25
@@ -0,0 +1,90 @@
1
+ import { Logger } from '@nestjs/common';
2
+ import { OrchestrationError } from '../../shared-lib/errors';
3
+ import { CommandBus, QueryBus } from '@nestjs/cqrs';
4
+ /**
5
+ * BaseOrchestrator - Centralized Application Layer Orchestration Pattern
6
+ *
7
+ * @description Foundation for all domain orchestrators following PERS DDD principles:
8
+ * - Application layer orchestrates cross-domain operations via CQRS
9
+ * - Domain services contain pure business logic only
10
+ * - Microservice boundary preparation through clean abstractions
11
+ * - Consistent patterns across all domains (transaction, user, wallet, token, etc.)
12
+ * - Smart error handling that preserves business context
13
+ *
14
+ * @usage Extend this class in domain-specific orchestrators:
15
+ * ```typescript
16
+ * @Injectable()
17
+ * export class UserOrchestrator extends BaseOrchestrator {
18
+ * constructor(commandBus: CommandBus, queryBus: QueryBus) {
19
+ * super(commandBus, queryBus, UserOrchestrator.name);
20
+ * }
21
+ * }
22
+ * ```
23
+ *
24
+ * @library @explorins/pers-shared
25
+ * @version 2.0.0
26
+ * @since August 2025
27
+ */
28
+ export declare abstract class BaseOrchestrator {
29
+ protected readonly commandBus: CommandBus;
30
+ protected readonly queryBus: QueryBus;
31
+ protected readonly logger: Logger;
32
+ protected constructor(commandBus: CommandBus, queryBus: QueryBus, loggerContext: string);
33
+ /**
34
+ * Enhanced error handling that preserves business errors while wrapping technical errors
35
+ * Business errors (with category: DOMAIN_RULE) are passed through unchanged
36
+ * Technical errors are wrapped in OrchestrationError for consistent handling
37
+ */
38
+ protected executeWithErrorHandling<T>(operation: () => Promise<T>, operationName: string, context?: Record<string, any>): Promise<T>;
39
+ /**
40
+ * Execute CQRS command with consistent error handling and logging
41
+ * Standardizes command execution across all orchestrators
42
+ */
43
+ protected executeCommand<T>(command: any, operationName?: string): Promise<T>;
44
+ /**
45
+ * Execute CQRS query with consistent error handling and logging
46
+ * Standardizes query execution across all orchestrators
47
+ */
48
+ protected executeQuery<T>(query: any, operationName?: string): Promise<T>;
49
+ /**
50
+ * Execute multiple operations in parallel with error handling
51
+ * Useful for batch operations across domains
52
+ */
53
+ protected executeParallel<T>(operations: (() => Promise<T>)[], operationName: string): Promise<T[]>;
54
+ }
55
+ /**
56
+ * Result pattern for orchestrator operations (optional - for complex flows)
57
+ * Provides type-safe error handling without exceptions
58
+ */
59
+ export type OrchestrationResult<T> = {
60
+ success: true;
61
+ data: T;
62
+ operation?: string;
63
+ } | {
64
+ success: false;
65
+ error: OrchestrationError;
66
+ operation?: string;
67
+ };
68
+ /**
69
+ * Helper function to create success result
70
+ */
71
+ export declare function createSuccessResult<T>(data: T, operation?: string): OrchestrationResult<T>;
72
+ /**
73
+ * Helper function to create error result
74
+ */
75
+ export declare function createErrorResult<T>(error: OrchestrationError, operation?: string): OrchestrationResult<T>;
76
+ /**
77
+ * Utility function to check if result is successful
78
+ * Provides type guard for TypeScript
79
+ */
80
+ export declare function isSuccessResult<T>(result: OrchestrationResult<T>): result is {
81
+ success: true;
82
+ data: T;
83
+ operation?: string;
84
+ };
85
+ /**
86
+ * Utility function to extract data from result or throw error
87
+ * Useful for converting result pattern back to exception-based flow
88
+ */
89
+ export declare function unwrapResult<T>(result: OrchestrationResult<T>): T;
90
+ //# sourceMappingURL=base-orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-orchestrator.d.ts","sourceRoot":"","sources":["../../../../src/shared-patterns/orchestrators/base-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAiB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAY,QAAQ,EAAU,MAAM,cAAc,CAAC;AACtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,gBAAgB;IAIlC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU;IACzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ;IAJvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAElC,SAAS,aACY,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EACrC,aAA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CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAE3H;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAKjE"}
@@ -0,0 +1,116 @@
1
+ import { Logger, HttpException } from '@nestjs/common';
2
+ import { OrchestrationError, ErrorCategory } from '../../shared-lib/errors';
3
+ /**
4
+ * BaseOrchestrator - Centralized Application Layer Orchestration Pattern
5
+ *
6
+ * @description Foundation for all domain orchestrators following PERS DDD principles:
7
+ * - Application layer orchestrates cross-domain operations via CQRS
8
+ * - Domain services contain pure business logic only
9
+ * - Microservice boundary preparation through clean abstractions
10
+ * - Consistent patterns across all domains (transaction, user, wallet, token, etc.)
11
+ * - Smart error handling that preserves business context
12
+ *
13
+ * @usage Extend this class in domain-specific orchestrators:
14
+ * ```typescript
15
+ * @Injectable()
16
+ * export class UserOrchestrator extends BaseOrchestrator {
17
+ * constructor(commandBus: CommandBus, queryBus: QueryBus) {
18
+ * super(commandBus, queryBus, UserOrchestrator.name);
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @library @explorins/pers-shared
24
+ * @version 2.0.0
25
+ * @since August 2025
26
+ */
27
+ export class BaseOrchestrator {
28
+ commandBus;
29
+ queryBus;
30
+ logger;
31
+ constructor(commandBus, queryBus, loggerContext) {
32
+ this.commandBus = commandBus;
33
+ this.queryBus = queryBus;
34
+ this.logger = new Logger(loggerContext);
35
+ }
36
+ /**
37
+ * Enhanced error handling that preserves business errors while wrapping technical errors
38
+ * Business errors (with category: DOMAIN_RULE) are passed through unchanged
39
+ * Technical errors are wrapped in OrchestrationError for consistent handling
40
+ */
41
+ async executeWithErrorHandling(operation, operationName, context) {
42
+ try {
43
+ this.logger.debug(`🚀 Starting ${operationName}`, context);
44
+ const result = await operation();
45
+ this.logger.debug(`✅ Completed ${operationName}`, context);
46
+ return result;
47
+ }
48
+ catch (error) {
49
+ const errorMessage = error instanceof Error ? error.message : String(error);
50
+ // Preserve business errors - don't wrap them
51
+ if (error instanceof HttpException) {
52
+ const response = error.getResponse();
53
+ if (typeof response === 'object' && response?.category === ErrorCategory.DOMAIN_RULE) {
54
+ this.logger.warn(`⚠️ Business logic error in ${operationName}: ${errorMessage}`, { ...context, error });
55
+ throw error; // Pass through unchanged
56
+ }
57
+ }
58
+ // Wrap technical errors
59
+ this.logger.error(`❌ Failed ${operationName}: ${errorMessage}`, { ...context, error });
60
+ throw new OrchestrationError(operationName, error instanceof Error ? error : new Error(errorMessage));
61
+ }
62
+ }
63
+ /**
64
+ * Execute CQRS command with consistent error handling and logging
65
+ * Standardizes command execution across all orchestrators
66
+ */
67
+ async executeCommand(command, operationName) {
68
+ const operation = operationName || `Command: ${command.constructor.name}`;
69
+ return this.executeWithErrorHandling(() => this.commandBus.execute(command), operation, { commandType: command.constructor.name });
70
+ }
71
+ /**
72
+ * Execute CQRS query with consistent error handling and logging
73
+ * Standardizes query execution across all orchestrators
74
+ */
75
+ async executeQuery(query, operationName) {
76
+ const operation = operationName || `Query: ${query.constructor.name}`;
77
+ return this.executeWithErrorHandling(() => this.queryBus.execute(query), operation, { queryType: query.constructor.name });
78
+ }
79
+ /**
80
+ * Execute multiple operations in parallel with error handling
81
+ * Useful for batch operations across domains
82
+ */
83
+ async executeParallel(operations, operationName) {
84
+ return this.executeWithErrorHandling(() => Promise.all(operations.map(op => op())), `Parallel: ${operationName}`, { operationCount: operations.length });
85
+ }
86
+ }
87
+ /**
88
+ * Helper function to create success result
89
+ */
90
+ export function createSuccessResult(data, operation) {
91
+ return { success: true, data, operation };
92
+ }
93
+ /**
94
+ * Helper function to create error result
95
+ */
96
+ export function createErrorResult(error, operation) {
97
+ return { success: false, error, operation };
98
+ }
99
+ /**
100
+ * Utility function to check if result is successful
101
+ * Provides type guard for TypeScript
102
+ */
103
+ export function isSuccessResult(result) {
104
+ return result.success === true;
105
+ }
106
+ /**
107
+ * Utility function to extract data from result or throw error
108
+ * Useful for converting result pattern back to exception-based flow
109
+ */
110
+ export function unwrapResult(result) {
111
+ if (isSuccessResult(result)) {
112
+ return result.data;
113
+ }
114
+ throw result.error;
115
+ }
116
+ //# sourceMappingURL=base-orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-orchestrator.js","sourceRoot":"","sources":["../../../../src/shared-patterns/orchestrators/base-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAgB,gBAAgB;IAIf;IACA;IAJF,MAAM,CAAS;IAElC,YACqB,UAAsB,EACtB,QAAkB,EACrC,aAAqB;QAFF,eAAU,GAAV,UAAU,CAAY;QACtB,aAAQ,GAAR,QAAQ,CAAU;QAGrC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,wBAAwB,CACtC,SAA2B,EAC3B,aAAqB,EACrB,OAA6B;QAE7B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;YAC3D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;YAC3D,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CA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**
3
+ * BaseWorkflow - Business Process Coordination Pattern
4
+ *
5
+ * @description Foundation for business workflow coordination in PERS domains.
6
+ * Distinct from BaseOrchestrator which handles technical CQRS coordination.
7
+ *
8
+ * ARCHITECTURAL DISTINCTION:
9
+ * - BaseOrchestrator: Technical coordination (CQRS, queries, commands)
10
+ * - BaseWorkflow: Business process coordination (orchestrator choreography)
11
+ *
12
+ * @usage Extend this class for domain-specific business workflows:
13
+ * ```typescript
14
+ * @Injectable()
15
+ * export class ServerTransactionWorkflow extends BaseWorkflow {
16
+ * constructor(
17
+ * private readonly walletOrchestrator: WalletResolutionOrchestrator,
18
+ * private readonly tokenOrchestrator: TokenResolutionOrchestrator
19
+ * ) {
20
+ * super(ServerTransactionWorkflow.name);
21
+ * }
22
+ *
23
+ * async executeTransactionFlow(dto: TransactionRequestDTO): Promise<TransactionDTO> {
24
+ * return this.executeWorkflowStep(async () => {
25
+ * const token = await this.tokenOrchestrator.resolveToken(dto.token);
26
+ * const addresses = await this.walletOrchestrator.resolveAddresses(dto, token.chainId);
27
+ * return this.createTransaction(token, addresses, dto);
28
+ * }, 'Transaction Creation Flow');
29
+ * }
30
+ * }
31
+ * ```
32
+ *
33
+ * @library @explorins/pers-shared-patterns
34
+ * @version 1.0.0
35
+ * @since September 2025
36
+ */
37
+ export declare abstract class BaseWorkflow {
38
+ protected readonly logger: Logger;
39
+ protected constructor(loggerContext: string);
40
+ /**
41
+ * Execute a workflow step with standardized logging and error handling
42
+ *
43
+ * @param step - Function to execute as workflow step
44
+ * @param stepName - Human-readable name for the step
45
+ * @param context - Optional context for logging
46
+ * @returns Promise resolving to step result
47
+ */
48
+ protected executeWorkflowStep<T>(step: () => Promise<T>, stepName: string, context?: Record<string, any>): Promise<T>;
49
+ }
50
+ //# sourceMappingURL=base-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-workflow.d.ts","sourceRoot":"","sources":["../../../../src/shared-patterns/orchestrators/base-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,8BAAsB,YAAY;IAChC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAElC,SAAS,aAAa,aAAa,EAAE,MAAM;IAI3C;;;;;;;OAOG;cACa,mBAAmB,CAAC,CAAC,EACnC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC;CAYd"}
@@ -0,0 +1,64 @@
1
+ import { Logger } from '@nestjs/common';
2
+ /**
3
+ * BaseWorkflow - Business Process Coordination Pattern
4
+ *
5
+ * @description Foundation for business workflow coordination in PERS domains.
6
+ * Distinct from BaseOrchestrator which handles technical CQRS coordination.
7
+ *
8
+ * ARCHITECTURAL DISTINCTION:
9
+ * - BaseOrchestrator: Technical coordination (CQRS, queries, commands)
10
+ * - BaseWorkflow: Business process coordination (orchestrator choreography)
11
+ *
12
+ * @usage Extend this class for domain-specific business workflows:
13
+ * ```typescript
14
+ * @Injectable()
15
+ * export class ServerTransactionWorkflow extends BaseWorkflow {
16
+ * constructor(
17
+ * private readonly walletOrchestrator: WalletResolutionOrchestrator,
18
+ * private readonly tokenOrchestrator: TokenResolutionOrchestrator
19
+ * ) {
20
+ * super(ServerTransactionWorkflow.name);
21
+ * }
22
+ *
23
+ * async executeTransactionFlow(dto: TransactionRequestDTO): Promise<TransactionDTO> {
24
+ * return this.executeWorkflowStep(async () => {
25
+ * const token = await this.tokenOrchestrator.resolveToken(dto.token);
26
+ * const addresses = await this.walletOrchestrator.resolveAddresses(dto, token.chainId);
27
+ * return this.createTransaction(token, addresses, dto);
28
+ * }, 'Transaction Creation Flow');
29
+ * }
30
+ * }
31
+ * ```
32
+ *
33
+ * @library @explorins/pers-shared-patterns
34
+ * @version 1.0.0
35
+ * @since September 2025
36
+ */
37
+ export class BaseWorkflow {
38
+ logger;
39
+ constructor(loggerContext) {
40
+ this.logger = new Logger(loggerContext);
41
+ }
42
+ /**
43
+ * Execute a workflow step with standardized logging and error handling
44
+ *
45
+ * @param step - Function to execute as workflow step
46
+ * @param stepName - Human-readable name for the step
47
+ * @param context - Optional context for logging
48
+ * @returns Promise resolving to step result
49
+ */
50
+ async executeWorkflowStep(step, stepName, context) {
51
+ try {
52
+ this.logger.debug(`🎯 Starting workflow step: ${stepName}`, context);
53
+ const result = await step();
54
+ this.logger.debug(`✅ Completed workflow step: ${stepName}`, context);
55
+ return result;
56
+ }
57
+ catch (error) {
58
+ const errorMessage = error instanceof Error ? error.message : String(error);
59
+ this.logger.error(`❌ Failed workflow step: ${stepName}: ${errorMessage}`, { ...context, error });
60
+ throw error; // Let business errors flow through unchanged
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=base-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-workflow.js","sourceRoot":"","sources":["../../../../src/shared-patterns/orchestrators/base-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAgB,YAAY;IACb,MAAM,CAAS;IAElC,YAAsB,aAAqB;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;OAOG;IACO,KAAK,CAAC,mBAAmB,CACjC,IAAsB,EACtB,QAAgB,EAChB,OAA6B;QAE7B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;YACrE,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;YACrE,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,QAAQ,KAAK,YAAY,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;YACjG,MAAM,KAAK,CAAC,CAAC,6CAA6C;QAC5D,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * PERS Orchestrators - Application Layer Patterns
3
+ *
4
+ * @description Centralized orchestration utilities for DDD-compliant applications
5
+ * - BaseOrchestrator: Foundation for all domain orchestrators (technical coordination)
6
+ * - BaseWorkflow: Foundation for business process workflows (business coordination)
7
+ * - OrchestrationError: Standard error handling
8
+ * - OrchestrationResult: Type-safe result pattern
9
+ * - Utility functions for error handling and result processing
10
+ *
11
+ * @usage Import directly from shared library:
12
+ * ```typescript
13
+ * import { BaseOrchestrator, BaseWorkflow, OrchestrationError } from '@explorins/pers-shared-patterns';
14
+ * ```
15
+ *
16
+ * ARCHITECTURAL DISTINCTION:
17
+ * - BaseOrchestrator: Technical coordination (CQRS, queries, commands)
18
+ * - BaseWorkflow: Business process coordination (orchestrator choreography)
19
+ *
20
+ * @library @explorins/pers-shared-patterns
21
+ * @version 2.0.0
22
+ * @since August 2025
23
+ */
24
+ export * from './base-orchestrator';
25
+ export * from './base-workflow';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared-patterns/orchestrators/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * PERS Orchestrators - Application Layer Patterns
3
+ *
4
+ * @description Centralized orchestration utilities for DDD-compliant applications
5
+ * - BaseOrchestrator: Foundation for all domain orchestrators (technical coordination)
6
+ * - BaseWorkflow: Foundation for business process workflows (business coordination)
7
+ * - OrchestrationError: Standard error handling
8
+ * - OrchestrationResult: Type-safe result pattern
9
+ * - Utility functions for error handling and result processing
10
+ *
11
+ * @usage Import directly from shared library:
12
+ * ```typescript
13
+ * import { BaseOrchestrator, BaseWorkflow, OrchestrationError } from '@explorins/pers-shared-patterns';
14
+ * ```
15
+ *
16
+ * ARCHITECTURAL DISTINCTION:
17
+ * - BaseOrchestrator: Technical coordination (CQRS, queries, commands)
18
+ * - BaseWorkflow: Business process coordination (orchestrator choreography)
19
+ *
20
+ * @library @explorins/pers-shared-patterns
21
+ * @version 2.0.0
22
+ * @since August 2025
23
+ */
24
+ export * from './base-orchestrator';
25
+ export * from './base-workflow';
26
+ // Future orchestration utilities can be added here:
27
+ // export * from './validation-orchestrator';
28
+ // export * from './audit-orchestrator';
29
+ // export * from './notification-orchestrator';
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/shared-patterns/orchestrators/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,oDAAoD;AACpD,6CAA6C;AAC7C,wCAAwC;AACxC,+CAA+C"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Standardized error message generators for consistent error handling across applications
3
+ *
4
+ * This utility provides reusable message generation functions for common error scenarios:
5
+ * - Authentication context errors
6
+ * - Resource not found errors
7
+ * - Access denied errors
8
+ * - Validation errors
9
+ * - Business rule violations
10
+ * - Database operation errors
11
+ *
12
+ * @example
13
+ * import { generateAuthRequiredMessage, generateNotFoundMessage } from '@explorins/pers-shared-patterns';
14
+ *
15
+ * const message = generateAuthRequiredMessage(['user', 'admin']);
16
+ * // "User or admin authentication required"
17
+ *
18
+ * const notFound = generateNotFoundMessage('transaction', 'tx-123');
19
+ * // "Transaction with identifier 'tx-123' not found"
20
+ */
21
+ /**
22
+ * Authentication context types supported across applications
23
+ */
24
+ export type AuthenticationContext = 'user' | 'business' | 'admin' | 'tenant';
25
+ /**
26
+ * Resource types commonly used in error messages
27
+ */
28
+ export type ResourceType = 'user' | 'business' | 'admin' | 'campaign' | 'transaction' | 'redemption' | 'wallet' | 'contract' | 'tenant' | 'token' | 'signing-account';
29
+ /**
30
+ * Database operation types for error reporting
31
+ */
32
+ export type DatabaseOperation = 'save' | 'find' | 'delete' | 'update' | 'query';
33
+ /**
34
+ * Generate standardized authentication required error message
35
+ * @param requiredContexts - Array of required authentication contexts
36
+ * @param action - Optional action description (e.g., 'for redemption processing')
37
+ * @returns Standardized error message
38
+ */
39
+ export declare function generateAuthRequiredMessage(requiredContexts: AuthenticationContext[], action?: string): string;
40
+ /**
41
+ * Generate standardized "not found" error message
42
+ * @param resourceType - Type of resource that was not found
43
+ * @param identifier - Optional identifier (ID, email, etc.)
44
+ * @returns Standardized not found message
45
+ */
46
+ export declare function generateNotFoundMessage(resourceType: ResourceType, identifier?: string): string;
47
+ /**
48
+ * Generate standardized "access denied" error message
49
+ * @param action - The action being attempted
50
+ * @param resource - Optional resource context
51
+ * @returns Standardized access denied message
52
+ */
53
+ export declare function generateAccessDeniedMessage(action: string, resource?: string): string;
54
+ /**
55
+ * Generate standardized validation error message
56
+ * @param field - Field that failed validation
57
+ * @param constraint - The validation constraint
58
+ * @returns Standardized validation message
59
+ */
60
+ export declare function generateValidationMessage(field: string, constraint: string): string;
61
+ /**
62
+ * Generate standardized business rule violation message
63
+ * @param rule - The business rule that was violated
64
+ * @param context - Optional context information
65
+ * @returns Standardized business rule message
66
+ */
67
+ export declare function generateBusinessRuleMessage(rule: string, context?: string): string;
68
+ /**
69
+ * Generate standardized database error message
70
+ * @param operation - The database operation that failed
71
+ * @param resourceType - Type of resource involved
72
+ * @param details - Optional error details
73
+ * @returns Standardized database error message
74
+ */
75
+ export declare function generateDatabaseErrorMessage(operation: DatabaseOperation, resourceType: ResourceType, details?: string): string;
76
+ /**
77
+ * Generate standardized input validation error message
78
+ * @param parameter - The parameter that failed validation
79
+ * @param requirement - What the parameter should meet
80
+ * @returns Standardized input validation message
81
+ */
82
+ export declare function generateInputValidationMessage(parameter: string, requirement: string): string;
83
+ /**
84
+ * Generate standardized operation error message
85
+ * @param operation - The operation that was attempted
86
+ * @param reason - Why it failed
87
+ * @returns Standardized operation error message
88
+ */
89
+ export declare function generateOperationErrorMessage(operation: string, reason: string): string;
90
+ /**
91
+ * Common error message constants for quick access
92
+ */
93
+ export declare const ERROR_MESSAGE_TEMPLATES: {
94
+ readonly AUTH: {
95
+ readonly USER_ONLY: () => string;
96
+ readonly BUSINESS_ONLY: () => string;
97
+ readonly ADMIN_ONLY: () => string;
98
+ readonly USER_OR_BUSINESS: () => string;
99
+ readonly USER_OR_ADMIN: () => string;
100
+ readonly BUSINESS_OR_ADMIN: () => string;
101
+ readonly USER_BUSINESS_OR_ADMIN: () => string;
102
+ readonly ANY_AUTH: () => string;
103
+ readonly FOR_REDEMPTION: () => string;
104
+ readonly FOR_TRANSACTION: () => string;
105
+ readonly FOR_ADMIN_ACTION: () => string;
106
+ };
107
+ readonly NOT_FOUND: {
108
+ readonly USER: (id?: string) => string;
109
+ readonly BUSINESS: (id?: string) => string;
110
+ readonly ADMIN: (id?: string) => string;
111
+ readonly CAMPAIGN: (id?: string) => string;
112
+ readonly TRANSACTION: (id?: string) => string;
113
+ readonly REDEMPTION: (id?: string) => string;
114
+ readonly WALLET: (id?: string) => string;
115
+ readonly CONTRACT: (address?: string) => string;
116
+ readonly TENANT: (id?: string) => string;
117
+ readonly TOKEN: (id?: string) => string;
118
+ readonly SIGNING_ACCOUNT: (id?: string) => string;
119
+ };
120
+ readonly ACCESS_DENIED: {
121
+ readonly VIEW_RESOURCE: (resource: string) => string;
122
+ readonly MODIFY_RESOURCE: (resource: string) => string;
123
+ readonly DELETE_RESOURCE: (resource: string) => string;
124
+ readonly EXECUTE_ACTION: (action: string) => string;
125
+ };
126
+ readonly VALIDATION: {
127
+ readonly REQUIRED_FIELD: (field: string) => string;
128
+ readonly INVALID_FORMAT: (field: string, format: string) => string;
129
+ readonly OUT_OF_RANGE: (field: string, min?: number, max?: number) => string;
130
+ };
131
+ readonly BUSINESS_RULES: {
132
+ readonly REDEMPTION_LIMIT_REACHED: () => string;
133
+ readonly INSUFFICIENT_BALANCE: (required?: string) => string;
134
+ readonly GEOGRAPHIC_RESTRICTION: (location: string) => string;
135
+ readonly STATUS_NOT_ALLOWED: (status: string, action: string) => string;
136
+ };
137
+ readonly DATABASE: {
138
+ readonly SAVE_FAILED: (resourceType: ResourceType, details?: string) => string;
139
+ readonly FIND_FAILED: (resourceType: ResourceType, details?: string) => string;
140
+ readonly DELETE_FAILED: (resourceType: ResourceType, details?: string) => string;
141
+ readonly UPDATE_FAILED: (resourceType: ResourceType, details?: string) => string;
142
+ readonly QUERY_FAILED: (resourceType: ResourceType, details?: string) => string;
143
+ };
144
+ readonly INPUT_VALIDATION: {
145
+ readonly REQUIRED: (param: string) => string;
146
+ readonly EMPTY: (param: string) => string;
147
+ readonly INVALID_FORMAT: (param: string, format: string) => string;
148
+ readonly OUT_OF_RANGE: (param: string, range: string) => string;
149
+ readonly INVALID_COMBINATION: (params: string) => string;
150
+ readonly MISSING_FIELD: (param: string) => string;
151
+ };
152
+ readonly OPERATIONS: {
153
+ readonly TRANSACTION_FAILED: (reason: string) => string;
154
+ readonly SIGNATURE_FAILED: (reason: string) => string;
155
+ readonly WALLET_OPERATION_FAILED: (reason: string) => string;
156
+ readonly CONTRACT_INTERACTION_FAILED: (reason: string) => string;
157
+ readonly DATA_PROCESSING_FAILED: (reason: string) => string;
158
+ };
159
+ };
160
+ /**
161
+ * Database operation error helper function
162
+ * Creates appropriate errors for database operations using the centralized ErrorFactory
163
+ */
164
+ export declare function DatabaseOperationError(operation: DatabaseOperation, resourceType: ResourceType, details?: string): void;
165
+ /**
166
+ * Input validation error helper function
167
+ * Creates appropriate validation errors using the centralized ErrorFactory
168
+ */
169
+ export declare function InputValidationError(field: string, requirement: string, providedValue?: any): void;
170
+ /**
171
+ * Operation failure error helper function
172
+ * Creates appropriate operation errors using the centralized ErrorFactory
173
+ */
174
+ export declare function OperationFailureError(operation: string, reason: string, retryable?: boolean): void;
175
+ //# sourceMappingURL=error-message.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-message.utils.d.ts","sourceRoot":"","sources":["../../../../src/shared-patterns/utils/error-message.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,iBAAiB,CAAC;AAEtK;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhF;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,gBAAgB,EAAE,qBAAqB,EAAE,EACzC,MAAM,CAAC,EAAE,MAAM,GAChB,MAAM,CA0BR;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/F;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,Q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