@plyaz/types 1.23.1 → 1.24.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/dist/core/domain/types.d.ts +19 -1
- package/dist/core/events/enums.d.ts +40 -0
- package/dist/core/events/index.d.ts +2 -2
- package/dist/core/events/payloads.d.ts +127 -0
- package/dist/core/init/index.d.ts +1 -1
- package/dist/core/init/types.d.ts +153 -3
- package/dist/core/modules.d.ts +12 -2
- package/dist/index.cjs +37 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/notifications/webhooks.schemas.d.ts +4 -4
- package/package.json +1 -1
|
@@ -94,6 +94,12 @@ export interface CoreBaseDomainServiceConfig {
|
|
|
94
94
|
enabled?: boolean;
|
|
95
95
|
/** Default values for feature flags or other defaults */
|
|
96
96
|
defaults?: Record<string, FeatureFlagValue>;
|
|
97
|
+
/**
|
|
98
|
+
* Custom observability adapter to use instead of the injected global/dedicated one.
|
|
99
|
+
* Useful when a service needs a different provider or custom configuration.
|
|
100
|
+
* Takes precedence over injected observability.
|
|
101
|
+
*/
|
|
102
|
+
observabilityOverride?: unknown;
|
|
97
103
|
}
|
|
98
104
|
/**
|
|
99
105
|
* Type for mapper class constructor
|
|
@@ -126,7 +132,7 @@ export type CoreValidatorClass<T extends CoreBaseValidatorInstance = CoreBaseVal
|
|
|
126
132
|
* interface BasicInjectedServices extends CoreInjectedServices {}
|
|
127
133
|
* ```
|
|
128
134
|
*/
|
|
129
|
-
export interface CoreInjectedServices<TCache = unknown, TDb = unknown, TApi = unknown, TStores = unknown, TObservability = unknown> {
|
|
135
|
+
export interface CoreInjectedServices<TCache = unknown, TDb = unknown, TApi = unknown, TStores = unknown, TObservability = unknown, TStorage = unknown, TNotifications = unknown> {
|
|
130
136
|
/** Cache manager instance */
|
|
131
137
|
cache?: TCache;
|
|
132
138
|
/** Database service instance */
|
|
@@ -144,6 +150,18 @@ export interface CoreInjectedServices<TCache = unknown, TDb = unknown, TApi = un
|
|
|
144
150
|
* Supports adapter-based providers (Datadog, Grafana, OpenTelemetry, etc.)
|
|
145
151
|
*/
|
|
146
152
|
observability?: TObservability;
|
|
153
|
+
/**
|
|
154
|
+
* Storage service instance for file uploads, downloads, and management.
|
|
155
|
+
* Supports multi-provider setup (Cloudflare R2, Supabase, etc.) with automatic failover.
|
|
156
|
+
* Backend-only - not available in browser/frontend runtimes.
|
|
157
|
+
*/
|
|
158
|
+
storage?: TStorage;
|
|
159
|
+
/**
|
|
160
|
+
* Notification service instance for email, SMS, and push notifications.
|
|
161
|
+
* Supports multi-provider setup (SendGrid, Infobip, etc.) with automatic failover.
|
|
162
|
+
* Backend-only - not available in browser/frontend runtimes.
|
|
163
|
+
*/
|
|
164
|
+
notifications?: TNotifications;
|
|
147
165
|
}
|
|
148
166
|
/**
|
|
149
167
|
* Base service configuration passed to constructor
|
|
@@ -29,6 +29,8 @@ export declare const CoreEventScope: {
|
|
|
29
29
|
readonly DATABASE: "database";
|
|
30
30
|
readonly FEATURE_FLAG: "featureFlag";
|
|
31
31
|
readonly STORE: "store";
|
|
32
|
+
readonly STORAGE: "storage";
|
|
33
|
+
readonly NOTIFICATION: "notification";
|
|
32
34
|
};
|
|
33
35
|
export type CoreEventScopeType = (typeof CoreEventScope)[keyof typeof CoreEventScope];
|
|
34
36
|
/**
|
|
@@ -133,6 +135,28 @@ export declare const StoreEventAction: {
|
|
|
133
135
|
readonly RESET: "reset";
|
|
134
136
|
readonly HYDRATED: "hydrated";
|
|
135
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Storage event actions (file uploads, downloads, deletions)
|
|
140
|
+
*/
|
|
141
|
+
export declare const StorageEventAction: {
|
|
142
|
+
readonly UPLOADED: "uploaded";
|
|
143
|
+
readonly DOWNLOADED: "downloaded";
|
|
144
|
+
readonly DELETED: "deleted";
|
|
145
|
+
readonly ERROR: "error";
|
|
146
|
+
readonly HEALTH_CHECK: "healthCheck";
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Notification event actions (email, sms, push)
|
|
150
|
+
*/
|
|
151
|
+
export declare const NotificationEventAction: {
|
|
152
|
+
readonly SENT: "sent";
|
|
153
|
+
readonly FAILED: "failed";
|
|
154
|
+
readonly DELIVERED: "delivered";
|
|
155
|
+
readonly OPENED: "opened";
|
|
156
|
+
readonly CLICKED: "clicked";
|
|
157
|
+
readonly ERROR: "error";
|
|
158
|
+
readonly HEALTH_CHECK: "healthCheck";
|
|
159
|
+
};
|
|
136
160
|
/**
|
|
137
161
|
* All core event type constants
|
|
138
162
|
*
|
|
@@ -215,6 +239,22 @@ export declare const CORE_EVENTS: {
|
|
|
215
239
|
readonly RESET: "store:reset";
|
|
216
240
|
readonly HYDRATED: "store:hydrated";
|
|
217
241
|
};
|
|
242
|
+
readonly STORAGE: {
|
|
243
|
+
readonly UPLOADED: "storage:uploaded";
|
|
244
|
+
readonly DOWNLOADED: "storage:downloaded";
|
|
245
|
+
readonly DELETED: "storage:deleted";
|
|
246
|
+
readonly ERROR: "storage:error";
|
|
247
|
+
readonly HEALTH_CHECK: "storage:healthCheck";
|
|
248
|
+
};
|
|
249
|
+
readonly NOTIFICATION: {
|
|
250
|
+
readonly SENT: "notification:sent";
|
|
251
|
+
readonly FAILED: "notification:failed";
|
|
252
|
+
readonly DELIVERED: "notification:delivered";
|
|
253
|
+
readonly OPENED: "notification:opened";
|
|
254
|
+
readonly CLICKED: "notification:clicked";
|
|
255
|
+
readonly ERROR: "notification:error";
|
|
256
|
+
readonly HEALTH_CHECK: "notification:healthCheck";
|
|
257
|
+
};
|
|
218
258
|
};
|
|
219
259
|
/** All system event types */
|
|
220
260
|
export type SystemEventType = (typeof CORE_EVENTS.SYSTEM)[keyof typeof CORE_EVENTS.SYSTEM];
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
* );
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export { CoreEventScope, SystemEventAction, EntityEventAction, ValidationEventAction, SanitizationEventAction, ApiEventAction, CacheEventAction, AuthEventAction, DatabaseEventAction, FeatureFlagEventAction, StoreEventAction, CORE_EVENTS, } from './enums';
|
|
20
|
+
export { CoreEventScope, SystemEventAction, EntityEventAction, ValidationEventAction, SanitizationEventAction, ApiEventAction, CacheEventAction, AuthEventAction, DatabaseEventAction, FeatureFlagEventAction, StoreEventAction, StorageEventAction, NotificationEventAction, CORE_EVENTS, } from './enums';
|
|
21
21
|
export type { CoreEventScopeType, SystemEventType, EntityEventType, ValidationEventType, SanitizationEventType, ApiEventType, CacheEventType, AuthEventType, DatabaseEventType, FeatureFlagEventType, StoreEventType, CoreEventType, } from './enums';
|
|
22
|
-
export type { CoreEvent, CoreCrudOperation, CoreValidationStartedPayload, CoreValidationSuccessPayload, CoreValidationFailedPayload, CoreSanitizationStartedPayload, CoreSanitizationSuccessPayload, CoreSanitizationFailedPayload, CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityPatchedPayload, CoreEntityDeletedPayload, CoreEntityCreatingPayload, CoreEntityUpdatingPayload, CoreEntityPatchingPayload, CoreEntityDeletingPayload, CoreEntityErrorPayload, CoreEntityCompletePayload, CoreBulkCreatedPayload, CoreBulkDeletedPayload, CoreSystemInitializedPayload, CoreSystemReadyPayload, CoreSystemShutdownPayload, CoreSystemErrorPayload, CoreSystemWarningPayload, CoreApiRequestStartPayload, CoreApiRequestSuccessPayload, CoreApiRequestErrorPayload, CoreApiRetryPayload, CoreApiTimeoutPayload, CoreCacheHitPayload, CoreCacheMissPayload, CoreCacheSetPayload, CoreCacheDeletePayload, CoreCacheClearPayload, CoreCacheExpiredPayload, CoreDatabaseConnectedPayload, CoreDatabaseDisconnectedPayload, CoreDatabaseQueryPayload, CoreDatabaseErrorPayload, CoreDatabaseTransactionStartPayload, CoreDatabaseTransactionCommitPayload, CoreDatabaseTransactionRollbackPayload, CoreAuthLoginPayload, CoreAuthLogoutPayload, CoreAuthTokenRefreshPayload, CoreAuthSessionExpiredPayload, CoreAuthUnauthorizedPayload, CoreFeatureFlagChangedPayload, CoreFeatureFlagEvaluatedPayload, CoreFeatureFlagRefreshedPayload, CoreStoreUpdatedPayload, CoreStoreResetPayload, CoreStoreHydratedPayload, CoreEventPayloadMap, } from './payloads';
|
|
22
|
+
export type { CoreEvent, CoreCrudOperation, CoreValidationStartedPayload, CoreValidationSuccessPayload, CoreValidationFailedPayload, CoreSanitizationStartedPayload, CoreSanitizationSuccessPayload, CoreSanitizationFailedPayload, CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityPatchedPayload, CoreEntityDeletedPayload, CoreEntityCreatingPayload, CoreEntityUpdatingPayload, CoreEntityPatchingPayload, CoreEntityDeletingPayload, CoreEntityErrorPayload, CoreEntityCompletePayload, CoreBulkCreatedPayload, CoreBulkDeletedPayload, CoreSystemInitializedPayload, CoreSystemReadyPayload, CoreSystemShutdownPayload, CoreSystemErrorPayload, CoreSystemWarningPayload, CoreApiRequestStartPayload, CoreApiRequestSuccessPayload, CoreApiRequestErrorPayload, CoreApiRetryPayload, CoreApiTimeoutPayload, CoreCacheHitPayload, CoreCacheMissPayload, CoreCacheSetPayload, CoreCacheDeletePayload, CoreCacheClearPayload, CoreCacheExpiredPayload, CoreDatabaseConnectedPayload, CoreDatabaseDisconnectedPayload, CoreDatabaseQueryPayload, CoreDatabaseErrorPayload, CoreDatabaseTransactionStartPayload, CoreDatabaseTransactionCommitPayload, CoreDatabaseTransactionRollbackPayload, CoreAuthLoginPayload, CoreAuthLogoutPayload, CoreAuthTokenRefreshPayload, CoreAuthSessionExpiredPayload, CoreAuthUnauthorizedPayload, CoreFeatureFlagChangedPayload, CoreFeatureFlagEvaluatedPayload, CoreFeatureFlagRefreshedPayload, CoreStoreUpdatedPayload, CoreStoreResetPayload, CoreStoreHydratedPayload, CoreStorageUploadedPayload, CoreStorageDownloadedPayload, CoreStorageDeletedPayload, CoreStorageErrorPayload, CoreStorageHealthCheckPayload, CoreNotificationSentPayload, CoreNotificationFailedPayload, CoreNotificationDeliveredPayload, CoreNotificationOpenedPayload, CoreNotificationClickedPayload, CoreNotificationErrorPayload, CoreNotificationHealthCheckPayload, CoreEventPayloadMap, } from './payloads';
|
|
@@ -446,6 +446,121 @@ export interface CoreStoreHydratedPayload {
|
|
|
446
446
|
storeName: string;
|
|
447
447
|
source: string;
|
|
448
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Payload for storage:uploaded events
|
|
451
|
+
*/
|
|
452
|
+
export interface CoreStorageUploadedPayload {
|
|
453
|
+
fileId: string;
|
|
454
|
+
filename: string;
|
|
455
|
+
size: number;
|
|
456
|
+
mimeType?: string;
|
|
457
|
+
bucket?: string;
|
|
458
|
+
adapter?: string;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Payload for storage:downloaded events
|
|
462
|
+
*/
|
|
463
|
+
export interface CoreStorageDownloadedPayload {
|
|
464
|
+
fileId: string;
|
|
465
|
+
filename?: string;
|
|
466
|
+
size?: number;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Payload for storage:deleted events
|
|
470
|
+
*/
|
|
471
|
+
export interface CoreStorageDeletedPayload {
|
|
472
|
+
fileId: string;
|
|
473
|
+
permanent?: boolean;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Payload for storage:error events
|
|
477
|
+
*/
|
|
478
|
+
export interface CoreStorageErrorPayload {
|
|
479
|
+
error: unknown;
|
|
480
|
+
operation: string;
|
|
481
|
+
fileId?: string;
|
|
482
|
+
filename?: string;
|
|
483
|
+
recoverable: boolean;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Payload for storage:healthCheck events
|
|
487
|
+
*/
|
|
488
|
+
export interface CoreStorageHealthCheckPayload {
|
|
489
|
+
healthy: boolean;
|
|
490
|
+
adapters?: {
|
|
491
|
+
name: string;
|
|
492
|
+
healthy: boolean;
|
|
493
|
+
}[];
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Payload for notification:sent events
|
|
497
|
+
*/
|
|
498
|
+
export interface CoreNotificationSentPayload {
|
|
499
|
+
notificationId: string;
|
|
500
|
+
recipientId: string;
|
|
501
|
+
channel: 'email' | 'sms' | 'push';
|
|
502
|
+
templateId?: string;
|
|
503
|
+
provider?: string;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Payload for notification:failed events
|
|
507
|
+
*/
|
|
508
|
+
export interface CoreNotificationFailedPayload {
|
|
509
|
+
notificationId?: string;
|
|
510
|
+
recipientId: string;
|
|
511
|
+
channel: 'email' | 'sms' | 'push';
|
|
512
|
+
error: unknown;
|
|
513
|
+
retryable?: boolean;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Payload for notification:delivered events
|
|
517
|
+
*/
|
|
518
|
+
export interface CoreNotificationDeliveredPayload {
|
|
519
|
+
notificationId: string;
|
|
520
|
+
recipientId: string;
|
|
521
|
+
channel: 'email' | 'sms' | 'push';
|
|
522
|
+
deliveredAt: Date;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Payload for notification:opened events
|
|
526
|
+
*/
|
|
527
|
+
export interface CoreNotificationOpenedPayload {
|
|
528
|
+
notificationId: string;
|
|
529
|
+
recipientId: string;
|
|
530
|
+
channel: 'email' | 'sms' | 'push';
|
|
531
|
+
openedAt: Date;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Payload for notification:clicked events
|
|
535
|
+
*/
|
|
536
|
+
export interface CoreNotificationClickedPayload {
|
|
537
|
+
notificationId: string;
|
|
538
|
+
recipientId: string;
|
|
539
|
+
channel: 'email' | 'sms' | 'push';
|
|
540
|
+
link?: string;
|
|
541
|
+
clickedAt: Date;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Payload for notification:error events
|
|
545
|
+
*/
|
|
546
|
+
export interface CoreNotificationErrorPayload {
|
|
547
|
+
error: unknown;
|
|
548
|
+
operation: string;
|
|
549
|
+
recipientId?: string;
|
|
550
|
+
channel?: string;
|
|
551
|
+
recoverable: boolean;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Payload for notification:healthCheck events
|
|
555
|
+
*/
|
|
556
|
+
export interface CoreNotificationHealthCheckPayload {
|
|
557
|
+
healthy: boolean;
|
|
558
|
+
providers?: {
|
|
559
|
+
name: string;
|
|
560
|
+
channel: string;
|
|
561
|
+
healthy: boolean;
|
|
562
|
+
}[];
|
|
563
|
+
}
|
|
449
564
|
/**
|
|
450
565
|
* Maps event types to their payload types for type-safe event handling.
|
|
451
566
|
*
|
|
@@ -516,4 +631,16 @@ export interface CoreEventPayloadMap {
|
|
|
516
631
|
[CORE_EVENTS.STORE.UPDATED]: CoreStoreUpdatedPayload;
|
|
517
632
|
[CORE_EVENTS.STORE.RESET]: CoreStoreResetPayload;
|
|
518
633
|
[CORE_EVENTS.STORE.HYDRATED]: CoreStoreHydratedPayload;
|
|
634
|
+
[CORE_EVENTS.STORAGE.UPLOADED]: CoreStorageUploadedPayload;
|
|
635
|
+
[CORE_EVENTS.STORAGE.DOWNLOADED]: CoreStorageDownloadedPayload;
|
|
636
|
+
[CORE_EVENTS.STORAGE.DELETED]: CoreStorageDeletedPayload;
|
|
637
|
+
[CORE_EVENTS.STORAGE.ERROR]: CoreStorageErrorPayload;
|
|
638
|
+
[CORE_EVENTS.STORAGE.HEALTH_CHECK]: CoreStorageHealthCheckPayload;
|
|
639
|
+
[CORE_EVENTS.NOTIFICATION.SENT]: CoreNotificationSentPayload;
|
|
640
|
+
[CORE_EVENTS.NOTIFICATION.FAILED]: CoreNotificationFailedPayload;
|
|
641
|
+
[CORE_EVENTS.NOTIFICATION.DELIVERED]: CoreNotificationDeliveredPayload;
|
|
642
|
+
[CORE_EVENTS.NOTIFICATION.OPENED]: CoreNotificationOpenedPayload;
|
|
643
|
+
[CORE_EVENTS.NOTIFICATION.CLICKED]: CoreNotificationClickedPayload;
|
|
644
|
+
[CORE_EVENTS.NOTIFICATION.ERROR]: CoreNotificationErrorPayload;
|
|
645
|
+
[CORE_EVENTS.NOTIFICATION.HEALTH_CHECK]: CoreNotificationHealthCheckPayload;
|
|
519
646
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Core Init Types
|
|
3
3
|
* Service registry and initialization type definitions
|
|
4
4
|
*/
|
|
5
|
-
export type { CoreDomainServiceInstance, CoreServiceInitConfig, CoreServiceCreateOptions, CoreInitializableDomainService, CoreServiceEntry, CoreServiceRegistryConfig, CoreExtractServiceConfig, CoreExtractServiceInstance, CoreFeatureFlagInitConfig, CoreErrorHandlerInitConfig, CoreCacheConfig, CoreObservabilityConfig, CoreInitOptionsBase, CoreServicesResultBase, } from './types';
|
|
5
|
+
export type { CoreDomainServiceInstance, CoreServiceInitConfig, CoreServiceCreateOptions, CoreInitializableDomainService, CoreServiceEntry, CoreServiceRegistryConfig, CoreExtractServiceConfig, CoreExtractServiceInstance, CoreFeatureFlagInitConfig, CoreErrorHandlerInitConfig, CoreCacheConfig, CoreObservabilityConfig, CoreStorageConfig, CoreNotificationConfig, CoreInitOptionsBase, CoreServicesResultBase, } from './types';
|
|
@@ -12,6 +12,21 @@ import type { RootStoreSlice } from '../../store';
|
|
|
12
12
|
import type { CoreAppEnvironment, CoreAppContext, CoreRuntimeEnvironment, CoreServiceRuntime } from '../modules';
|
|
13
13
|
import type { CoreDbServiceConfig } from '../services';
|
|
14
14
|
import type { CoreInjectedServices } from '../domain';
|
|
15
|
+
import type { MonitoringObservabilityAdapter, MonitoringAdapterWithPriority } from '../../observability';
|
|
16
|
+
import type { StorageServiceConfig } from '../../storage';
|
|
17
|
+
import type { NotificationServiceConfig } from '../../notifications';
|
|
18
|
+
/**
|
|
19
|
+
* Storage service configuration for Core initialization.
|
|
20
|
+
* Uses the StorageServiceConfig from @plyaz/storage.
|
|
21
|
+
* Backend-only - not available in browser/frontend runtimes.
|
|
22
|
+
*/
|
|
23
|
+
export type CoreStorageConfig = StorageServiceConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Notification service configuration for Core initialization.
|
|
26
|
+
* Uses the NotificationServiceConfig from @plyaz/notifications.
|
|
27
|
+
* Backend-only - not available in browser/frontend runtimes.
|
|
28
|
+
*/
|
|
29
|
+
export type CoreNotificationConfig = NotificationServiceConfig;
|
|
15
30
|
/**
|
|
16
31
|
* Base interface that all domain service instances must implement.
|
|
17
32
|
* This allows the registry to manage services generically.
|
|
@@ -245,6 +260,75 @@ export interface CoreServiceInitConfig {
|
|
|
245
260
|
* ```
|
|
246
261
|
*/
|
|
247
262
|
dedicatedObservability?: boolean | CoreObservabilityConfig;
|
|
263
|
+
/**
|
|
264
|
+
* Create a dedicated storage instance for this service.
|
|
265
|
+
*
|
|
266
|
+
* By default, services share the global storage service. Use this when
|
|
267
|
+
* a service needs its own isolated storage (e.g., different adapters,
|
|
268
|
+
* separate buckets, compliance requirements).
|
|
269
|
+
*
|
|
270
|
+
* - `false` or `undefined`: Use global shared storage (default)
|
|
271
|
+
* - `true`: Create dedicated instance using global config
|
|
272
|
+
* - `CoreStorageConfig`: Create dedicated instance with custom config
|
|
273
|
+
*
|
|
274
|
+
* Note: This is only available in backend/Node.js contexts.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* // Use global shared storage (default)
|
|
279
|
+
* { service: UserService, config: { enabled: true } }
|
|
280
|
+
*
|
|
281
|
+
* // Create dedicated storage with global config
|
|
282
|
+
* { service: DocumentService, config: { dedicatedStorage: true } }
|
|
283
|
+
*
|
|
284
|
+
* // Create dedicated storage with custom config (compliance documents)
|
|
285
|
+
* {
|
|
286
|
+
* service: TaxDocumentService,
|
|
287
|
+
* config: {
|
|
288
|
+
* dedicatedStorage: {
|
|
289
|
+
* adapters: [cloudflareR2Adapter],
|
|
290
|
+
* compliance: { retentionYears: 7, immutable: true },
|
|
291
|
+
* },
|
|
292
|
+
* },
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
dedicatedStorage?: boolean | CoreStorageConfig;
|
|
297
|
+
/**
|
|
298
|
+
* Create a dedicated notifications instance for this service.
|
|
299
|
+
*
|
|
300
|
+
* By default, services share the global notification service. Use this when
|
|
301
|
+
* a service needs its own isolated notifications (e.g., different providers,
|
|
302
|
+
* separate templates, custom preferences).
|
|
303
|
+
*
|
|
304
|
+
* - `false` or `undefined`: Use global shared notifications (default)
|
|
305
|
+
* - `true`: Create dedicated instance using global config
|
|
306
|
+
* - `CoreNotificationConfig`: Create dedicated instance with custom config
|
|
307
|
+
*
|
|
308
|
+
* Note: This is only available in backend/Node.js contexts.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* // Use global shared notifications (default)
|
|
313
|
+
* { service: UserService, config: { enabled: true } }
|
|
314
|
+
*
|
|
315
|
+
* // Create dedicated notifications with global config
|
|
316
|
+
* { service: MarketingService, config: { dedicatedNotifications: true } }
|
|
317
|
+
*
|
|
318
|
+
* // Create dedicated notifications with custom config
|
|
319
|
+
* {
|
|
320
|
+
* service: TransactionalService,
|
|
321
|
+
* config: {
|
|
322
|
+
* dedicatedNotifications: {
|
|
323
|
+
* providers: {
|
|
324
|
+
* email: [sendGridAdapter], // SendGrid only for transactional
|
|
325
|
+
* },
|
|
326
|
+
* },
|
|
327
|
+
* },
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
dedicatedNotifications?: boolean | CoreNotificationConfig;
|
|
248
332
|
}
|
|
249
333
|
/**
|
|
250
334
|
* Options passed to the service factory method
|
|
@@ -357,12 +441,56 @@ export interface CoreServiceCreateOptions<TConfig = unknown, TMapper = unknown,
|
|
|
357
441
|
*/
|
|
358
442
|
instance?: unknown;
|
|
359
443
|
};
|
|
444
|
+
/**
|
|
445
|
+
* Storage configuration and mode.
|
|
446
|
+
* Backend-only - not available in browser/frontend runtimes.
|
|
447
|
+
*/
|
|
448
|
+
storage?: {
|
|
449
|
+
/**
|
|
450
|
+
* Whether to use a dedicated (isolated) storage instance.
|
|
451
|
+
* - `false`: Use global shared instance (default)
|
|
452
|
+
* - `true`: Create dedicated instance
|
|
453
|
+
*/
|
|
454
|
+
dedicated: boolean;
|
|
455
|
+
/**
|
|
456
|
+
* Storage config (merged global + per-service config).
|
|
457
|
+
* Used to create dedicated instance or configure global.
|
|
458
|
+
*/
|
|
459
|
+
config?: CoreStorageConfig;
|
|
460
|
+
/**
|
|
461
|
+
* Actual StorageService instance to use.
|
|
462
|
+
* Injected by ServiceRegistry, not created by service.
|
|
463
|
+
*/
|
|
464
|
+
instance?: unknown;
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* Notifications configuration and mode.
|
|
468
|
+
* Backend-only - not available in browser/frontend runtimes.
|
|
469
|
+
*/
|
|
470
|
+
notifications?: {
|
|
471
|
+
/**
|
|
472
|
+
* Whether to use a dedicated (isolated) notifications instance.
|
|
473
|
+
* - `false`: Use global shared instance (default)
|
|
474
|
+
* - `true`: Create dedicated instance
|
|
475
|
+
*/
|
|
476
|
+
dedicated: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Notifications config (merged global + per-service config).
|
|
479
|
+
* Used to create dedicated instance or configure global.
|
|
480
|
+
*/
|
|
481
|
+
config?: CoreNotificationConfig;
|
|
482
|
+
/**
|
|
483
|
+
* Actual NotificationService instance to use.
|
|
484
|
+
* Injected by ServiceRegistry, not created by service.
|
|
485
|
+
*/
|
|
486
|
+
instance?: unknown;
|
|
487
|
+
};
|
|
360
488
|
/** Logger prefix */
|
|
361
489
|
loggerPrefix?: string;
|
|
362
490
|
/** Whether this is a singleton instance */
|
|
363
491
|
isSingleton?: boolean;
|
|
364
492
|
/**
|
|
365
|
-
* Injected service instances (cache, db, api).
|
|
493
|
+
* Injected service instances (cache, db, api, storage, notifications).
|
|
366
494
|
* Services built by ServiceRegistry will receive these automatically.
|
|
367
495
|
*/
|
|
368
496
|
injected?: CoreInjectedServices;
|
|
@@ -442,6 +570,10 @@ export interface CoreServiceRegistryConfig {
|
|
|
442
570
|
cache?: CoreCacheConfig;
|
|
443
571
|
/** Global observability config (shared by all services unless overridden) */
|
|
444
572
|
observability?: CoreObservabilityConfig;
|
|
573
|
+
/** Global storage config (shared by all services unless overridden) - backend only */
|
|
574
|
+
storage?: CoreStorageConfig;
|
|
575
|
+
/** Global notifications config (shared by all services unless overridden) - backend only */
|
|
576
|
+
notifications?: CoreNotificationConfig;
|
|
445
577
|
/**
|
|
446
578
|
* Store registry interface for injecting stores into services.
|
|
447
579
|
* Provides type-safe store access via store keys.
|
|
@@ -637,12 +769,18 @@ export interface CoreObservabilityConfig {
|
|
|
637
769
|
/** Export interval in milliseconds */
|
|
638
770
|
exportInterval?: number;
|
|
639
771
|
};
|
|
772
|
+
/**
|
|
773
|
+
* Pre-initialized adapters for observability.
|
|
774
|
+
* Can be plain adapters or adapters with priority/failover config.
|
|
775
|
+
* LoggerAdapter is auto-added as failover if not included.
|
|
776
|
+
*/
|
|
777
|
+
adapters?: (MonitoringObservabilityAdapter | MonitoringAdapterWithPriority)[];
|
|
640
778
|
}
|
|
641
779
|
/**
|
|
642
780
|
* Base core initialization options
|
|
643
781
|
* Extended by @plyaz/core's CoreInitOptions with specific types
|
|
644
782
|
*/
|
|
645
|
-
export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
783
|
+
export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown, TStorage = unknown, TNotifications = unknown> {
|
|
646
784
|
/** Path to .env file (backend only) */
|
|
647
785
|
envPath?: string;
|
|
648
786
|
/** Global environment (production, staging, development) */
|
|
@@ -659,6 +797,10 @@ export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
|
659
797
|
cache?: CoreCacheConfig;
|
|
660
798
|
/** Observability configuration */
|
|
661
799
|
observability?: CoreObservabilityConfig;
|
|
800
|
+
/** Storage configuration (backend only) */
|
|
801
|
+
storage?: TStorage;
|
|
802
|
+
/** Notifications configuration (backend only) */
|
|
803
|
+
notifications?: TNotifications;
|
|
662
804
|
/** Skip database initialization */
|
|
663
805
|
skipDb?: boolean;
|
|
664
806
|
/** Skip API client initialization */
|
|
@@ -667,6 +809,10 @@ export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
|
667
809
|
skipCache?: boolean;
|
|
668
810
|
/** Skip observability initialization */
|
|
669
811
|
skipObservability?: boolean;
|
|
812
|
+
/** Skip storage initialization (backend only) */
|
|
813
|
+
skipStorage?: boolean;
|
|
814
|
+
/** Skip notifications initialization (backend only) */
|
|
815
|
+
skipNotifications?: boolean;
|
|
670
816
|
/** Enable verbose logging */
|
|
671
817
|
verbose?: boolean;
|
|
672
818
|
/** Error handler configuration */
|
|
@@ -679,7 +825,7 @@ export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
|
679
825
|
/**
|
|
680
826
|
* Core services result from initialization
|
|
681
827
|
*/
|
|
682
|
-
export interface CoreServicesResultBase<TDb = unknown, TApi = unknown, TCache = unknown, TObservability = unknown> {
|
|
828
|
+
export interface CoreServicesResultBase<TDb = unknown, TApi = unknown, TCache = unknown, TObservability = unknown, TStorage = unknown, TNotifications = unknown> {
|
|
683
829
|
/** Database service instance (null if skipped or on frontend) */
|
|
684
830
|
db: TDb | null;
|
|
685
831
|
/** API client service class */
|
|
@@ -688,6 +834,10 @@ export interface CoreServicesResultBase<TDb = unknown, TApi = unknown, TCache =
|
|
|
688
834
|
cache: TCache | null;
|
|
689
835
|
/** Observability adapter instance (null if skipped) */
|
|
690
836
|
observability: TObservability | null;
|
|
837
|
+
/** Storage service instance (null if skipped or on frontend) */
|
|
838
|
+
storage: TStorage | null;
|
|
839
|
+
/** Notification service instance (null if skipped or on frontend) */
|
|
840
|
+
notifications: TNotifications | null;
|
|
691
841
|
/** Loaded environment variables */
|
|
692
842
|
env: Record<string, string | undefined>;
|
|
693
843
|
/** Detected runtime environment */
|
package/dist/core/modules.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ export interface CoreApiInitOptions {
|
|
|
311
311
|
/**
|
|
312
312
|
* Core initialization options
|
|
313
313
|
*/
|
|
314
|
-
export interface CoreInitOptions<TDbConfig = unknown, TApiConfig = CoreApiInitOptions, TCacheConfig = unknown> {
|
|
314
|
+
export interface CoreInitOptions<TDbConfig = unknown, TApiConfig = CoreApiInitOptions, TCacheConfig = unknown, TStorageConfig = unknown, TNotificationsConfig = unknown> {
|
|
315
315
|
/** Path to .env file */
|
|
316
316
|
envPath?: string;
|
|
317
317
|
/** Global application environment */
|
|
@@ -326,22 +326,32 @@ export interface CoreInitOptions<TDbConfig = unknown, TApiConfig = CoreApiInitOp
|
|
|
326
326
|
api?: TApiConfig;
|
|
327
327
|
/** Cache configuration */
|
|
328
328
|
cache?: TCacheConfig;
|
|
329
|
+
/** Storage configuration (backend only) */
|
|
330
|
+
storage?: TStorageConfig;
|
|
331
|
+
/** Notifications configuration (backend only) */
|
|
332
|
+
notifications?: TNotificationsConfig;
|
|
329
333
|
/** Skip database initialization */
|
|
330
334
|
skipDb?: boolean;
|
|
331
335
|
/** Skip API client initialization */
|
|
332
336
|
skipApi?: boolean;
|
|
333
337
|
/** Skip cache initialization */
|
|
334
338
|
skipCache?: boolean;
|
|
339
|
+
/** Skip storage initialization */
|
|
340
|
+
skipStorage?: boolean;
|
|
341
|
+
/** Skip notifications initialization */
|
|
342
|
+
skipNotifications?: boolean;
|
|
335
343
|
/** Enable verbose logging */
|
|
336
344
|
verbose?: boolean;
|
|
337
345
|
}
|
|
338
346
|
/**
|
|
339
347
|
* Core initialization result
|
|
340
348
|
*/
|
|
341
|
-
export interface CoreServicesResult<TDb = unknown, TApi = unknown, TCache = unknown> {
|
|
349
|
+
export interface CoreServicesResult<TDb = unknown, TApi = unknown, TCache = unknown, TStorage = unknown, TNotifications = unknown> {
|
|
342
350
|
db: TDb | null;
|
|
343
351
|
api: TApi | null;
|
|
344
352
|
cache: TCache | null;
|
|
353
|
+
storage: TStorage | null;
|
|
354
|
+
notifications: TNotifications | null;
|
|
345
355
|
env: CoreEnvVars;
|
|
346
356
|
runtime: CoreRuntimeEnvironment;
|
|
347
357
|
appContext: CoreAppContext;
|
package/dist/index.cjs
CHANGED
|
@@ -192,7 +192,9 @@ var CoreEventScope = {
|
|
|
192
192
|
AUTH: "auth",
|
|
193
193
|
DATABASE: "database",
|
|
194
194
|
FEATURE_FLAG: "featureFlag",
|
|
195
|
-
STORE: "store"
|
|
195
|
+
STORE: "store",
|
|
196
|
+
STORAGE: "storage",
|
|
197
|
+
NOTIFICATION: "notification"
|
|
196
198
|
};
|
|
197
199
|
var SystemEventAction = {
|
|
198
200
|
INITIALIZED: "initialized",
|
|
@@ -270,6 +272,22 @@ var StoreEventAction = {
|
|
|
270
272
|
RESET: "reset",
|
|
271
273
|
HYDRATED: "hydrated"
|
|
272
274
|
};
|
|
275
|
+
var StorageEventAction = {
|
|
276
|
+
UPLOADED: "uploaded",
|
|
277
|
+
DOWNLOADED: "downloaded",
|
|
278
|
+
DELETED: "deleted",
|
|
279
|
+
ERROR: "error",
|
|
280
|
+
HEALTH_CHECK: "healthCheck"
|
|
281
|
+
};
|
|
282
|
+
var NotificationEventAction = {
|
|
283
|
+
SENT: "sent",
|
|
284
|
+
FAILED: "failed",
|
|
285
|
+
DELIVERED: "delivered",
|
|
286
|
+
OPENED: "opened",
|
|
287
|
+
CLICKED: "clicked",
|
|
288
|
+
ERROR: "error",
|
|
289
|
+
HEALTH_CHECK: "healthCheck"
|
|
290
|
+
};
|
|
273
291
|
var CORE_EVENTS = {
|
|
274
292
|
SYSTEM: {
|
|
275
293
|
INITIALIZED: `${CoreEventScope.SYSTEM}:${SystemEventAction.INITIALIZED}`,
|
|
@@ -342,6 +360,22 @@ var CORE_EVENTS = {
|
|
|
342
360
|
UPDATED: `${CoreEventScope.STORE}:${StoreEventAction.UPDATED}`,
|
|
343
361
|
RESET: `${CoreEventScope.STORE}:${StoreEventAction.RESET}`,
|
|
344
362
|
HYDRATED: `${CoreEventScope.STORE}:${StoreEventAction.HYDRATED}`
|
|
363
|
+
},
|
|
364
|
+
STORAGE: {
|
|
365
|
+
UPLOADED: `${CoreEventScope.STORAGE}:${StorageEventAction.UPLOADED}`,
|
|
366
|
+
DOWNLOADED: `${CoreEventScope.STORAGE}:${StorageEventAction.DOWNLOADED}`,
|
|
367
|
+
DELETED: `${CoreEventScope.STORAGE}:${StorageEventAction.DELETED}`,
|
|
368
|
+
ERROR: `${CoreEventScope.STORAGE}:${StorageEventAction.ERROR}`,
|
|
369
|
+
HEALTH_CHECK: `${CoreEventScope.STORAGE}:${StorageEventAction.HEALTH_CHECK}`
|
|
370
|
+
},
|
|
371
|
+
NOTIFICATION: {
|
|
372
|
+
SENT: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.SENT}`,
|
|
373
|
+
FAILED: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.FAILED}`,
|
|
374
|
+
DELIVERED: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.DELIVERED}`,
|
|
375
|
+
OPENED: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.OPENED}`,
|
|
376
|
+
CLICKED: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.CLICKED}`,
|
|
377
|
+
ERROR: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.ERROR}`,
|
|
378
|
+
HEALTH_CHECK: `${CoreEventScope.NOTIFICATION}:${NotificationEventAction.HEALTH_CHECK}`
|
|
345
379
|
}
|
|
346
380
|
};
|
|
347
381
|
|
|
@@ -8696,6 +8730,7 @@ exports.NOTIFICATION_ERROR_CODES = NOTIFICATION_ERROR_CODES;
|
|
|
8696
8730
|
exports.NOTIFICATION_PROVIDERS = NOTIFICATION_PROVIDERS;
|
|
8697
8731
|
exports.NetworkPresetNames = NetworkPresetNames;
|
|
8698
8732
|
exports.NotificationCategorySchema = NotificationCategorySchema;
|
|
8733
|
+
exports.NotificationEventAction = NotificationEventAction;
|
|
8699
8734
|
exports.OBSERVABILITY_METRICS = OBSERVABILITY_METRICS;
|
|
8700
8735
|
exports.OBSERVABILITY_SPANS = OBSERVABILITY_SPANS;
|
|
8701
8736
|
exports.OPERATIONS = COMMON_OPERATIONS;
|
|
@@ -8766,6 +8801,7 @@ exports.SanitizationEventAction = SanitizationEventAction;
|
|
|
8766
8801
|
exports.SendGridEventSchema = SendGridEventSchema;
|
|
8767
8802
|
exports.SendGridWebhookSchema = SendGridWebhookSchema;
|
|
8768
8803
|
exports.SignupFormSchema = SignupFormSchema;
|
|
8804
|
+
exports.StorageEventAction = StorageEventAction;
|
|
8769
8805
|
exports.StorageMediaProcessingPayloadSchema = StorageMediaProcessingPayloadSchema;
|
|
8770
8806
|
exports.StorageProcessingOutputSchema = StorageProcessingOutputSchema;
|
|
8771
8807
|
exports.StoreEventAction = StoreEventAction;
|