@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,391 @@
1
+ /**
2
+ * DbService - Singleton Database Connection Manager
3
+ *
4
+ * @description Manages database connections for the entire application using a singleton pattern.
5
+ * This service wraps @plyaz/db and provides a centralized way to initialize and access
6
+ * the database across all domains (feature flags, users, campaigns, backoffice, etc.).
7
+ *
8
+ * **Architecture:**
9
+ * - Uses `createDatabaseService()` from @plyaz/db which builds an adapter chain
10
+ * - Supports Drizzle (direct PostgreSQL), Supabase (REST API), or raw SQL adapters
11
+ * - Extension layers: Encryption → SoftDelete → Caching → Audit → ReadReplica
12
+ *
13
+ * **Adapter Configuration:**
14
+ * - **Drizzle**: Requires `connectionString` (PostgreSQL URL)
15
+ * - **Supabase**: Requires `supabaseUrl`, `supabaseServiceKey`, `supabaseAnonKey`
16
+ * - **SQL**: Requires `connectionString`
17
+ *
18
+ * **Required Environment Variables (Drizzle with Supabase):**
19
+ * - DATABASE_URL: PostgreSQL connection string (from Supabase Dashboard > Database > URI)
20
+ *
21
+ * **Required Environment Variables (Supabase REST API):**
22
+ * - SUPABASE_URL: Your Supabase project URL
23
+ * - SUPABASE_SERVICE_ROLE_KEY: Service role key for admin operations
24
+ * - SUPABASE_ANON_PUBLIC_KEY: Anonymous key for public operations
25
+ *
26
+ * @example Using with Core.initialize() (Recommended)
27
+ * ```typescript
28
+ * import { Core } from '@plyaz/core';
29
+ *
30
+ * // Core.initialize() handles loading env and passing to DbService
31
+ * await Core.initialize({
32
+ * envPath: '.env',
33
+ * db: {
34
+ * adapter: 'sql',
35
+ * cache: { enabled: true, ttl: 60 },
36
+ * },
37
+ * });
38
+ *
39
+ * // Access via Core.db
40
+ * const db = Core.db.getDatabase();
41
+ * const result = await db.list('users', { pagination: { limit: 10, offset: 0 } });
42
+ * ```
43
+ *
44
+ * @example Direct Usage (requires explicit config)
45
+ * ```typescript
46
+ * // Direct usage requires explicit connectionString
47
+ * await DbService.initialize({
48
+ * adapter: 'drizzle',
49
+ * drizzle: {
50
+ * connectionString: 'postgresql://user:pass@localhost:5432/db',
51
+ * poolSize: 20,
52
+ * },
53
+ * });
54
+ * ```
55
+ *
56
+ * @example With Extensions
57
+ * ```typescript
58
+ * await Core.initialize({
59
+ * envPath: '.env',
60
+ * db: {
61
+ * adapter: 'drizzle',
62
+ * softDelete: {
63
+ * enabled: true,
64
+ * field: 'deleted_at',
65
+ * excludeTables: ['audit_logs', 'feature_flag_evaluations'],
66
+ * },
67
+ * cache: {
68
+ * enabled: true,
69
+ * provider: 'memory',
70
+ * ttl: 300,
71
+ * },
72
+ * audit: {
73
+ * enabled: true,
74
+ * retentionDays: 90,
75
+ * },
76
+ * },
77
+ * });
78
+ * ```
79
+ *
80
+ * @example Using with BaseRepository
81
+ * ```typescript
82
+ * import { BaseRepository } from '@plyaz/db';
83
+ * import { DbService } from '@plyaz/core';
84
+ *
85
+ * class UserRepository extends BaseRepository<User> {
86
+ * constructor() {
87
+ * super(DbService.getInstance().getDatabase(), 'users');
88
+ * }
89
+ * }
90
+ * ```
91
+ *
92
+ * @module services
93
+ */
94
+ import { type DatabaseServiceInterface, type Transaction } from '@plyaz/types/db';
95
+ /**
96
+ * Default fields to encrypt per table
97
+ * Contains sensitive PII and financial data that should be encrypted at rest
98
+ *
99
+ * @see docs/db-schemas/dbdiagram_schema.dbml for field definitions
100
+ */
101
+ export declare const DEFAULT_ENCRYPTION_FIELDS: Record<string, string[]>;
102
+ export type { CoreDbServiceConfig } from '@plyaz/types/core';
103
+ import type { CoreDbServiceConfig as DbServiceConfig } from '@plyaz/types/core';
104
+ /**
105
+ * Complete table registry from database migrations
106
+ * Maps logical table names to their ID columns
107
+ *
108
+ * @see docs/db-schemas/migrations/ for schema definitions
109
+ * @see docs/db-schemas/dbdiagram_schema.dbml for full schema
110
+ */
111
+ /**
112
+ * TABLE_REGISTRY - Custom ID Column and Schema Registry
113
+ *
114
+ * ONLY register tables with:
115
+ * 1. Custom ID columns (anything other than 'id')
116
+ * 2. Custom database schemas (anything other than 'public')
117
+ *
118
+ * Tables with standard 'id' column in 'public' schema do NOT need registration.
119
+ * You can also override ID column and schema per-query using OperationConfig.
120
+ *
121
+ * Schema can be defined in the table key or in the config object (or both):
122
+ * - 'schema.table': { idColumn: 'key' } ← Schema in key only
123
+ * - 'schema.table': { idColumn: 'key', schema: 'schema' } ← Redundant but allowed
124
+ * - 'schema.table': {} ← Empty config, schema in key
125
+ * - 'table': { idColumn: 'key', schema: 'schema' } ← Schema in config only
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * // Using registry
130
+ * await db.get('feature_flags', 'my-flag-key'); // Uses 'key' column from registry
131
+ *
132
+ * // Per-query override
133
+ * await db.get('custom_table', 'some-key', { idColumn: 'custom_id' });
134
+ *
135
+ * // Schema override
136
+ * await db.get('logs', '123', { schema: 'logging' });
137
+ * ```
138
+ */
139
+ export declare const TABLE_REGISTRY: Record<string, {
140
+ idColumn?: string;
141
+ schema?: string;
142
+ }>;
143
+ /**
144
+ * DbService - Singleton Database Connection Manager
145
+ *
146
+ * Provides centralized database connection management for all domains.
147
+ * Uses @plyaz/db under the hood with configurable adapters and extensions.
148
+ */
149
+ export declare class DbService {
150
+ private static instance;
151
+ private databaseService;
152
+ private namedAdapters;
153
+ private config;
154
+ private initialized;
155
+ private constructor();
156
+ /**
157
+ * Emits a database error event via CoreEventManager.
158
+ * Called when database operations fail to integrate with global error handling.
159
+ *
160
+ * @param error - The error that occurred
161
+ * @param operation - The operation that failed (e.g., 'transaction', 'query', 'healthCheck')
162
+ * @param table - Optional table name involved in the operation
163
+ * @param query - Optional query string that failed
164
+ * @param recoverable - Whether the error is recoverable (default: false)
165
+ */
166
+ private emitDatabaseError;
167
+ /**
168
+ * Gets the singleton instance of DbService
169
+ *
170
+ * @returns {DbService} The singleton instance
171
+ */
172
+ static getInstance(): DbService;
173
+ /**
174
+ * Checks if the database service has been initialized
175
+ *
176
+ * @returns {boolean} True if initialized
177
+ */
178
+ static isInitialized(): boolean;
179
+ /**
180
+ * Resets the database service by closing connections and clearing the singleton instance
181
+ *
182
+ * @description Properly closes the database connection and clears the singleton.
183
+ * Useful for testing or when you need to reinitialize with different configuration.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * await DbService.reset();
188
+ * await DbService.initialize({ adapter: 'sql', ... });
189
+ * ```
190
+ */
191
+ static reset(): Promise<void>;
192
+ /**
193
+ * Initializes the database connection
194
+ *
195
+ * @description Sets up the database connection using the provided configuration
196
+ * or environment variables. This method is idempotent - calling it multiple
197
+ * times won't create additional connections.
198
+ *
199
+ * **Environment Variables:**
200
+ * - `DATABASE_URL` - PostgreSQL connection string (for sql/drizzle adapters)
201
+ * - `ENCRYPTION_KEY` - 32-byte encryption key for field encryption (optional)
202
+ * - `SUPABASE_URL`, `SUPABASE_SERVICE_ROLE_KEY`, `SUPABASE_ANON_PUBLIC_KEY` - For supabase adapter
203
+ *
204
+ * **Encryption:** If `ENCRYPTION_KEY` env is set, encryption is auto-enabled
205
+ * using `DEFAULT_ENCRYPTION_FIELDS`. Override via config.encryption.
206
+ *
207
+ * @param {DbServiceConfig} [config] - Optional configuration
208
+ * @returns {Promise<DbService>} The initialized DbService instance
209
+ * @throws {DatabasePackageError} When configuration is invalid or connection fails
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * // Minimal - uses DATABASE_URL env, auto-enables encryption if ENCRYPTION_KEY set
214
+ * await DbService.initialize();
215
+ *
216
+ * // With explicit encryption
217
+ * await DbService.initialize({
218
+ * adapter: 'sql',
219
+ * encryption: {
220
+ * enabled: true,
221
+ * key: 'your-32-byte-encryption-key-here!!',
222
+ * fields: DEFAULT_ENCRYPTION_FIELDS,
223
+ * },
224
+ * });
225
+ *
226
+ * // Or via Core.initialize() with env:
227
+ * await Core.initialize({
228
+ * env: { ENCRYPTION_KEY: '...' },
229
+ * db: { adapter: 'sql' },
230
+ * });
231
+ * ```
232
+ */
233
+ /** Build encryption config from user config */
234
+ private static buildEncryptionConfig;
235
+ /** Merge user config with defaults */
236
+ private static mergeConfig;
237
+ /** Initialize named adapters */
238
+ private initializeNamedAdapters;
239
+ static initialize(config?: DbServiceConfig): Promise<DbService>;
240
+ /**
241
+ * Builds the DatabaseServiceConfig based on the adapter type
242
+ * @private
243
+ */
244
+ /** Builds adapter-specific config based on adapter type */
245
+ private buildAdapterConfig;
246
+ /** Builds soft delete extension config */
247
+ private buildSoftDeleteExtension;
248
+ /** Builds cache extension config */
249
+ private buildCacheExtension;
250
+ /** Builds audit extension config */
251
+ private buildAuditExtension;
252
+ /** Builds encryption extension config */
253
+ private buildEncryptionExtension;
254
+ private buildDatabaseConfig;
255
+ /**
256
+ * Builds Drizzle adapter configuration
257
+ * @private
258
+ */
259
+ private buildDrizzleConfig;
260
+ /**
261
+ * Builds Supabase adapter configuration
262
+ * @private
263
+ */
264
+ private buildSupabaseConfig;
265
+ /**
266
+ * Builds SQL adapter configuration
267
+ * @private
268
+ */
269
+ private buildSqlConfig;
270
+ /**
271
+ * Builds table ID column mappings from TABLE_REGISTRY
272
+ * @private
273
+ * @returns Record of table names to ID column names
274
+ */
275
+ private buildTableIdColumns;
276
+ /**
277
+ * Gets the initialized database service instance
278
+ *
279
+ * @param {string} [adapterName] - Optional named adapter to use instead of default
280
+ * @returns {DatabaseServiceInterface} The database service instance
281
+ * @throws {DatabasePackageError} When database is not initialized or named adapter not found
282
+ */
283
+ getDatabase(adapterName?: string): DatabaseServiceInterface;
284
+ /**
285
+ * Gets a named adapter by name
286
+ *
287
+ * @param {string} name - The name of the adapter
288
+ * @returns {DatabaseServiceInterface} The named adapter instance
289
+ * @throws {DatabasePackageError} When adapter not found
290
+ */
291
+ getAdapter(name: string): DatabaseServiceInterface;
292
+ /**
293
+ * Lists all available named adapters
294
+ *
295
+ * @returns {string[]} Array of adapter names
296
+ */
297
+ getAvailableAdapters(): string[];
298
+ /**
299
+ * Executes a database transaction with automatic rollback on failure
300
+ *
301
+ * @template T The return type of the transaction callback
302
+ * @param {Function} callback - Function that receives transaction object
303
+ * @returns {Promise<T>} The result of the transaction callback
304
+ * @throws {DatabasePackageError} When transaction fails
305
+ */
306
+ transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>;
307
+ /**
308
+ * Sets audit context for subsequent operations
309
+ *
310
+ * @param context - Audit context (userId, requestId, etc.)
311
+ */
312
+ setAuditContext(context: {
313
+ userId?: string;
314
+ requestId?: string;
315
+ ipAddress?: string;
316
+ userAgent?: string;
317
+ }): Promise<void>;
318
+ /**
319
+ * Performs a health check on the database connection
320
+ *
321
+ * @returns Health check result
322
+ */
323
+ healthCheck(): Promise<{
324
+ isHealthy: boolean;
325
+ responseTime?: number;
326
+ error?: string;
327
+ }>;
328
+ /**
329
+ * Gets the table registry with all known tables and their ID columns
330
+ *
331
+ * @returns The complete table registry
332
+ */
333
+ static getTableRegistry(): typeof TABLE_REGISTRY;
334
+ /**
335
+ * Gets ID column for a specific table
336
+ *
337
+ * @param tableName - Name of the table
338
+ * @returns ID column name or 'id' as default
339
+ */
340
+ static getTableIdColumn(tableName: string): string;
341
+ /**
342
+ * Reinitializes the database connection with new config
343
+ *
344
+ * @param {DbServiceConfig} [config] - New configuration
345
+ * @returns {Promise<DbService>} The reinitialized DbService instance
346
+ */
347
+ static reinitialize(config?: DbServiceConfig): Promise<DbService>;
348
+ /**
349
+ * Closes the database connection and cleans up resources
350
+ */
351
+ close(): Promise<void>;
352
+ /**
353
+ * Gets the current configuration
354
+ *
355
+ * @returns {DbServiceConfig | null} Current config or null if not initialized
356
+ */
357
+ getConfig(): DbServiceConfig | null;
358
+ /**
359
+ * Gets the current adapter type
360
+ *
361
+ * @returns The adapter type or null if not initialized
362
+ */
363
+ getAdapterType(): 'drizzle' | 'supabase' | 'sql' | null;
364
+ /**
365
+ * Creates a dedicated database service instance (NOT the singleton)
366
+ *
367
+ * Use this when you need an isolated database connection with its own configuration
368
+ * that doesn't affect or get affected by the shared singleton instance.
369
+ *
370
+ * @param config - Database service configuration
371
+ * @returns Promise that resolves to a new dedicated DbService instance
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * // Create a dedicated instance for analytics database
376
+ * const analyticsDb = await DbService.createInstance({
377
+ * adapter: 'sql',
378
+ * sql: { connectionString: process.env.ANALYTICS_DB_URL },
379
+ * cache: { enabled: false }, // No caching for analytics
380
+ * });
381
+ *
382
+ * // This instance is independent from DbService.getInstance()
383
+ * const data = await analyticsDb.getDatabase().list('events');
384
+ *
385
+ * // Clean up when done
386
+ * await analyticsDb.close();
387
+ * ```
388
+ */
389
+ static createInstance(config: DbServiceConfig): Promise<DbService>;
390
+ }
391
+ //# sourceMappingURL=DbService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbService.d.ts","sourceRoot":"","sources":["../../src/services/DbService.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * NotificationService - Singleton Notification Manager
3
+ *
4
+ * @description Manages notification delivery for the entire application using a singleton pattern.
5
+ * This service wraps @plyaz/notifications and provides a centralized way to initialize and access
6
+ * notification capabilities across all domains (transactional, marketing, system alerts, etc.).
7
+ *
8
+ * **Architecture:**
9
+ * - Uses `NotificationService` from @plyaz/notifications which supports multi-provider setup
10
+ * - Supports email (Infobip primary, SendGrid fallback), SMS, and push notifications
11
+ * - Automatic failover between providers based on health status
12
+ * - Event-driven architecture for tracking delivery, opens, clicks
13
+ * - **Proxy-based method forwarding**: All methods from the underlying service are
14
+ * automatically available with error handling - no manual wrapping needed
15
+ *
16
+ * **Provider Configuration:**
17
+ * - **Infobip**: Primary email provider (unified omnichannel platform)
18
+ * - **SendGrid**: Fallback email provider for transactional emails
19
+ *
20
+ * **Required Environment Variables (Infobip):**
21
+ * - INFOBIP_API_KEY: Your Infobip API key
22
+ * - INFOBIP_BASE_URL: Infobip API base URL
23
+ * - FROM_EMAIL: Default sender email address
24
+ *
25
+ * **Required Environment Variables (SendGrid):**
26
+ * - SENDGRID_API_KEY: Your SendGrid API key
27
+ * - FROM_EMAIL: Default sender email address
28
+ *
29
+ * @example Using with Core.initialize() (Recommended)
30
+ * ```typescript
31
+ * import { Core } from '@plyaz/core';
32
+ *
33
+ * await Core.initialize({
34
+ * notifications: {
35
+ * providers: {
36
+ * email: [infobipAdapter, sendGridAdapter],
37
+ * sms: [],
38
+ * push: [],
39
+ * },
40
+ * events: {
41
+ * onSent: (event) => console.log('Notification sent:', event),
42
+ * onFailed: (event) => console.error('Notification failed:', event),
43
+ * },
44
+ * },
45
+ * });
46
+ *
47
+ * // Access via Core.notifications - all methods automatically available
48
+ * await Core.notifications.sendEmail({
49
+ * recipientId: 'user-123',
50
+ * to: 'user@example.com',
51
+ * templateId: 'welcome',
52
+ * templateData: { userName: 'John' },
53
+ * });
54
+ * ```
55
+ *
56
+ * @module services
57
+ */
58
+ import { NotificationService as NotificationServiceImpl } from '@plyaz/notifications';
59
+ import type { CoreNotificationConfig } from '@plyaz/types/core';
60
+ export type { CoreNotificationConfig } from '@plyaz/types/core';
61
+ /**
62
+ * NotificationService - Singleton Notification Manager with Proxy-based method forwarding
63
+ *
64
+ * Provides centralized notification management for all domains.
65
+ * Uses @plyaz/notifications under the hood with configurable providers and templates.
66
+ *
67
+ * All methods from the underlying NotificationServiceImpl are automatically available
68
+ * via Proxy - when new methods are added to @plyaz/notifications, they're instantly
69
+ * accessible here with automatic error handling.
70
+ */
71
+ export declare class NotificationService {
72
+ private static instance;
73
+ private notificationService;
74
+ private config;
75
+ private initialized;
76
+ private constructor();
77
+ /**
78
+ * Emits a notification error event via CoreEventManager.
79
+ * Called when notification operations fail to integrate with global error handling.
80
+ */
81
+ private emitNotificationError;
82
+ /**
83
+ * Gets the singleton instance of NotificationService
84
+ */
85
+ static getInstance(): NotificationService;
86
+ /**
87
+ * Checks if the notification service has been initialized
88
+ */
89
+ static isInitialized(): boolean;
90
+ /**
91
+ * Resets the notification service by clearing the singleton instance
92
+ */
93
+ static reset(): Promise<void>;
94
+ /**
95
+ * Initializes the notification service
96
+ *
97
+ * @param config - Notification service configuration
98
+ * @returns The initialized NotificationService instance
99
+ */
100
+ static initialize(config: CoreNotificationConfig): Promise<NotificationService>;
101
+ /**
102
+ * Gets the raw underlying notification service instance without error handling wrapper.
103
+ * Use this only if you need direct access to the underlying service.
104
+ *
105
+ * @returns The raw NotificationService instance from @plyaz/notifications
106
+ * @throws {NotificationsPackageError} When notifications is not initialized
107
+ */
108
+ private getRawNotifications;
109
+ /**
110
+ * Gets the notification service with automatic error handling.
111
+ * All method calls are wrapped with try/catch and emit error events on failure.
112
+ * Any method added to @plyaz/notifications will be automatically available.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const notifications = NotificationService.getInstance().getNotifications();
117
+ * await notifications.sendEmail({ to: 'user@example.com', templateId: 'welcome' });
118
+ * await notifications.sendSMS({ to: '+1234567890', message: 'Hello!' });
119
+ * ```
120
+ *
121
+ * @returns NotificationServiceImpl with automatic error handling
122
+ */
123
+ getNotifications(): NotificationServiceImpl;
124
+ /**
125
+ * Performs a health check on the notification service.
126
+ * This method has special handling to transform the response format.
127
+ */
128
+ healthCheck(): Promise<{
129
+ isHealthy: boolean;
130
+ providers?: unknown[];
131
+ error?: string;
132
+ }>;
133
+ /**
134
+ * Gets the current configuration
135
+ */
136
+ getConfig(): CoreNotificationConfig | null;
137
+ /**
138
+ * Closes the notification service and cleans up resources
139
+ */
140
+ close(): Promise<void>;
141
+ /**
142
+ * Creates a dedicated notification service instance (NOT the singleton)
143
+ *
144
+ * Use this when you need an isolated notification service with its own configuration.
145
+ *
146
+ * @param config - Notification service configuration
147
+ * @returns Promise that resolves to a new dedicated NotificationService instance
148
+ */
149
+ static createInstance(config: CoreNotificationConfig): Promise<NotificationService>;
150
+ }
151
+ //# sourceMappingURL=NotificationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../src/services/NotificationService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAMhE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAShE;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;IAC3D,OAAO,CAAC,mBAAmB,CAAwC;IACnE,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO;IAMP;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAmB7B;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,mBAAmB;IAKzC;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;IAI/B;;OAEG;WACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IASnC;;;;;OAKG;WACU,UAAU,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAcrF;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;;;;;;;;;;;;OAaG;IACH,gBAAgB,IAAI,uBAAuB;IA6C3C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAyB3F;;OAEG;IACH,SAAS,IAAI,sBAAsB,GAAG,IAAI;IAI1C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;;;;;;OAOG;WACU,cAAc,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAO1F"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * StorageService - Singleton File Storage Manager
3
+ *
4
+ * @description Manages file storage operations for the entire application using a singleton pattern.
5
+ * This service wraps @plyaz/storage and provides a centralized way to initialize and access
6
+ * file storage across all domains (media uploads, compliance documents, user avatars, etc.).
7
+ *
8
+ * **Architecture:**
9
+ * - Uses `StorageService` from @plyaz/storage which supports multi-provider setup
10
+ * - Supports Cloudflare R2 (compliance documents) and Supabase Storage (assets/media)
11
+ * - Automatic failover between providers based on health status
12
+ * - Event-driven architecture with 40+ event types
13
+ * - **Proxy-based method forwarding**: All methods from the underlying service are
14
+ * automatically available with error handling - no manual wrapping needed
15
+ *
16
+ * **Provider Configuration:**
17
+ * - **Cloudflare R2**: For compliance documents (tax, invoices, KYC) with zero egress fees
18
+ * - **Supabase Storage**: For assets like images, user avatars, media files
19
+ *
20
+ * **Required Environment Variables (Cloudflare R2):**
21
+ * - CLOUDFLARE_ACCOUNT_ID: Your Cloudflare account ID
22
+ * - R2_ACCESS_KEY_ID: R2 access key
23
+ * - R2_SECRET_ACCESS_KEY: R2 secret key
24
+ * - R2_BUCKET_NAME: Default bucket name
25
+ *
26
+ * **Required Environment Variables (Supabase Storage):**
27
+ * - SUPABASE_URL: Your Supabase project URL
28
+ * - SUPABASE_SERVICE_ROLE_KEY: Service role key for storage operations
29
+ *
30
+ * @example Using with Core.initialize() (Recommended)
31
+ * ```typescript
32
+ * import { Core } from '@plyaz/core';
33
+ *
34
+ * await Core.initialize({
35
+ * storage: {
36
+ * adapters: [r2Adapter, supabaseAdapter],
37
+ * plugins: [virusScanPlugin, sharpImagePlugin],
38
+ * },
39
+ * });
40
+ *
41
+ * // Access via Core.storage - all methods automatically available
42
+ * const result = await Core.storage.uploadFile({
43
+ * file: buffer,
44
+ * filename: 'document.pdf',
45
+ * category: FILE_CATEGORY.COMPLIANCE_DOCUMENT,
46
+ * });
47
+ * ```
48
+ *
49
+ * @module services
50
+ */
51
+ import { StorageService as StorageServiceImpl } from '@plyaz/storage';
52
+ import type { CoreStorageConfig } from '@plyaz/types/core';
53
+ export type { CoreStorageConfig } from '@plyaz/types/core';
54
+ /**
55
+ * StorageService - Singleton File Storage Manager with Proxy-based method forwarding
56
+ *
57
+ * Provides centralized file storage management for all domains.
58
+ * Uses @plyaz/storage under the hood with configurable providers and plugins.
59
+ *
60
+ * All methods from the underlying StorageServiceImpl are automatically available
61
+ * via Proxy - when new methods are added to @plyaz/storage, they're instantly
62
+ * accessible here with automatic error handling.
63
+ */
64
+ export declare class StorageService {
65
+ private static instance;
66
+ private storageService;
67
+ private config;
68
+ private initialized;
69
+ private constructor();
70
+ /**
71
+ * Emits a storage error event via CoreEventManager.
72
+ * Called when storage operations fail to integrate with global error handling.
73
+ */
74
+ private emitStorageError;
75
+ /**
76
+ * Gets the singleton instance of StorageService
77
+ */
78
+ static getInstance(): StorageService;
79
+ /**
80
+ * Checks if the storage service has been initialized
81
+ */
82
+ static isInitialized(): boolean;
83
+ /**
84
+ * Resets the storage service by clearing the singleton instance
85
+ */
86
+ static reset(): Promise<void>;
87
+ /**
88
+ * Initializes the storage service
89
+ *
90
+ * @param config - Storage service configuration
91
+ * @returns The initialized StorageService instance
92
+ */
93
+ static initialize(config: CoreStorageConfig): Promise<StorageService>;
94
+ /**
95
+ * Gets the raw underlying storage service instance without error handling wrapper.
96
+ * Use this only if you need direct access to the underlying service.
97
+ *
98
+ * @returns The raw StorageService instance from @plyaz/storage
99
+ * @throws {StoragePackageError} When storage is not initialized
100
+ */
101
+ private getRawStorage;
102
+ /**
103
+ * Gets the storage service with automatic error handling.
104
+ * All method calls are wrapped with try/catch and emit error events on failure.
105
+ * Any method added to @plyaz/storage will be automatically available.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const storage = StorageService.getInstance().getStorage();
110
+ * await storage.uploadFile({ file, filename: 'doc.pdf' });
111
+ * await storage.deleteFile({ fileId: '123' });
112
+ * ```
113
+ *
114
+ * @returns StorageServiceImpl with automatic error handling
115
+ */
116
+ getStorage(): StorageServiceImpl;
117
+ /**
118
+ * Performs a health check on the storage service by checking all adapter health.
119
+ * This method has special handling to transform the response format.
120
+ */
121
+ healthCheck(): Promise<{
122
+ isHealthy: boolean;
123
+ responseTime?: number;
124
+ error?: string;
125
+ }>;
126
+ /**
127
+ * Gets the current configuration
128
+ */
129
+ getConfig(): CoreStorageConfig | null;
130
+ /**
131
+ * Closes the storage service and cleans up resources
132
+ */
133
+ close(): Promise<void>;
134
+ /**
135
+ * Creates a dedicated storage service instance (NOT the singleton)
136
+ *
137
+ * Use this when you need an isolated storage connection with its own configuration.
138
+ *
139
+ * @param config - Storage service configuration
140
+ * @returns Promise that resolves to a new dedicated StorageService instance
141
+ */
142
+ static createInstance(config: CoreStorageConfig): Promise<StorageService>;
143
+ }
144
+ //# sourceMappingURL=StorageService.d.ts.map