@plyaz/core 1.1.1 → 1.2.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 (243) hide show
  1. package/dist/adapters/index.d.ts +16 -0
  2. package/dist/adapters/index.d.ts.map +1 -0
  3. package/dist/adapters/nestjs.d.ts +79 -0
  4. package/dist/adapters/nestjs.d.ts.map +1 -0
  5. package/dist/adapters/nextjs.d.ts +28 -0
  6. package/dist/adapters/nextjs.d.ts.map +1 -0
  7. package/dist/backend/example/example.controller.d.ts +121 -0
  8. package/dist/backend/example/example.controller.d.ts.map +1 -0
  9. package/dist/backend/example/example.module.d.ts +29 -0
  10. package/dist/backend/example/example.module.d.ts.map +1 -0
  11. package/dist/backend/example/index.d.ts +8 -0
  12. package/dist/backend/example/index.d.ts.map +1 -0
  13. package/dist/backend/featureFlags/FeatureFlagDomainService.d.ts +150 -0
  14. package/dist/backend/featureFlags/FeatureFlagDomainService.d.ts.map +1 -0
  15. package/dist/backend/featureFlags/config/feature-flag.config.d.ts +89 -0
  16. package/dist/backend/featureFlags/config/feature-flag.config.d.ts.map +1 -0
  17. package/dist/backend/featureFlags/config/validation.d.ts +181 -0
  18. package/dist/backend/featureFlags/config/validation.d.ts.map +1 -0
  19. package/dist/backend/featureFlags/decorators/feature-disabled.decorator.d.ts +6 -0
  20. package/dist/backend/featureFlags/decorators/feature-disabled.decorator.d.ts.map +1 -0
  21. package/dist/backend/featureFlags/decorators/feature-enabled.decorator.d.ts +8 -0
  22. package/dist/backend/featureFlags/decorators/feature-enabled.decorator.d.ts.map +1 -0
  23. package/dist/backend/featureFlags/decorators/feature-flag.decorator.d.ts +11 -0
  24. package/dist/backend/featureFlags/decorators/feature-flag.decorator.d.ts.map +1 -0
  25. package/dist/backend/featureFlags/feature-flag.controller.d.ts +14 -56
  26. package/dist/backend/featureFlags/feature-flag.controller.d.ts.map +1 -1
  27. package/dist/backend/featureFlags/feature-flag.module.d.ts +36 -44
  28. package/dist/backend/featureFlags/feature-flag.module.d.ts.map +1 -1
  29. package/dist/backend/featureFlags/guards/feature-flag.guard.d.ts +33 -0
  30. package/dist/backend/featureFlags/guards/feature-flag.guard.d.ts.map +1 -0
  31. package/dist/backend/featureFlags/index.d.ts +14 -41
  32. package/dist/backend/featureFlags/index.d.ts.map +1 -1
  33. package/dist/backend/featureFlags/interceptors/error-handling-interceptor.d.ts +16 -0
  34. package/dist/backend/featureFlags/interceptors/error-handling-interceptor.d.ts.map +1 -0
  35. package/dist/backend/featureFlags/interceptors/feature-flag-logging-interceptor.d.ts +18 -0
  36. package/dist/backend/featureFlags/interceptors/feature-flag-logging-interceptor.d.ts.map +1 -0
  37. package/dist/backend/featureFlags/middleware/feature-flag-middleware.d.ts +162 -0
  38. package/dist/backend/featureFlags/middleware/feature-flag-middleware.d.ts.map +1 -0
  39. package/dist/backend/index.d.ts +5 -0
  40. package/dist/backend/index.d.ts.map +1 -1
  41. package/dist/base/cache/CacheKeyBuilder.d.ts +115 -0
  42. package/dist/base/cache/CacheKeyBuilder.d.ts.map +1 -0
  43. package/dist/base/cache/feature/caching.d.ts +16 -0
  44. package/dist/base/cache/feature/caching.d.ts.map +1 -0
  45. package/dist/base/cache/index.d.ts +2 -0
  46. package/dist/base/cache/index.d.ts.map +1 -1
  47. package/dist/base/cache/strategies/redis.d.ts.map +1 -1
  48. package/dist/base/observability/BaseAdapter.d.ts +79 -0
  49. package/dist/base/observability/BaseAdapter.d.ts.map +1 -0
  50. package/dist/base/observability/CompositeAdapter.d.ts +72 -0
  51. package/dist/base/observability/CompositeAdapter.d.ts.map +1 -0
  52. package/dist/base/observability/DatadogAdapter.d.ts +117 -0
  53. package/dist/base/observability/DatadogAdapter.d.ts.map +1 -0
  54. package/dist/base/observability/LoggerAdapter.d.ts +54 -0
  55. package/dist/base/observability/LoggerAdapter.d.ts.map +1 -0
  56. package/dist/base/observability/ObservabilityService.d.ts +160 -0
  57. package/dist/base/observability/ObservabilityService.d.ts.map +1 -0
  58. package/dist/base/observability/index.d.ts +17 -0
  59. package/dist/base/observability/index.d.ts.map +1 -0
  60. package/dist/domain/base/BaseBackendDomainService.d.ts +528 -0
  61. package/dist/domain/base/BaseBackendDomainService.d.ts.map +1 -0
  62. package/dist/domain/base/BaseDomainService.d.ts +284 -0
  63. package/dist/domain/base/BaseDomainService.d.ts.map +1 -0
  64. package/dist/domain/base/BaseFrontendDomainService.d.ts +493 -0
  65. package/dist/domain/base/BaseFrontendDomainService.d.ts.map +1 -0
  66. package/dist/domain/base/BaseMapper.d.ts +100 -0
  67. package/dist/domain/base/BaseMapper.d.ts.map +1 -0
  68. package/dist/domain/base/BaseValidator.d.ts +105 -0
  69. package/dist/domain/base/BaseValidator.d.ts.map +1 -0
  70. package/dist/domain/base/index.d.ts +10 -0
  71. package/dist/domain/base/index.d.ts.map +1 -0
  72. package/dist/domain/example/BackendExampleDomainService.d.ts +257 -0
  73. package/dist/domain/example/BackendExampleDomainService.d.ts.map +1 -0
  74. package/dist/domain/example/FrontendExampleDomainService.d.ts +164 -0
  75. package/dist/domain/example/FrontendExampleDomainService.d.ts.map +1 -0
  76. package/dist/domain/example/index.d.ts +10 -0
  77. package/dist/domain/example/index.d.ts.map +1 -0
  78. package/dist/domain/example/mappers/ExampleMapper.d.ts +67 -0
  79. package/dist/domain/example/mappers/ExampleMapper.d.ts.map +1 -0
  80. package/dist/domain/example/validators/ExampleValidator.d.ts +33 -0
  81. package/dist/domain/example/validators/ExampleValidator.d.ts.map +1 -0
  82. package/dist/domain/featureFlags/FrontendFeatureFlagDomainService.d.ts +86 -0
  83. package/dist/domain/featureFlags/FrontendFeatureFlagDomainService.d.ts.map +1 -0
  84. package/dist/domain/featureFlags/index.d.ts +10 -5
  85. package/dist/domain/featureFlags/index.d.ts.map +1 -1
  86. package/dist/domain/featureFlags/mappers/FeatureFlagMapper.d.ts +72 -0
  87. package/dist/domain/featureFlags/mappers/FeatureFlagMapper.d.ts.map +1 -0
  88. package/dist/domain/featureFlags/mappers/index.d.ts +8 -0
  89. package/dist/domain/featureFlags/mappers/index.d.ts.map +1 -0
  90. package/dist/domain/featureFlags/module.d.ts +20 -0
  91. package/dist/domain/featureFlags/module.d.ts.map +1 -0
  92. package/dist/domain/featureFlags/provider.d.ts +40 -1
  93. package/dist/domain/featureFlags/provider.d.ts.map +1 -1
  94. package/dist/domain/featureFlags/providers/api.d.ts +59 -34
  95. package/dist/domain/featureFlags/providers/api.d.ts.map +1 -1
  96. package/dist/domain/featureFlags/providers/database.d.ts +59 -52
  97. package/dist/domain/featureFlags/providers/database.d.ts.map +1 -1
  98. package/dist/domain/featureFlags/providers/factory.d.ts +50 -33
  99. package/dist/domain/featureFlags/providers/factory.d.ts.map +1 -1
  100. package/dist/domain/featureFlags/providers/file.d.ts +48 -1
  101. package/dist/domain/featureFlags/providers/file.d.ts.map +1 -1
  102. package/dist/domain/featureFlags/providers/memory.d.ts +32 -6
  103. package/dist/domain/featureFlags/providers/memory.d.ts.map +1 -1
  104. package/dist/domain/featureFlags/providers/redis.d.ts +6 -1
  105. package/dist/domain/featureFlags/providers/redis.d.ts.map +1 -1
  106. package/dist/domain/featureFlags/service.d.ts +112 -0
  107. package/dist/domain/featureFlags/service.d.ts.map +1 -0
  108. package/dist/domain/index.d.ts +2 -0
  109. package/dist/domain/index.d.ts.map +1 -1
  110. package/dist/engine/featureFlags/engine.d.ts +8 -0
  111. package/dist/engine/featureFlags/engine.d.ts.map +1 -1
  112. package/dist/entry-backend.d.ts +24 -0
  113. package/dist/entry-backend.d.ts.map +1 -0
  114. package/dist/entry-backend.js +15635 -0
  115. package/dist/entry-backend.js.map +1 -0
  116. package/dist/entry-backend.mjs +15506 -0
  117. package/dist/entry-backend.mjs.map +1 -0
  118. package/dist/entry-frontend.d.ts +23 -0
  119. package/dist/entry-frontend.d.ts.map +1 -0
  120. package/dist/entry-frontend.js +11152 -0
  121. package/dist/entry-frontend.js.map +1 -0
  122. package/dist/entry-frontend.mjs +11089 -0
  123. package/dist/entry-frontend.mjs.map +1 -0
  124. package/dist/events/CoreEventManager.d.ts +116 -0
  125. package/dist/events/CoreEventManager.d.ts.map +1 -0
  126. package/dist/events/index.d.ts +27 -0
  127. package/dist/events/index.d.ts.map +1 -0
  128. package/dist/frontend/base/index.d.ts +8 -0
  129. package/dist/frontend/base/index.d.ts.map +1 -0
  130. package/dist/frontend/components/InitializationError.d.ts +25 -0
  131. package/dist/frontend/components/InitializationError.d.ts.map +1 -0
  132. package/dist/frontend/components/InitializationLoading.d.ts +22 -0
  133. package/dist/frontend/components/InitializationLoading.d.ts.map +1 -0
  134. package/dist/frontend/components/index.d.ts +9 -0
  135. package/dist/frontend/components/index.d.ts.map +1 -0
  136. package/dist/frontend/example/index.d.ts +9 -0
  137. package/dist/frontend/example/index.d.ts.map +1 -0
  138. package/dist/frontend/featureFlags/index.d.ts +28 -7
  139. package/dist/frontend/featureFlags/index.d.ts.map +1 -1
  140. package/dist/frontend/index.d.ts +5 -0
  141. package/dist/frontend/index.d.ts.map +1 -1
  142. package/dist/frontend/providers/ApiProvider.d.ts +41 -0
  143. package/dist/frontend/providers/ApiProvider.d.ts.map +1 -0
  144. package/dist/frontend/providers/PlyazProvider.d.ts +305 -0
  145. package/dist/frontend/providers/PlyazProvider.d.ts.map +1 -0
  146. package/dist/frontend/providers/index.d.ts +8 -0
  147. package/dist/frontend/providers/index.d.ts.map +1 -0
  148. package/dist/frontend/store/feature-flags.d.ts +63 -0
  149. package/dist/frontend/store/feature-flags.d.ts.map +1 -0
  150. package/dist/frontend/store/index.d.ts +14 -0
  151. package/dist/frontend/store/index.d.ts.map +1 -0
  152. package/dist/frontend/store/integrations.d.ts +36 -0
  153. package/dist/frontend/store/integrations.d.ts.map +1 -0
  154. package/dist/frontend/store/service-accessors.d.ts +78 -0
  155. package/dist/frontend/store/service-accessors.d.ts.map +1 -0
  156. package/dist/index.d.ts +6 -2
  157. package/dist/index.d.ts.map +1 -1
  158. package/dist/index.js +15450 -0
  159. package/dist/index.js.map +1 -0
  160. package/dist/index.mjs +13461 -2440
  161. package/dist/index.mjs.map +1 -1
  162. package/dist/init/CoreInitializer.d.ts +582 -0
  163. package/dist/init/CoreInitializer.d.ts.map +1 -0
  164. package/dist/init/ServiceRegistry.d.ts +256 -0
  165. package/dist/init/ServiceRegistry.d.ts.map +1 -0
  166. package/dist/init/index.d.ts +14 -0
  167. package/dist/init/index.d.ts.map +1 -0
  168. package/dist/init/nestjs/CoreModule.d.ts +63 -0
  169. package/dist/init/nestjs/CoreModule.d.ts.map +1 -0
  170. package/dist/init/nestjs/index.d.ts +5 -0
  171. package/dist/init/nestjs/index.d.ts.map +1 -0
  172. package/dist/init/nestjs/index.js +9059 -0
  173. package/dist/init/nestjs/index.js.map +1 -0
  174. package/dist/init/nestjs/index.mjs +9055 -0
  175. package/dist/init/nestjs/index.mjs.map +1 -0
  176. package/dist/init/react.d.ts +33 -0
  177. package/dist/init/react.d.ts.map +1 -0
  178. package/dist/models/example/ExampleRepository.d.ts +124 -0
  179. package/dist/models/example/ExampleRepository.d.ts.map +1 -0
  180. package/dist/models/example/index.d.ts +7 -0
  181. package/dist/models/example/index.d.ts.map +1 -0
  182. package/dist/models/featureFlags/FeatureFlagRepository.d.ts +560 -0
  183. package/dist/models/featureFlags/FeatureFlagRepository.d.ts.map +1 -0
  184. package/dist/models/featureFlags/index.d.ts +7 -0
  185. package/dist/models/featureFlags/index.d.ts.map +1 -0
  186. package/dist/models/index.d.ts +9 -0
  187. package/dist/models/index.d.ts.map +1 -0
  188. package/dist/services/ApiClientService.d.ts +178 -0
  189. package/dist/services/ApiClientService.d.ts.map +1 -0
  190. package/dist/services/CacheService.d.ts +176 -0
  191. package/dist/services/CacheService.d.ts.map +1 -0
  192. package/dist/services/DbService.d.ts +391 -0
  193. package/dist/services/DbService.d.ts.map +1 -0
  194. package/dist/services/NotificationService.d.ts +151 -0
  195. package/dist/services/NotificationService.d.ts.map +1 -0
  196. package/dist/services/StorageService.d.ts +144 -0
  197. package/dist/services/StorageService.d.ts.map +1 -0
  198. package/dist/services/index.d.ts +12 -0
  199. package/dist/services/index.d.ts.map +1 -0
  200. package/dist/utils/common/id.d.ts +83 -0
  201. package/dist/utils/common/id.d.ts.map +1 -0
  202. package/dist/utils/common/index.d.ts +3 -1
  203. package/dist/utils/common/index.d.ts.map +1 -1
  204. package/dist/utils/common/object.d.ts +70 -0
  205. package/dist/utils/common/object.d.ts.map +1 -0
  206. package/dist/utils/common/validation.d.ts +20 -0
  207. package/dist/utils/common/validation.d.ts.map +1 -0
  208. package/dist/utils/featureFlags/conditions.d.ts.map +1 -1
  209. package/dist/utils/featureFlags/context.d.ts +0 -1
  210. package/dist/utils/featureFlags/context.d.ts.map +1 -1
  211. package/dist/utils/index.d.ts +1 -0
  212. package/dist/utils/index.d.ts.map +1 -1
  213. package/dist/utils/mapperUtils.d.ts +38 -0
  214. package/dist/utils/mapperUtils.d.ts.map +1 -0
  215. package/dist/utils/runtime.d.ts +15 -0
  216. package/dist/utils/runtime.d.ts.map +1 -0
  217. package/dist/version.d.ts +24 -0
  218. package/dist/version.d.ts.map +1 -0
  219. package/dist/web_app/auth/add_user.d.ts +3 -0
  220. package/dist/web_app/auth/add_user.d.ts.map +1 -0
  221. package/dist/web_app/auth/update_user.d.ts +2 -0
  222. package/dist/web_app/auth/update_user.d.ts.map +1 -0
  223. package/package.json +102 -15
  224. package/dist/backend/featureFlags/feature-flag.repository.d.ts +0 -85
  225. package/dist/backend/featureFlags/feature-flag.repository.d.ts.map +0 -1
  226. package/dist/backend/featureFlags/feature-flag.service.d.ts +0 -123
  227. package/dist/backend/featureFlags/feature-flag.service.d.ts.map +0 -1
  228. package/dist/frontend/featureFlags/hooks/useFeatureFlag.d.ts +0 -103
  229. package/dist/frontend/featureFlags/hooks/useFeatureFlag.d.ts.map +0 -1
  230. package/dist/frontend/featureFlags/hooks/useFeatureFlagActions.d.ts +0 -35
  231. package/dist/frontend/featureFlags/hooks/useFeatureFlagActions.d.ts.map +0 -1
  232. package/dist/frontend/featureFlags/hooks/useFeatureFlagHelpers.d.ts +0 -55
  233. package/dist/frontend/featureFlags/hooks/useFeatureFlagHelpers.d.ts.map +0 -1
  234. package/dist/frontend/featureFlags/hooks/useFeatureFlagProvider.d.ts +0 -57
  235. package/dist/frontend/featureFlags/hooks/useFeatureFlagProvider.d.ts.map +0 -1
  236. package/dist/frontend/featureFlags/providers/FeatureFlagProvider.d.ts +0 -99
  237. package/dist/frontend/featureFlags/providers/FeatureFlagProvider.d.ts.map +0 -1
  238. package/dist/frontend/featureFlags/providers/FeatureFlagProviderHelpers.d.ts +0 -31
  239. package/dist/frontend/featureFlags/providers/FeatureFlagProviderHelpers.d.ts.map +0 -1
  240. package/dist/frontend/featureFlags/providers/types.d.ts +0 -21
  241. package/dist/frontend/featureFlags/providers/types.d.ts.map +0 -1
  242. package/dist/index.cjs +0 -4383
  243. package/dist/index.cjs.map +0 -1
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Base Validator
3
+ *
4
+ * Abstract base class for domain validators.
5
+ * Handles validation AND sanitization using Zod schemas from @plyaz/types.
6
+ *
7
+ * Supports all HTTP operations:
8
+ * - create (POST)
9
+ * - update (PUT - full replacement)
10
+ * - patch (PATCH - partial update)
11
+ * - delete (DELETE with options)
12
+ * - query (GET params)
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { CreateExampleSchema, PatchExampleSchema } from '@plyaz/types/examples';
17
+ *
18
+ * class ExampleValidator extends BaseValidator<
19
+ * CreateExampleDTO, // create
20
+ * UpdateExampleDTO, // update (full)
21
+ * PatchExampleDTO, // patch (partial)
22
+ * DeleteExampleDTO, // delete options
23
+ * QueryExampleDTO // query params
24
+ * > {
25
+ * constructor() {
26
+ * super({
27
+ * createSchema: CreateExampleSchema,
28
+ * patchSchema: PatchExampleSchema,
29
+ * // ... other schemas
30
+ * });
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ import { ValidationError } from '@plyaz/errors';
36
+ import type { ValidationIssue, BaseErrorContext, InternalValidationSchema } from '@plyaz/types/errors';
37
+ import type { CoreValidationResult, CoreValidatorConfig, CoreBaseValidatorInstance } from '@plyaz/types/core';
38
+ /**
39
+ * Abstract base validator with default implementations
40
+ */
41
+ export declare abstract class BaseValidator<TCreate = unknown, TUpdate = TCreate, TPatch = Partial<TCreate>, TDelete = unknown, TQuery = unknown> implements CoreBaseValidatorInstance<TCreate, TUpdate, TPatch, TDelete, TQuery> {
42
+ protected readonly config: CoreValidatorConfig<TCreate, TUpdate, TPatch, TDelete, TQuery>;
43
+ constructor(config?: CoreValidatorConfig<TCreate, TUpdate, TPatch, TDelete, TQuery>);
44
+ /**
45
+ * Validate data for create operation (POST)
46
+ */
47
+ validateCreate(data: unknown): CoreValidationResult<TCreate>;
48
+ /**
49
+ * Validate data for full update operation (PUT)
50
+ */
51
+ validateUpdate(data: unknown): CoreValidationResult<TUpdate>;
52
+ /**
53
+ * Validate data for partial update operation (PATCH)
54
+ */
55
+ validatePatch(data: unknown): CoreValidationResult<TPatch>;
56
+ /**
57
+ * Validate data for delete operation (DELETE with options)
58
+ */
59
+ validateDelete(data: unknown): CoreValidationResult<TDelete>;
60
+ /**
61
+ * Validate query parameters (GET list)
62
+ */
63
+ validateQuery(data: unknown): CoreValidationResult<TQuery>;
64
+ /**
65
+ * Validate and throw if invalid (for create)
66
+ * @throws ValidationError[] (array) if validation fails
67
+ */
68
+ validateCreateOrThrow(data: unknown): TCreate;
69
+ /**
70
+ * Validate and throw if invalid (for update)
71
+ * @throws ValidationError[] (array) if validation fails
72
+ */
73
+ validateUpdateOrThrow(data: unknown): TUpdate;
74
+ /**
75
+ * Validate and throw if invalid (for patch)
76
+ * @throws ValidationError[] (array) if validation fails
77
+ */
78
+ validatePatchOrThrow(data: unknown): TPatch;
79
+ /**
80
+ * Validate and throw if invalid (for delete)
81
+ * @throws ValidationError[] (array) if validation fails
82
+ */
83
+ validateDeleteOrThrow(data: unknown): TDelete;
84
+ /**
85
+ * Validate and throw if invalid (for query)
86
+ * @throws ValidationError[] (array) if validation fails
87
+ */
88
+ validateQueryOrThrow(data: unknown): TQuery;
89
+ /**
90
+ * Internal validation using ValidateAndFormatErrors from @plyaz/errors
91
+ * This handles both validation AND sanitization (via Zod transforms)
92
+ */
93
+ protected validate<T>(data: unknown, schema: InternalValidationSchema<T>): CoreValidationResult<T>;
94
+ /**
95
+ * Convert ValidationIssue[] to array of ValidationError objects
96
+ * Each validation issue becomes a separate ValidationError
97
+ */
98
+ protected toValidationErrorArray(issues?: ValidationIssue[]): ValidationError[];
99
+ /**
100
+ * Convert ValidationIssue[] to BaseErrorContext (legacy)
101
+ * @deprecated Use toValidationErrorArray instead
102
+ */
103
+ protected toErrorContext(issues?: ValidationIssue[]): BaseErrorContext;
104
+ }
105
+ //# sourceMappingURL=BaseValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseValidator.d.ts","sourceRoot":"","sources":["../../../src/domain/base/BaseValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAA2B,eAAe,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,8BAAsB,aAAa,CACjC,OAAO,GAAG,OAAO,EACjB,OAAO,GAAG,OAAO,EACjB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EACzB,OAAO,GAAG,OAAO,EACjB,MAAM,GAAG,OAAO,CAChB,YAAW,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;IAE/E,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,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3
+ */
4
+ export { BaseDomainService } from './BaseDomainService';
5
+ export { BaseFrontendDomainService } from './BaseFrontendDomainService';
6
+ export { BaseBackendDomainService } from './BaseBackendDomainService';
7
+ export { BaseMapper } from './BaseMapper';
8
+ export { BaseValidator } from './BaseValidator';
9
+ export * from '../../utils/mapperUtils';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/base/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Backend Example Domain Service
3
+ *
4
+ * Demonstrates extending BaseBackendDomainService which provides:
5
+ * - Automatic validation → mapper → repository/API → mapper flow
6
+ * - Event emission throughout CRUD lifecycle
7
+ * - Dual mode: Repository (DbService/dummy) OR HTTP API
8
+ * - Configurable error throwing behavior
9
+ *
10
+ * This service only needs to:
11
+ * - Initialize repository in constructor
12
+ * - Set eventPrefix for event emission
13
+ * - Implement isAvailable() and dispose()
14
+ * - Add any custom domain methods
15
+ *
16
+ * All standard CRUD operations are inherited with cache support:
17
+ * - create(data, options?) - Create with optional caching
18
+ * - patch(id, data, options?) - Update with automatic cache invalidation
19
+ * - delete(id, deleteOptions?, crudOptions?) - Delete with automatic cache invalidation
20
+ * - getById(id, options?) - Read with cache-aside pattern
21
+ *
22
+ * Runtime: Backend (NestJS, Express, Node.js)
23
+ * - Uses repository (DbService or dummy data fallback)
24
+ * - Auto-initialized by Core.initialize() as part of DomainServices
25
+ * - For HTTP API calls, use fetchers from @plyaz/api directly
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * // Create service
30
+ * const service = await BackendExampleDomainService.create({
31
+ * throwOnValidationError: true, // Throw on validation errors (default)
32
+ * throwOnRepositoryError: true, // Throw on repository errors (default)
33
+ * });
34
+ *
35
+ * // Use inherited CRUD methods
36
+ * const entity = await service.create({ name: 'Test', amount: 100 });
37
+ * const updated = await service.patch(entity.id, { amount: 200 });
38
+ * await service.delete(entity.id, { soft: true });
39
+ * ```
40
+ */
41
+ import { BaseBackendDomainService } from '../base';
42
+ import type { ExampleEntity, ExampleResponseDTO, CreateExampleDTO, PatchExampleDTO, QueryExampleDTO, DeleteExampleDTO, ExampleStoreItem, ExampleDomainServiceConfig as _ExampleDomainServiceConfig } from '@plyaz/types/examples';
43
+ import type { CoreServiceCreateOptions, CoreInjectedServices } from '@plyaz/types/core';
44
+ import { ExampleRepository, type ExampleDatabaseRow } from '../../models/example';
45
+ import { ExampleMapperClass } from './mappers/ExampleMapper';
46
+ import { ExampleValidatorClass } from './validators/ExampleValidator';
47
+ /**
48
+ * Mapper type for this service
49
+ */
50
+ type ExampleMapper = InstanceType<typeof ExampleMapperClass>;
51
+ /**
52
+ * Validator type for this service
53
+ */
54
+ type ExampleValidator = InstanceType<typeof ExampleValidatorClass>;
55
+ /**
56
+ * Example event types (for subscription)
57
+ */
58
+ export type ExampleEventType = 'example:creating' | 'example:created' | 'example:updating' | 'example:updated' | 'example:deleting' | 'example:deleted' | 'example:complete' | 'example:error' | 'example:validation:started' | 'example:validation:success' | 'example:validation:failed' | 'example:sanitization:started' | 'example:sanitization:complete';
59
+ /**
60
+ * Backend Example Domain Service
61
+ *
62
+ * Extends BaseBackendDomainService with all generic types:
63
+ * - TConfig: ExampleDomainServiceConfig
64
+ * - TEntity: ExampleEntity
65
+ * - TResponseDTO: ExampleResponseDTO
66
+ * - TCreateDTO: CreateExampleDTO
67
+ * - TUpdateDTO: CreateExampleDTO (same as create)
68
+ * - TPatchDTO: PatchExampleDTO
69
+ * - TQueryDTO: QueryExampleDTO
70
+ * - TDeleteOptions: DeleteExampleDTO
71
+ * - TRepository: ExampleRepository
72
+ * - TDatabaseRow: ExampleDatabaseRow
73
+ * - TStoreState: ExampleStoreItem
74
+ * - TMapper: ExampleMapper
75
+ * - TValidator: ExampleValidator
76
+ *
77
+ * All CRUD methods are inherited from base class - no need to implement!
78
+ */
79
+ export declare class BackendExampleDomainService extends BaseBackendDomainService<_ExampleDomainServiceConfig, ExampleEntity, ExampleResponseDTO, CreateExampleDTO, CreateExampleDTO, // Update same as create
80
+ PatchExampleDTO, QueryExampleDTO, // Query/filter type for getAll()
81
+ DeleteExampleDTO, ExampleDatabaseRow, ExampleRepository, ExampleStoreItem, ExampleMapper, ExampleValidator> {
82
+ /**
83
+ * Repository instance for data access
84
+ * Required by BaseBackendDomainService
85
+ */
86
+ protected repository: ExampleRepository;
87
+ /**
88
+ * Event prefix for all events emitted by this service
89
+ * Required by BaseBackendDomainService
90
+ */
91
+ protected eventPrefix: string;
92
+ /**
93
+ * Cache prefix for namespacing cache keys
94
+ * Optional: defaults to serviceName.toLowerCase() if not set
95
+ */
96
+ protected cachePrefix: string;
97
+ /**
98
+ * Unique key for this service (used by ServiceRegistry)
99
+ */
100
+ static readonly serviceKey: "example";
101
+ /**
102
+ * Factory method for ServiceRegistry auto-initialization.
103
+ * Creates and initializes the service instance.
104
+ *
105
+ * @param config - Service configuration
106
+ * @param options - Global options from the registry (includes cache, db, api instances)
107
+ * @returns Promise resolving to the initialized service instance
108
+ */
109
+ static create(config: _ExampleDomainServiceConfig, options?: CoreServiceCreateOptions): Promise<BackendExampleDomainService>;
110
+ constructor(config?: _ExampleDomainServiceConfig, injected?: CoreInjectedServices);
111
+ /**
112
+ * Check if service is available
113
+ * Service is available if enabled (repository is always available)
114
+ */
115
+ isAvailable(): boolean;
116
+ /**
117
+ * Dispose/cleanup the service
118
+ */
119
+ dispose(): void;
120
+ /**
121
+ * Configure the service (mutates config)
122
+ * Use this to update configuration at runtime
123
+ */
124
+ configure(updates: Partial<_ExampleDomainServiceConfig>): void;
125
+ /**
126
+ * Subscribe to service events
127
+ * Uses CoreEventManager under the hood
128
+ *
129
+ * @param event - Event type to listen for
130
+ * @param handler - Event handler function
131
+ * @returns Unsubscribe function
132
+ */
133
+ on(event: ExampleEventType, handler: (data: unknown) => void): () => void;
134
+ /**
135
+ * Demo: Single validation error
136
+ * Validates data with ONE field invalid to trigger single validation error in array
137
+ *
138
+ * @throws ValidationError[] (array with 1 error)
139
+ */
140
+ demoSingleValidationError(): void;
141
+ /**
142
+ * Demo: Multiple validation errors
143
+ * Validates data with MULTIPLE fields invalid to trigger array of validation errors
144
+ *
145
+ * @throws ValidationError[] (array with multiple errors)
146
+ */
147
+ demoMultipleValidationErrors(): void;
148
+ /**
149
+ * Demo: Get all examples with optional filters
150
+ * Demonstrates the getAll() method with typed query parameters
151
+ *
152
+ * @param filters - Optional query filters (status, pagination, sorting)
153
+ * @returns Promise resolving to array of ExampleEntity
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * // Get all active examples
158
+ * const activeExamples = await service.getExamples({ status: 'active' });
159
+ *
160
+ * // Get archived examples with pagination
161
+ * const archivedExamples = await service.getExamples({
162
+ * status: 'archived',
163
+ * page: 2,
164
+ * limit: 10
165
+ * });
166
+ *
167
+ * // Get all examples sorted by name
168
+ * const sortedExamples = await service.getExamples({
169
+ * sort_by: 'name',
170
+ * sort_order: 'asc'
171
+ * });
172
+ * ```
173
+ */
174
+ getExamples(filters?: QueryExampleDTO): Promise<ExampleEntity[]>;
175
+ /**
176
+ * Demo: Get active examples only
177
+ * Convenience method demonstrating filtering
178
+ */
179
+ getActiveExamples(): Promise<ExampleEntity[]>;
180
+ /**
181
+ * Demo: Get draft examples only
182
+ * Convenience method demonstrating filtering
183
+ */
184
+ getDraftExamples(): Promise<ExampleEntity[]>;
185
+ /**
186
+ * Demo: Get archived examples only
187
+ * Convenience method demonstrating filtering
188
+ */
189
+ getArchivedExamples(): Promise<ExampleEntity[]>;
190
+ /**
191
+ * Demo: Check if an example exists
192
+ * More efficient than fetching the full entity when you only need existence
193
+ *
194
+ * @param id - Example ID to check
195
+ * @returns Promise resolving to boolean
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const exists = await service.checkExampleExists('123');
200
+ * if (exists) {
201
+ * console.log('Example exists!');
202
+ * }
203
+ * ```
204
+ */
205
+ checkExampleExists(id: string): Promise<boolean>;
206
+ /**
207
+ * Demo: Create multiple examples at once
208
+ * More efficient than calling create() multiple times
209
+ *
210
+ * @param dataArray - Array of example data to create
211
+ * @returns Promise resolving to array of created entities
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * const examples = await service.createMultipleExamples([
216
+ * { name: 'Example 1', amount: 100 },
217
+ * { name: 'Example 2', amount: 200 },
218
+ * { name: 'Example 3', amount: 300 },
219
+ * ]);
220
+ * console.log(`Created ${examples.length} examples`);
221
+ * ```
222
+ */
223
+ createMultipleExamples(dataArray: CreateExampleDTO[]): Promise<ExampleEntity[]>;
224
+ /**
225
+ * Demo: Delete multiple examples at once
226
+ * More efficient than calling delete() multiple times
227
+ *
228
+ * @param ids - Array of example IDs to delete
229
+ * @param soft - Whether to soft delete (default: true)
230
+ * @returns Promise resolving when all deletions complete
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * // Soft delete multiple examples
235
+ * await service.deleteMultipleExamples(['id1', 'id2', 'id3'], true);
236
+ *
237
+ * // Hard delete multiple examples
238
+ * await service.deleteMultipleExamples(['id1', 'id2', 'id3'], false);
239
+ * ```
240
+ */
241
+ deleteMultipleExamples(ids: string[], soft?: boolean): Promise<void>;
242
+ }
243
+ /**
244
+ * Default instance of BackendExampleDomainService
245
+ * Use this for singleton pattern usage
246
+ *
247
+ * @example
248
+ * ```tsx
249
+ * import { backendExampleDomainService } from '@plyaz/core';
250
+ *
251
+ * const entity = await backendExampleDomainService.create({ name: 'Test', amount: 100 });
252
+ * ```
253
+ */
254
+ export declare const backendExampleDomainService: BackendExampleDomainService;
255
+ export { backendExampleDomainService as backendExampleService };
256
+ export { backendExampleDomainService as exampleService };
257
+ //# sourceMappingURL=BackendExampleDomainService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackendExampleDomainService.d.ts","sourceRoot":"","sources":["../../../src/domain/example/BackendExampleDomainService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,IAAI,2BAA2B,EAC1D,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAMtE;;GAEG;AACH,KAAK,aAAa,GAAG,YAAY,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE7D;;GAEG;AACH,KAAK,gBAAgB,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAExB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,eAAe,GAEf,4BAA4B,GAC5B,4BAA4B,GAC5B,2BAA2B,GAE3B,8BAA8B,GAC9B,+BAA+B,CAAC;AAMpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,2BAA4B,SAAQ,wBAAwB,CACvE,2BAA2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BAAmB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAQrD;;;;;;;;;;;;;;OAcG;IACG,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItD;;;;;;;;;;;;;;;;OAgBG;IACG,sBAAsB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAIrF;;;;;;;;;;;;;;;;OAgBG;IACG,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA6BxE;AAMD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,6BAAoC,CAAC;AAG7E,OAAO,EAAE,2BAA2B,IAAI,qBAAqB,EAAE,CAAC;AAChE,OAAO,EAAE,2BAA2B,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Example Frontend Service
3
+ *
4
+ * Demonstrates extending BaseFrontendDomainService which provides:
5
+ * - Automatic CRUD operations (fetchAll, fetchById, create, update, delete)
6
+ * - Store integration (Zustand-compatible)
7
+ * - Error handling with @plyaz/errors
8
+ * - Event emission and subscription
9
+ * - Loading/error state management
10
+ * - Automatic DTO validation and mapping via validator and mapper
11
+ *
12
+ * This service only needs to:
13
+ * - Set eventPrefix for event emission
14
+ * - Add any custom domain methods (e.g., polling)
15
+ * - Override lifecycle hooks if needed
16
+ *
17
+ * All standard CRUD operations are inherited:
18
+ * - fetchAll(query?) - Inherited from BaseFrontendDomainService
19
+ * - fetchById(id) - Inherited from BaseFrontendDomainService
20
+ * - create(data) - Inherited from BaseFrontendDomainService
21
+ * - update(id, data) - Inherited from BaseFrontendDomainService
22
+ * - delete(id) - Inherited from BaseFrontendDomainService
23
+ *
24
+ * Runtime: Frontend only (Browser/React/Next.js)
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // Service automatically gets stores via ServiceRegistry injection
29
+ * const service = await ServiceRegistry.getAsync<FrontendExampleDomainService>('example');
30
+ *
31
+ * // Or create directly (stores injected if configured)
32
+ * const service = new FrontendExampleDomainService({
33
+ * enabled: true,
34
+ * apiBasePath: '/api/examples',
35
+ * });
36
+ *
37
+ * // Use inherited CRUD methods
38
+ * const items = await service.fetchAll();
39
+ * const activeItems = await service.fetchAll({ status: 'active' });
40
+ * const item = await service.create({ name: 'Test', amount: 100 });
41
+ * const updated = await service.update(item.id, { amount: 200 });
42
+ * await service.delete(item.id);
43
+ * ```
44
+ */
45
+ import type { ExampleEntity, ExampleResponseDTO, CreateExampleDTO, PatchExampleDTO, QueryExampleDTO, ExampleStoreItem } from '@plyaz/types/examples';
46
+ import { BaseFrontendDomainService } from '../base';
47
+ import { ExampleMapperClass } from './mappers/ExampleMapper';
48
+ export type { ExampleFrontendStoreData, ExampleFrontendStoreSlice, ExampleFrontendServiceConfig, ExampleFrontendEventType, } from '@plyaz/types/examples';
49
+ import type { ExampleFrontendStoreData, ExampleFrontendStoreSlice, ExampleFrontendServiceConfig as _ExampleFrontendServiceConfig, ExampleFrontendEventType } from '@plyaz/types/examples';
50
+ import type { CoreServiceCreateOptions } from '@plyaz/types/core';
51
+ import type { CoreBaseValidatorInstance } from '@plyaz/types/core';
52
+ /**
53
+ * Example Frontend Service
54
+ *
55
+ * Extends BaseFrontendDomainService with all generic types:
56
+ * - TConfig: ExampleFrontendServiceConfig
57
+ * - TStore: ExampleFrontendStoreSlice
58
+ * - TData: ExampleFrontendStoreData
59
+ * - TEntity: ExampleEntity
60
+ * - TResponseDTO: ExampleResponseDTO
61
+ * - TCreateDTO: CreateExampleDTO
62
+ * - TPatchDTO: PatchExampleDTO
63
+ * - TQueryDTO: QueryExampleDTO
64
+ * - TStoreState: ExampleStoreItem
65
+ * - TMapper: ExampleMapper
66
+ *
67
+ * All CRUD methods are inherited from base class - no need to implement!
68
+ */
69
+ export declare class FrontendExampleDomainService extends BaseFrontendDomainService<_ExampleFrontendServiceConfig, ExampleFrontendStoreSlice, ExampleFrontendStoreData, ExampleEntity, ExampleResponseDTO, CreateExampleDTO, PatchExampleDTO, QueryExampleDTO, ExampleStoreItem, InstanceType<typeof ExampleMapperClass>, CoreBaseValidatorInstance, void> {
70
+ /**
71
+ * Event prefix for all events emitted by this service
72
+ * Required by BaseFrontendDomainService
73
+ */
74
+ protected eventPrefix: string;
75
+ /**
76
+ * Primary store key - the store this service can mutate
77
+ */
78
+ protected primaryStoreKey: "example";
79
+ /**
80
+ * Read-only store keys - inherits error and featureFlags from base
81
+ * No need to redeclare them - they're always included by default
82
+ */
83
+ private pollingTimer;
84
+ static readonly serviceKey: "example-frontend";
85
+ /**
86
+ * Factory method for ServiceRegistry auto-initialization.
87
+ * Creates and initializes the service instance.
88
+ */
89
+ static create(config: _ExampleFrontendServiceConfig, options?: CoreServiceCreateOptions): Promise<FrontendExampleDomainService>;
90
+ constructor(config?: _ExampleFrontendServiceConfig, options?: CoreServiceCreateOptions);
91
+ isAvailable(): boolean;
92
+ dispose(): void;
93
+ /**
94
+ * After fetchAll - emit event (store sync handled automatically)
95
+ * Note: Base class automatically calls syncToStores() which uses storeHandlers
96
+ */
97
+ protected afterFetchAll(entities: ExampleEntity[]): Promise<void>;
98
+ /**
99
+ * Subscribe to service events
100
+ *
101
+ * @example
102
+ * ```tsx
103
+ * const unsubscribe = service.on('example:created', (data) => {
104
+ * console.log('Item created:', data.entity);
105
+ * });
106
+ *
107
+ * // Later: cleanup
108
+ * unsubscribe();
109
+ * ```
110
+ */
111
+ on(event: ExampleFrontendEventType, handler: (data: unknown) => void): () => void;
112
+ /**
113
+ * Start polling for updates
114
+ * Domain-specific feature - not part of base class
115
+ */
116
+ startPolling(): void;
117
+ /**
118
+ * Stop polling
119
+ */
120
+ stopPolling(): void;
121
+ /**
122
+ * Demo: Fetch all examples with optional filters
123
+ * Demonstrates the fetchAll() method with typed query parameters
124
+ *
125
+ * @param filters - Optional query filters (status, pagination, sorting)
126
+ * @returns Promise resolving to array of ExampleEntity
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * // Fetch all active examples
131
+ * const activeExamples = await service.getExamples({ status: 'active' });
132
+ *
133
+ * // Fetch archived examples with pagination
134
+ * const archivedExamples = await service.getExamples({
135
+ * status: 'archived',
136
+ * page: 2,
137
+ * limit: 10
138
+ * });
139
+ *
140
+ * // Fetch all examples sorted by name
141
+ * const sortedExamples = await service.getExamples({
142
+ * sort_by: 'name',
143
+ * sort_order: 'asc'
144
+ * });
145
+ * ```
146
+ */
147
+ getExamples(filters?: QueryExampleDTO): Promise<ExampleEntity[]>;
148
+ /**
149
+ * Demo: Fetch active examples only
150
+ * Convenience method demonstrating filtering
151
+ */
152
+ getActiveExamples(): Promise<ExampleEntity[]>;
153
+ /**
154
+ * Demo: Fetch draft examples only
155
+ * Convenience method demonstrating filtering
156
+ */
157
+ getDraftExamples(): Promise<ExampleEntity[]>;
158
+ /**
159
+ * Demo: Fetch archived examples only
160
+ * Convenience method demonstrating filtering
161
+ */
162
+ getArchivedExamples(): Promise<ExampleEntity[]>;
163
+ }
164
+ //# sourceMappingURL=FrontendExampleDomainService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrontendExampleDomainService.d.ts","sourceRoot":"","sources":["../../../src/domain/example/FrontendExampleDomainService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAc7D,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EACV,wBAAwB,EACxB,yBA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AC,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAItE;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAInD;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAIlD;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAkBtD"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Example Domain Exports
3
+ *
4
+ * Types and schemas should be imported from @plyaz/types/examples
5
+ */
6
+ export { BackendExampleDomainService, backendExampleDomainService, backendExampleService, exampleService, type ExampleEventType, } from './BackendExampleDomainService';
7
+ export { FrontendExampleDomainService, type ExampleFrontendStoreSlice, type ExampleFrontendStoreData, type ExampleFrontendServiceConfig, type ExampleFrontendEventType, } from './FrontendExampleDomainService';
8
+ export { ExampleMapper } from './mappers/ExampleMapper';
9
+ export { ExampleValidator } from './validators/ExampleValidator';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/example/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,KAAK,gBAAgB,GACtB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,GAC9B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Example Mapper
3
+ *
4
+ * Demonstrates extending BaseMapper for a domain entity.
5
+ * Uses types from @plyaz/types/examples.
6
+ *
7
+ * Note: Validation is handled by ExampleValidator, not here.
8
+ */
9
+ import { BaseMapper } from '../../base';
10
+ import type { ExampleEntity, ExampleResponseDTO, ExampleStoreItem, CreateExampleDTO, UpdateExampleDTO, PatchExampleDTO, QueryExampleDTO } from '@plyaz/types/examples';
11
+ /**
12
+ * Example Mapper implementation
13
+ *
14
+ * Supports:
15
+ * - toDomain: API response → Domain
16
+ * - toCreateDTO: Domain → POST body
17
+ * - toPatchDTO: Domain → PATCH body
18
+ * - toStoreState: Domain → Zustand store
19
+ */
20
+ declare class ExampleMapperClass extends BaseMapper<ExampleEntity, ExampleResponseDTO, CreateExampleDTO, UpdateExampleDTO, PatchExampleDTO, QueryExampleDTO, ExampleStoreItem> {
21
+ /**
22
+ * API DTO → Domain Model
23
+ */
24
+ toDomain(dto: ExampleResponseDTO): ExampleEntity;
25
+ /**
26
+ * Domain data → Create DTO (POST body)
27
+ */
28
+ toCreateDTO(data: Partial<ExampleEntity>): CreateExampleDTO;
29
+ /**
30
+ * Domain data → Update DTO (PUT body - full)
31
+ */
32
+ toUpdateDTO(data: Partial<ExampleEntity>): UpdateExampleDTO;
33
+ /**
34
+ * Domain data → Patch DTO (PATCH body - partial)
35
+ */
36
+ toPatchDTO(data: Partial<ExampleEntity>): PatchExampleDTO;
37
+ /**
38
+ * Filters → Query params DTO (GET)
39
+ */
40
+ toQueryDTO(filters: Partial<QueryExampleDTO>): QueryExampleDTO;
41
+ /**
42
+ * Domain → Store state (serializable)
43
+ */
44
+ toStoreState(domain: ExampleEntity): ExampleStoreItem;
45
+ /**
46
+ * Store state → Domain (restore computed props)
47
+ */
48
+ fromStoreState(state: ExampleStoreItem): ExampleEntity;
49
+ /**
50
+ * Database row → Response DTO
51
+ * Maps repository output to API response format
52
+ */
53
+ toResponseDTO(row: {
54
+ id: string;
55
+ name: string;
56
+ description: string | null;
57
+ amount: number;
58
+ owner_id: string;
59
+ status: string;
60
+ is_visible: boolean;
61
+ created_at: string;
62
+ updated_at: string;
63
+ }): ExampleResponseDTO;
64
+ }
65
+ export { ExampleMapperClass };
66
+ export declare const ExampleMapper: ExampleMapperClass;
67
+ //# sourceMappingURL=ExampleMapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleMapper.d.ts","sourceRoot":"","sources":["../../../../src/domain/example/mappers/ExampleMapper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAQ/B;;;;;;;;GAQG;AACH,cAAM,kBAAmB,SAAQ,UAAU,CACzC,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,CACjB;IACC;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,aAAa;IAkBhD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,gBAAgB;IAS3D;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,gBAAgB;IAI3D;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,eAAe;IAmBzD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe;IAc9D;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB;IAgBrD;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa;IAgBtD;;;OAGG;IACH,aAAa,CAAC,GAAG,EAAE;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,MAAM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