@plyaz/core 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -183
- package/dist/adapters/index.d.ts +16 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/nestjs.d.ts +79 -0
- package/dist/adapters/nestjs.d.ts.map +1 -0
- package/dist/adapters/nextjs.d.ts +28 -0
- package/dist/adapters/nextjs.d.ts.map +1 -0
- package/dist/backend/example/example.controller.d.ts +121 -0
- package/dist/backend/example/example.controller.d.ts.map +1 -0
- package/dist/backend/example/example.module.d.ts +29 -0
- package/dist/backend/example/example.module.d.ts.map +1 -0
- package/dist/backend/example/index.d.ts +8 -0
- package/dist/backend/example/index.d.ts.map +1 -0
- package/dist/backend/featureFlags/FeatureFlagDomainService.d.ts +150 -0
- package/dist/backend/featureFlags/FeatureFlagDomainService.d.ts.map +1 -0
- package/dist/backend/featureFlags/config/feature-flag.config.d.ts +28 -50
- package/dist/backend/featureFlags/config/feature-flag.config.d.ts.map +1 -1
- package/dist/backend/featureFlags/config/validation.d.ts +6 -6
- package/dist/backend/featureFlags/config/validation.d.ts.map +1 -1
- package/dist/backend/featureFlags/feature-flag.controller.d.ts +14 -55
- package/dist/backend/featureFlags/feature-flag.controller.d.ts.map +1 -1
- package/dist/backend/featureFlags/feature-flag.module.d.ts +36 -43
- package/dist/backend/featureFlags/feature-flag.module.d.ts.map +1 -1
- package/dist/backend/featureFlags/guards/feature-flag.guard.d.ts +16 -2
- package/dist/backend/featureFlags/guards/feature-flag.guard.d.ts.map +1 -1
- package/dist/backend/featureFlags/index.d.ts +6 -7
- package/dist/backend/featureFlags/index.d.ts.map +1 -1
- package/dist/backend/featureFlags/interceptors/error-handling-interceptor.d.ts.map +1 -1
- package/dist/backend/featureFlags/interceptors/feature-flag-logging-interceptor.d.ts.map +1 -1
- package/dist/backend/featureFlags/middleware/feature-flag-middleware.d.ts +6 -11
- package/dist/backend/featureFlags/middleware/feature-flag-middleware.d.ts.map +1 -1
- package/dist/backend/index.d.ts +5 -0
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/base/cache/CacheKeyBuilder.d.ts +115 -0
- package/dist/base/cache/CacheKeyBuilder.d.ts.map +1 -0
- package/dist/base/cache/index.d.ts +1 -0
- package/dist/base/cache/index.d.ts.map +1 -1
- package/dist/base/cache/strategies/redis.d.ts.map +1 -1
- package/dist/base/observability/BaseAdapter.d.ts +79 -0
- package/dist/base/observability/BaseAdapter.d.ts.map +1 -0
- package/dist/base/observability/CompositeAdapter.d.ts +72 -0
- package/dist/base/observability/CompositeAdapter.d.ts.map +1 -0
- package/dist/base/observability/DatadogAdapter.d.ts +117 -0
- package/dist/base/observability/DatadogAdapter.d.ts.map +1 -0
- package/dist/base/observability/LoggerAdapter.d.ts +54 -0
- package/dist/base/observability/LoggerAdapter.d.ts.map +1 -0
- package/dist/base/observability/ObservabilityService.d.ts +160 -0
- package/dist/base/observability/ObservabilityService.d.ts.map +1 -0
- package/dist/base/observability/index.d.ts +17 -0
- package/dist/base/observability/index.d.ts.map +1 -0
- package/dist/domain/base/BaseBackendDomainService.d.ts +528 -0
- package/dist/domain/base/BaseBackendDomainService.d.ts.map +1 -0
- package/dist/domain/base/BaseDomainService.d.ts +284 -0
- package/dist/domain/base/BaseDomainService.d.ts.map +1 -0
- package/dist/domain/base/BaseFrontendDomainService.d.ts +493 -0
- package/dist/domain/base/BaseFrontendDomainService.d.ts.map +1 -0
- package/dist/domain/base/BaseMapper.d.ts +100 -0
- package/dist/domain/base/BaseMapper.d.ts.map +1 -0
- package/dist/domain/base/BaseValidator.d.ts +105 -0
- package/dist/domain/base/BaseValidator.d.ts.map +1 -0
- package/dist/domain/base/index.d.ts +10 -0
- package/dist/domain/base/index.d.ts.map +1 -0
- package/dist/domain/example/BackendExampleDomainService.d.ts +257 -0
- package/dist/domain/example/BackendExampleDomainService.d.ts.map +1 -0
- package/dist/domain/example/FrontendExampleDomainService.d.ts +164 -0
- package/dist/domain/example/FrontendExampleDomainService.d.ts.map +1 -0
- package/dist/domain/example/index.d.ts +10 -0
- package/dist/domain/example/index.d.ts.map +1 -0
- package/dist/domain/example/mappers/ExampleMapper.d.ts +67 -0
- package/dist/domain/example/mappers/ExampleMapper.d.ts.map +1 -0
- package/dist/domain/example/validators/ExampleValidator.d.ts +33 -0
- package/dist/domain/example/validators/ExampleValidator.d.ts.map +1 -0
- package/dist/domain/featureFlags/FrontendFeatureFlagDomainService.d.ts +86 -0
- package/dist/domain/featureFlags/FrontendFeatureFlagDomainService.d.ts.map +1 -0
- package/dist/domain/featureFlags/index.d.ts +10 -5
- package/dist/domain/featureFlags/index.d.ts.map +1 -1
- package/dist/domain/featureFlags/mappers/FeatureFlagMapper.d.ts +72 -0
- package/dist/domain/featureFlags/mappers/FeatureFlagMapper.d.ts.map +1 -0
- package/dist/domain/featureFlags/mappers/index.d.ts +8 -0
- package/dist/domain/featureFlags/mappers/index.d.ts.map +1 -0
- package/dist/domain/featureFlags/module.d.ts +20 -0
- package/dist/domain/featureFlags/module.d.ts.map +1 -0
- package/dist/domain/featureFlags/provider.d.ts +40 -1
- package/dist/domain/featureFlags/provider.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/api.d.ts +59 -34
- package/dist/domain/featureFlags/providers/api.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/database.d.ts +54 -47
- package/dist/domain/featureFlags/providers/database.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/factory.d.ts +50 -33
- package/dist/domain/featureFlags/providers/factory.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/file.d.ts +48 -1
- package/dist/domain/featureFlags/providers/file.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/memory.d.ts +32 -6
- package/dist/domain/featureFlags/providers/memory.d.ts.map +1 -1
- package/dist/domain/featureFlags/providers/redis.d.ts +6 -1
- package/dist/domain/featureFlags/providers/redis.d.ts.map +1 -1
- package/dist/domain/featureFlags/service.d.ts +112 -0
- package/dist/domain/featureFlags/service.d.ts.map +1 -0
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/engine/featureFlags/engine.d.ts +8 -0
- package/dist/engine/featureFlags/engine.d.ts.map +1 -1
- package/dist/entry-backend.d.ts +26 -0
- package/dist/entry-backend.d.ts.map +1 -0
- package/dist/entry-backend.js +15455 -0
- package/dist/entry-backend.js.map +1 -0
- package/dist/entry-backend.mjs +15339 -0
- package/dist/entry-backend.mjs.map +1 -0
- package/dist/entry-frontend.d.ts +23 -0
- package/dist/entry-frontend.d.ts.map +1 -0
- package/dist/entry-frontend.js +11340 -0
- package/dist/entry-frontend.js.map +1 -0
- package/dist/entry-frontend.mjs +11278 -0
- package/dist/entry-frontend.mjs.map +1 -0
- package/dist/events/CoreEventManager.d.ts +116 -0
- package/dist/events/CoreEventManager.d.ts.map +1 -0
- package/dist/events/index.d.ts +27 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/frontend/base/index.d.ts +8 -0
- package/dist/frontend/base/index.d.ts.map +1 -0
- package/dist/frontend/components/InitializationError.d.ts +25 -0
- package/dist/frontend/components/InitializationError.d.ts.map +1 -0
- package/dist/frontend/components/InitializationLoading.d.ts +22 -0
- package/dist/frontend/components/InitializationLoading.d.ts.map +1 -0
- package/dist/frontend/components/index.d.ts +9 -0
- package/dist/frontend/components/index.d.ts.map +1 -0
- package/dist/frontend/example/index.d.ts +9 -0
- package/dist/frontend/example/index.d.ts.map +1 -0
- package/dist/frontend/featureFlags/index.d.ts +28 -7
- package/dist/frontend/featureFlags/index.d.ts.map +1 -1
- package/dist/frontend/index.d.ts +4 -0
- package/dist/frontend/index.d.ts.map +1 -1
- package/dist/frontend/providers/ApiProvider.d.ts +2 -2
- package/dist/frontend/providers/ApiProvider.d.ts.map +1 -1
- package/dist/frontend/providers/PlyazProvider.d.ts +305 -0
- package/dist/frontend/providers/PlyazProvider.d.ts.map +1 -0
- package/dist/frontend/providers/index.d.ts +1 -0
- package/dist/frontend/providers/index.d.ts.map +1 -1
- package/dist/frontend/store/feature-flags.d.ts +63 -0
- package/dist/frontend/store/feature-flags.d.ts.map +1 -0
- package/dist/frontend/store/index.d.ts +14 -0
- package/dist/frontend/store/index.d.ts.map +1 -0
- package/dist/frontend/store/integrations.d.ts +36 -0
- package/dist/frontend/store/integrations.d.ts.map +1 -0
- package/dist/frontend/store/service-accessors.d.ts +78 -0
- package/dist/frontend/store/service-accessors.d.ts.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15262 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13667 -4861
- package/dist/index.mjs.map +1 -1
- package/dist/init/CoreInitializer.d.ts +583 -0
- package/dist/init/CoreInitializer.d.ts.map +1 -0
- package/dist/init/ServiceRegistry.d.ts +256 -0
- package/dist/init/ServiceRegistry.d.ts.map +1 -0
- package/dist/init/index.d.ts +14 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/nestjs/CoreModule.d.ts +63 -0
- package/dist/init/nestjs/CoreModule.d.ts.map +1 -0
- package/dist/init/nestjs/index.d.ts +5 -0
- package/dist/init/nestjs/index.d.ts.map +1 -0
- package/dist/init/nestjs/index.js +9234 -0
- package/dist/init/nestjs/index.js.map +1 -0
- package/dist/init/nestjs/index.mjs +9230 -0
- package/dist/init/nestjs/index.mjs.map +1 -0
- package/dist/init/react.d.ts +33 -0
- package/dist/init/react.d.ts.map +1 -0
- package/dist/models/example/ExampleRepository.d.ts +166 -0
- package/dist/models/example/ExampleRepository.d.ts.map +1 -0
- package/dist/models/example/index.d.ts +7 -0
- package/dist/models/example/index.d.ts.map +1 -0
- package/dist/models/featureFlags/FeatureFlagRepository.d.ts +161 -0
- package/dist/models/featureFlags/FeatureFlagRepository.d.ts.map +1 -0
- package/dist/models/featureFlags/index.d.ts +7 -0
- package/dist/models/featureFlags/index.d.ts.map +1 -0
- package/dist/models/index.d.ts +9 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/services/ApiClientService.d.ts +92 -4
- package/dist/services/ApiClientService.d.ts.map +1 -1
- package/dist/services/CacheService.d.ts +176 -0
- package/dist/services/CacheService.d.ts.map +1 -0
- package/dist/services/DbService.d.ts +393 -0
- package/dist/services/DbService.d.ts.map +1 -0
- package/dist/services/NotificationService.d.ts +153 -0
- package/dist/services/NotificationService.d.ts.map +1 -0
- package/dist/services/StorageService.d.ts +146 -0
- package/dist/services/StorageService.d.ts.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/utils/common/id.d.ts +83 -0
- package/dist/utils/common/id.d.ts.map +1 -0
- package/dist/utils/common/index.d.ts +2 -0
- package/dist/utils/common/index.d.ts.map +1 -1
- package/dist/utils/common/object.d.ts +70 -0
- package/dist/utils/common/object.d.ts.map +1 -0
- package/dist/utils/featureFlags/conditions.d.ts.map +1 -1
- package/dist/utils/featureFlags/context.d.ts +0 -1
- package/dist/utils/featureFlags/context.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/mapperUtils.d.ts +38 -0
- package/dist/utils/mapperUtils.d.ts.map +1 -0
- package/dist/utils/runtime.d.ts +15 -0
- package/dist/utils/runtime.d.ts.map +1 -0
- package/dist/version.d.ts +24 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/web_app/auth/add_user.d.ts +2 -2
- package/dist/web_app/auth/add_user.d.ts.map +1 -1
- package/dist/web_app/auth/update_user.d.ts +1 -1
- package/dist/web_app/auth/update_user.d.ts.map +1 -1
- package/package.json +89 -15
- package/dist/backend/featureFlags/database/connection.d.ts +0 -321
- package/dist/backend/featureFlags/database/connection.d.ts.map +0 -1
- package/dist/backend/featureFlags/database/repository.d.ts +0 -518
- package/dist/backend/featureFlags/database/repository.d.ts.map +0 -1
- package/dist/backend/featureFlags/feature-flag.repository.d.ts +0 -85
- package/dist/backend/featureFlags/feature-flag.repository.d.ts.map +0 -1
- package/dist/backend/featureFlags/feature-flag.service.d.ts +0 -264
- package/dist/backend/featureFlags/feature-flag.service.d.ts.map +0 -1
- package/dist/frontend/featureFlags/hooks/useFeatureFlag.d.ts +0 -103
- package/dist/frontend/featureFlags/hooks/useFeatureFlag.d.ts.map +0 -1
- package/dist/frontend/featureFlags/hooks/useFeatureFlagActions.d.ts +0 -35
- package/dist/frontend/featureFlags/hooks/useFeatureFlagActions.d.ts.map +0 -1
- package/dist/frontend/featureFlags/hooks/useFeatureFlagHelpers.d.ts +0 -55
- package/dist/frontend/featureFlags/hooks/useFeatureFlagHelpers.d.ts.map +0 -1
- package/dist/frontend/featureFlags/hooks/useFeatureFlagProvider.d.ts +0 -57
- package/dist/frontend/featureFlags/hooks/useFeatureFlagProvider.d.ts.map +0 -1
- package/dist/frontend/featureFlags/providers/FeatureFlagProvider.d.ts +0 -99
- package/dist/frontend/featureFlags/providers/FeatureFlagProvider.d.ts.map +0 -1
- package/dist/frontend/featureFlags/providers/FeatureFlagProviderHelpers.d.ts +0 -31
- package/dist/frontend/featureFlags/providers/FeatureFlagProviderHelpers.d.ts.map +0 -1
- package/dist/frontend/featureFlags/providers/types.d.ts +0 -21
- package/dist/frontend/featureFlags/providers/types.d.ts.map +0 -1
- package/dist/index.cjs +0 -6435
- package/dist/index.cjs.map +0 -1
- package/dist/utils/db/databaseService.d.ts +0 -6
- package/dist/utils/db/databaseService.d.ts.map +0 -1
- package/dist/utils/db/index.d.ts +0 -2
- package/dist/utils/db/index.d.ts.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
/** Type alias for NotificationService instance (use for type-only imports to avoid bundling) */
|
|
152
|
+
export type NotificationServiceInstance = NotificationService;
|
|
153
|
+
//# 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;AAED,gGAAgG;AAChG,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
/** Type alias for StorageService instance (use for type-only imports to avoid bundling) */
|
|
145
|
+
export type StorageServiceInstance = StorageService;
|
|
146
|
+
//# sourceMappingURL=StorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../src/services/StorageService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAGH,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAO3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAY3D;;;;;;;;;GASG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA+B;IACtD,OAAO,CAAC,cAAc,CAAmC;IACzD,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO;IAMP;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAexB;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,cAAc;IAKpC;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;IAI/B;;OAEG;WACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IASnC;;;;;OAKG;WACU,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;IAgB3E;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAcrB;;;;;;;;;;;;;OAaG;IACH,UAAU,IAAI,kBAAkB;IA6ChC;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAkC3F;;OAEG;IACH,SAAS,IAAI,iBAAiB,GAAG,IAAI;IAIrC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B;;;;;;;OAOG;WACU,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;CAShF;AAED,2FAA2F;AAC3F,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ID Generation Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent ID generation across the application.
|
|
5
|
+
* Uses globalThis.crypto when available, with a fallback for environments without it.
|
|
6
|
+
*
|
|
7
|
+
* @fileoverview ID generation utility functions
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generate a UUID v4 string.
|
|
11
|
+
* Uses crypto.randomUUID when available, otherwise falls back to a timestamp-based ID.
|
|
12
|
+
*
|
|
13
|
+
* @returns A UUID v4 string or fallback ID
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const id = generateId();
|
|
18
|
+
* // => 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' (crypto available)
|
|
19
|
+
* // => '1701475200000-x7k9m2' (fallback)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateId(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a short random ID (8 characters).
|
|
25
|
+
* Useful for correlation IDs, short references, etc.
|
|
26
|
+
*
|
|
27
|
+
* @returns A short random string
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const shortId = generateShortId();
|
|
32
|
+
* // => 'x7k9m2ab'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateShortId(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Generate a correlation ID for tracing.
|
|
38
|
+
* Format: timestamp-randomString
|
|
39
|
+
*
|
|
40
|
+
* @returns A correlation ID string
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const correlationId = generateCorrelationId();
|
|
45
|
+
* // => '1701475200000-x7k9m2'
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateCorrelationId(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Generate a trace ID for distributed tracing (32 hex characters / 128 bits).
|
|
51
|
+
*
|
|
52
|
+
* @returns A 32-character hex string
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const traceId = generateTraceId();
|
|
57
|
+
* // => 'a1b2c3d4e5f67890abcdef1234567890'
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function generateTraceId(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Generate a span ID for distributed tracing (16 hex characters / 64 bits).
|
|
63
|
+
*
|
|
64
|
+
* @returns A 16-character hex string
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const spanId = generateSpanId();
|
|
69
|
+
* // => 'a1b2c3d4e5f67890'
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function generateSpanId(): string;
|
|
73
|
+
/**
|
|
74
|
+
* ID generation utilities object for convenient access.
|
|
75
|
+
*/
|
|
76
|
+
export declare const IdUtils: {
|
|
77
|
+
readonly generate: typeof generateId;
|
|
78
|
+
readonly generateShort: typeof generateShortId;
|
|
79
|
+
readonly generateCorrelation: typeof generateCorrelationId;
|
|
80
|
+
readonly generateTraceId: typeof generateTraceId;
|
|
81
|
+
readonly generateSpanId: typeof generateSpanId;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../../src/utils/common/id.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAMnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAQxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAWxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAQvC;AAED;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;CAMV,CAAC"}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* @fileoverview Common utilities export
|
|
7
7
|
*/
|
|
8
8
|
export { hashString, isInRollout, createRolloutIdentifier, HashUtils } from './hash';
|
|
9
|
+
export { generateId, generateShortId, generateCorrelationId, generateTraceId, generateSpanId, IdUtils, } from './id';
|
|
9
10
|
export { isTruthy, toBoolean, ValueUtils } from './values';
|
|
11
|
+
export { setNestedProperty, getNestedProperty, hasNestedProperty, ObjectUtils } from './object';
|
|
10
12
|
export * from './validation';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGrF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGrF,OAAO,EACL,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEhG,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with nested object paths and property access.
|
|
5
|
+
*
|
|
6
|
+
* @fileoverview Object manipulation utilities
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Sets a value at a nested path in an object, creating intermediate objects as needed.
|
|
10
|
+
*
|
|
11
|
+
* @param obj - The target object to modify
|
|
12
|
+
* @param path - Dot-separated path to the property (e.g., 'user.profile.name')
|
|
13
|
+
* @param value - The value to set at the path
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const obj = { user: { id: 1 } };
|
|
18
|
+
* setNestedProperty(obj, 'user.profile.name', 'John');
|
|
19
|
+
* // Result: { user: { id: 1, profile: { name: 'John' } } }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function setNestedProperty(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
23
|
+
/**
|
|
24
|
+
* Gets a value at a nested path in an object.
|
|
25
|
+
*
|
|
26
|
+
* @param obj - The source object to read from
|
|
27
|
+
* @param path - Dot-separated path to the property (e.g., 'user.profile.name')
|
|
28
|
+
* @param defaultValue - Optional default value if the path doesn't exist
|
|
29
|
+
* @returns The value at the path, or defaultValue if not found
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const obj = { user: { profile: { name: 'John' } } };
|
|
34
|
+
* getNestedProperty(obj, 'user.profile.name'); // 'John'
|
|
35
|
+
* getNestedProperty(obj, 'user.settings.theme', 'dark'); // 'dark' (default)
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function getNestedProperty<T = unknown>(obj: Record<string, unknown>, path: string, defaultValue?: T): T | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if a nested path exists in an object.
|
|
41
|
+
*
|
|
42
|
+
* @param obj - The object to check
|
|
43
|
+
* @param path - Dot-separated path to check (e.g., 'user.profile.name')
|
|
44
|
+
* @returns True if the path exists and is not undefined
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const obj = { user: { profile: { name: 'John' } } };
|
|
49
|
+
* hasNestedProperty(obj, 'user.profile.name'); // true
|
|
50
|
+
* hasNestedProperty(obj, 'user.settings.theme'); // false
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function hasNestedProperty(obj: Record<string, unknown>, path: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Object utilities namespace for convenient grouped access.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { ObjectUtils } from '@plyaz/core/utils';
|
|
60
|
+
*
|
|
61
|
+
* ObjectUtils.setNestedProperty(obj, 'user.name', 'John');
|
|
62
|
+
* const name = ObjectUtils.getNestedProperty(obj, 'user.name');
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare const ObjectUtils: {
|
|
66
|
+
readonly setNestedProperty: typeof setNestedProperty;
|
|
67
|
+
readonly getNestedProperty: typeof getNestedProperty;
|
|
68
|
+
readonly hasNestedProperty: typeof hasNestedProperty;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../src/utils/common/object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,IAAI,CAgBN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC3C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,CAAC,GACf,CAAC,GAAG,SAAS,CAaf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAerF;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAIzD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,oBAAoB,EAC/B,YAAY,EAAE,OAAO,GACpB,OAAO,CAoBT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,GACtB,OAAO,CAGT;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,GACtB,OAAO,CAeT;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,OAAO,EACvB,YAAY,EAAE,OAAO,GACpB,OAAO,CAQT;AAqBD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,GACtB,OAAO,CAeT;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;iDAEW,oBAAoB,EAAE,gBACpB,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,KACvC,OAAO;IAUV;;;;;;OAMG;gDAEW,oBAAoB,EAAE,gBACpB,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,KACvC,OAAO;IAUV;;;;;OAKG;4CAEU,OAAO,CAAC,oBAAoB,CAAC,KACvC;QACD,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB;IAmCD;;;;;;;OAOG;sCAEM,MAAM,YACH,oBAAoB,CAAC,UAAU,CAAC,SACnC,oBAAoB,CAAC,OAAO,CAAC,KACnC,oBAAoB;CAaf,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Feature Flag Context Utilities
|
|
3
3
|
*
|
|
4
4
|
* Utilities for building, validating, and manipulating feature flag contexts.
|
|
5
|
-
* Re-exports the context builder and utilities from domain layer for convenience.
|
|
6
5
|
*
|
|
7
6
|
* @fileoverview Feature flag context utilities
|
|
8
7
|
* @version 1.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/context.ts"],"names":[],"mappings":"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"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapper Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Common utilities for data transformation in mappers.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Convert snake_case to camelCase
|
|
8
|
+
*/
|
|
9
|
+
export declare function snakeToCamel(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert camelCase to snake_case
|
|
12
|
+
*/
|
|
13
|
+
export declare function camelToSnake(str: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Parse ISO date string to Date object
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseDate(dateString: string | null | undefined): Date | null;
|
|
18
|
+
/**
|
|
19
|
+
* Format Date to ISO string for API
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatDate(date: Date | null | undefined): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Trim string if defined
|
|
24
|
+
*/
|
|
25
|
+
export declare function trimString(str: string | undefined): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Pick only defined values from object (for PATCH requests)
|
|
28
|
+
*/
|
|
29
|
+
export declare function pickDefined<T extends Record<string, unknown>>(obj: T): Partial<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Convert object keys from snake_case to camelCase
|
|
32
|
+
*/
|
|
33
|
+
export declare function keysToCamel<T extends Record<string, unknown>>(obj: T): Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Convert object keys from camelCase to snake_case
|
|
36
|
+
*/
|
|
37
|
+
export declare function keysToSnake<T extends Record<string, unknown>>(obj: T): Record<string, unknown>;
|
|
38
|
+
//# sourceMappingURL=mapperUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapperUtils.d.ts","sourceRoot":"","sources":["../../src/utils/mapperUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAI5E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQjF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM9F;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM9F"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Detection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities for detecting the current JavaScript runtime environment.
|
|
5
|
+
*/
|
|
6
|
+
import type { CoreRuntimeEnvironment } from '@plyaz/types/core';
|
|
7
|
+
/**
|
|
8
|
+
* Detect the current runtime environment
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectRuntime(): CoreRuntimeEnvironment;
|
|
11
|
+
/**
|
|
12
|
+
* Load environment variables from a .env file
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadEnvFile(envPath: string, verbose?: boolean): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AA6DhE;;GAEG;AACH,wBAAgB,aAAa,IAAI,sBAAsB,CAmBtD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAanF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package version - single source of truth
|
|
3
|
+
*
|
|
4
|
+
* Reads version from package.json to ensure consistency across:
|
|
5
|
+
* - Health check endpoints
|
|
6
|
+
* - API headers (X-Version)
|
|
7
|
+
* - Observability tags
|
|
8
|
+
* - Logging metadata
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Get the package version from package.json
|
|
12
|
+
* Caches the result for subsequent calls
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPackageVersion(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Package version constant
|
|
17
|
+
* Use this for static contexts where async/dynamic loading isn't needed
|
|
18
|
+
*/
|
|
19
|
+
export declare const VERSION: string;
|
|
20
|
+
/**
|
|
21
|
+
* Package name
|
|
22
|
+
*/
|
|
23
|
+
export declare const PACKAGE_NAME = "@plyaz/core";
|
|
24
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAuB1C;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAsB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,YAAY,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const userData:
|
|
1
|
+
import type { CoreDBUser } from '@plyaz/types/core';
|
|
2
|
+
export declare const userData: CoreDBUser;
|
|
3
3
|
//# sourceMappingURL=add_user.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add_user.d.ts","sourceRoot":"","sources":["../../../src/web_app/auth/add_user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"add_user.d.ts","sourceRoot":"","sources":["../../../src/web_app/auth/add_user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,QAAQ,EAAE,UAiBtB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const UpdateUser: <T extends
|
|
1
|
+
export declare const UpdateUser: <T extends Record<string, unknown>>(table: string, id: string, input: T) => Promise<unknown>;
|
|
2
2
|
//# sourceMappingURL=update_user.d.ts.map
|