@plyaz/types 1.23.2 → 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 +13 -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 +146 -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
|
@@ -132,7 +132,7 @@ export type CoreValidatorClass<T extends CoreBaseValidatorInstance = CoreBaseVal
|
|
|
132
132
|
* interface BasicInjectedServices extends CoreInjectedServices {}
|
|
133
133
|
* ```
|
|
134
134
|
*/
|
|
135
|
-
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> {
|
|
136
136
|
/** Cache manager instance */
|
|
137
137
|
cache?: TCache;
|
|
138
138
|
/** Database service instance */
|
|
@@ -150,6 +150,18 @@ export interface CoreInjectedServices<TCache = unknown, TDb = unknown, TApi = un
|
|
|
150
150
|
* Supports adapter-based providers (Datadog, Grafana, OpenTelemetry, etc.)
|
|
151
151
|
*/
|
|
152
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;
|
|
153
165
|
}
|
|
154
166
|
/**
|
|
155
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';
|
|
@@ -13,6 +13,20 @@ import type { CoreAppEnvironment, CoreAppContext, CoreRuntimeEnvironment, CoreSe
|
|
|
13
13
|
import type { CoreDbServiceConfig } from '../services';
|
|
14
14
|
import type { CoreInjectedServices } from '../domain';
|
|
15
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;
|
|
16
30
|
/**
|
|
17
31
|
* Base interface that all domain service instances must implement.
|
|
18
32
|
* This allows the registry to manage services generically.
|
|
@@ -246,6 +260,75 @@ export interface CoreServiceInitConfig {
|
|
|
246
260
|
* ```
|
|
247
261
|
*/
|
|
248
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;
|
|
249
332
|
}
|
|
250
333
|
/**
|
|
251
334
|
* Options passed to the service factory method
|
|
@@ -358,12 +441,56 @@ export interface CoreServiceCreateOptions<TConfig = unknown, TMapper = unknown,
|
|
|
358
441
|
*/
|
|
359
442
|
instance?: unknown;
|
|
360
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
|
+
};
|
|
361
488
|
/** Logger prefix */
|
|
362
489
|
loggerPrefix?: string;
|
|
363
490
|
/** Whether this is a singleton instance */
|
|
364
491
|
isSingleton?: boolean;
|
|
365
492
|
/**
|
|
366
|
-
* Injected service instances (cache, db, api).
|
|
493
|
+
* Injected service instances (cache, db, api, storage, notifications).
|
|
367
494
|
* Services built by ServiceRegistry will receive these automatically.
|
|
368
495
|
*/
|
|
369
496
|
injected?: CoreInjectedServices;
|
|
@@ -443,6 +570,10 @@ export interface CoreServiceRegistryConfig {
|
|
|
443
570
|
cache?: CoreCacheConfig;
|
|
444
571
|
/** Global observability config (shared by all services unless overridden) */
|
|
445
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;
|
|
446
577
|
/**
|
|
447
578
|
* Store registry interface for injecting stores into services.
|
|
448
579
|
* Provides type-safe store access via store keys.
|
|
@@ -649,7 +780,7 @@ export interface CoreObservabilityConfig {
|
|
|
649
780
|
* Base core initialization options
|
|
650
781
|
* Extended by @plyaz/core's CoreInitOptions with specific types
|
|
651
782
|
*/
|
|
652
|
-
export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
783
|
+
export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown, TStorage = unknown, TNotifications = unknown> {
|
|
653
784
|
/** Path to .env file (backend only) */
|
|
654
785
|
envPath?: string;
|
|
655
786
|
/** Global environment (production, staging, development) */
|
|
@@ -666,6 +797,10 @@ export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
|
666
797
|
cache?: CoreCacheConfig;
|
|
667
798
|
/** Observability configuration */
|
|
668
799
|
observability?: CoreObservabilityConfig;
|
|
800
|
+
/** Storage configuration (backend only) */
|
|
801
|
+
storage?: TStorage;
|
|
802
|
+
/** Notifications configuration (backend only) */
|
|
803
|
+
notifications?: TNotifications;
|
|
669
804
|
/** Skip database initialization */
|
|
670
805
|
skipDb?: boolean;
|
|
671
806
|
/** Skip API client initialization */
|
|
@@ -674,6 +809,10 @@ export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
|
674
809
|
skipCache?: boolean;
|
|
675
810
|
/** Skip observability initialization */
|
|
676
811
|
skipObservability?: boolean;
|
|
812
|
+
/** Skip storage initialization (backend only) */
|
|
813
|
+
skipStorage?: boolean;
|
|
814
|
+
/** Skip notifications initialization (backend only) */
|
|
815
|
+
skipNotifications?: boolean;
|
|
677
816
|
/** Enable verbose logging */
|
|
678
817
|
verbose?: boolean;
|
|
679
818
|
/** Error handler configuration */
|
|
@@ -686,7 +825,7 @@ export interface CoreInitOptionsBase<TDb = unknown, TApi = unknown> {
|
|
|
686
825
|
/**
|
|
687
826
|
* Core services result from initialization
|
|
688
827
|
*/
|
|
689
|
-
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> {
|
|
690
829
|
/** Database service instance (null if skipped or on frontend) */
|
|
691
830
|
db: TDb | null;
|
|
692
831
|
/** API client service class */
|
|
@@ -695,6 +834,10 @@ export interface CoreServicesResultBase<TDb = unknown, TApi = unknown, TCache =
|
|
|
695
834
|
cache: TCache | null;
|
|
696
835
|
/** Observability adapter instance (null if skipped) */
|
|
697
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;
|
|
698
841
|
/** Loaded environment variables */
|
|
699
842
|
env: Record<string, string | undefined>;
|
|
700
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;
|