@gravito/flare 3.0.1 → 3.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/dist/index.d.cts CHANGED
@@ -118,6 +118,111 @@ interface SmsMessage {
118
118
  /** Sender ID or phone number */
119
119
  from?: string;
120
120
  }
121
+ /**
122
+ * Result of a single channel delivery attempt.
123
+ * @public
124
+ */
125
+ interface SendResult {
126
+ success: boolean;
127
+ channel: string;
128
+ error?: Error;
129
+ duration?: number;
130
+ }
131
+ /**
132
+ * Aggregated result of a notification delivery.
133
+ * @public
134
+ */
135
+ interface NotificationResult {
136
+ notification: string;
137
+ notifiable: string | number;
138
+ results: SendResult[];
139
+ allSuccess: boolean;
140
+ timestamp: Date;
141
+ }
142
+ /**
143
+ * Options for sending notifications.
144
+ * @public
145
+ */
146
+ interface SendOptions {
147
+ /** If true, throws an AggregateError when any channel fails */
148
+ throwOnError?: boolean;
149
+ /** Whether to send to channels in parallel (default: true) */
150
+ parallel?: boolean;
151
+ /** Maximum number of concurrent channel sends (default: unlimited) */
152
+ concurrency?: number;
153
+ /** Retry configuration */
154
+ retry?: Partial<RetryConfig> | boolean;
155
+ }
156
+ /**
157
+ * Retry configuration options.
158
+ * @public
159
+ */
160
+ interface RetryConfig {
161
+ /** Maximum number of retry attempts (default: 3) */
162
+ maxAttempts: number;
163
+ /** Base delay in milliseconds (default: 1000) */
164
+ baseDelay: number;
165
+ /** Backoff strategy: 'fixed' | 'linear' | 'exponential' (default: 'exponential') */
166
+ backoff: 'fixed' | 'linear' | 'exponential';
167
+ /** Maximum delay in milliseconds (default: 30000) */
168
+ maxDelay: number;
169
+ /** Function to determine if an error is retryable */
170
+ retryableErrors?: (error: Error) => boolean;
171
+ }
172
+ /**
173
+ * Interface for notifications that should retry on failure.
174
+ * @public
175
+ */
176
+ interface ShouldRetry {
177
+ /** Retry configuration for this notification */
178
+ retry?: Partial<RetryConfig>;
179
+ }
180
+ /**
181
+ * Result of a batch notification delivery.
182
+ * @public
183
+ */
184
+ interface BatchResult {
185
+ total: number;
186
+ success: number;
187
+ failed: number;
188
+ results: NotificationResult[];
189
+ duration: number;
190
+ }
191
+ interface NotificationHookPayload {
192
+ notification: Notification;
193
+ notifiable: Notifiable;
194
+ channels: string[];
195
+ }
196
+ interface ChannelHookPayload {
197
+ notification: Notification;
198
+ notifiable: Notifiable;
199
+ channel: string;
200
+ }
201
+ interface ChannelSuccessPayload extends ChannelHookPayload {
202
+ duration: number;
203
+ }
204
+ interface ChannelFailurePayload extends ChannelHookPayload {
205
+ error: Error;
206
+ duration: number;
207
+ }
208
+ interface NotificationCompletePayload {
209
+ notification: Notification;
210
+ notifiable: Notifiable;
211
+ results: SendResult[];
212
+ allSuccess: boolean;
213
+ totalDuration: number;
214
+ }
215
+ interface NotificationBatchStartPayload {
216
+ notification: Notification;
217
+ count: number;
218
+ }
219
+ interface NotificationBatchCompletePayload {
220
+ notification: Notification;
221
+ total: number;
222
+ success: number;
223
+ failed: number;
224
+ duration: number;
225
+ }
121
226
 
122
227
  /**
123
228
  * Marker interface for notifications that should be queued.
@@ -155,27 +260,27 @@ declare abstract class Notification {
155
260
  * Get mail message (optional).
156
261
  * Implement this if the notification will be sent via the mail channel.
157
262
  */
158
- toMail?(_notifiable: Notifiable): MailMessage;
263
+ toMail?(notifiable: Notifiable): MailMessage;
159
264
  /**
160
265
  * Get database notification (optional).
161
266
  * Implement this if the notification will be stored via the database channel.
162
267
  */
163
- toDatabase?(_notifiable: Notifiable): DatabaseNotification;
268
+ toDatabase?(notifiable: Notifiable): DatabaseNotification;
164
269
  /**
165
270
  * Get broadcast notification (optional).
166
271
  * Implement this if the notification will be sent via the broadcast channel.
167
272
  */
168
- toBroadcast?(_notifiable: Notifiable): BroadcastNotification;
273
+ toBroadcast?(notifiable: Notifiable): BroadcastNotification;
169
274
  /**
170
275
  * Get Slack message (optional).
171
276
  * Implement this if the notification will be sent via the Slack channel.
172
277
  */
173
- toSlack?(_notifiable: Notifiable): SlackMessage;
278
+ toSlack?(notifiable: Notifiable): SlackMessage;
174
279
  /**
175
280
  * Get SMS message (optional).
176
281
  * Implement this if the notification will be sent via the SMS channel.
177
282
  */
178
- toSms?(_notifiable: Notifiable): SmsMessage;
283
+ toSms?(notifiable: Notifiable): SmsMessage;
179
284
  /**
180
285
  * Check whether this notification should be queued.
181
286
  */
@@ -260,12 +365,14 @@ interface SmsChannelConfig {
260
365
  apiKey?: string;
261
366
  apiSecret?: string;
262
367
  from?: string;
368
+ region?: string;
369
+ accessKeyId?: string;
370
+ secretAccessKey?: string;
263
371
  }
264
372
  /**
265
373
  * SMS channel.
266
374
  *
267
375
  * Sends notifications via an SMS provider.
268
- * Only a basic interface is provided; real implementations should be extended per provider.
269
376
  */
270
377
  declare class SmsChannel implements NotificationChannel {
271
378
  private config;
@@ -281,6 +388,46 @@ declare class SmsChannel implements NotificationChannel {
281
388
  private sendViaAwsSns;
282
389
  }
283
390
 
391
+ interface NotificationMetric {
392
+ notification: string;
393
+ channel: string;
394
+ success: boolean;
395
+ duration: number;
396
+ timestamp: Date;
397
+ error?: string;
398
+ retryCount?: number;
399
+ }
400
+ interface MetricsSummary {
401
+ totalSent: number;
402
+ totalSuccess: number;
403
+ totalFailed: number;
404
+ avgDuration: number;
405
+ byChannel: Record<string, {
406
+ sent: number;
407
+ success: number;
408
+ failed: number;
409
+ avgDuration: number;
410
+ }>;
411
+ byNotification: Record<string, {
412
+ sent: number;
413
+ success: number;
414
+ failed: number;
415
+ avgDuration: number;
416
+ }>;
417
+ }
418
+ declare class NotificationMetricsCollector {
419
+ private metrics;
420
+ private readonly maxHistory;
421
+ constructor(maxHistory?: number);
422
+ record(metric: NotificationMetric): void;
423
+ getSummary(since?: Date): MetricsSummary;
424
+ getRecentFailures(limit?: number): NotificationMetric[];
425
+ getSlowNotifications(threshold: number, limit?: number): NotificationMetric[];
426
+ clear(): void;
427
+ }
428
+
429
+ declare function toPrometheusFormat(summary: MetricsSummary): string;
430
+
284
431
  /**
285
432
  * Notification manager.
286
433
  *
@@ -297,6 +444,19 @@ declare class NotificationManager {
297
444
  */
298
445
  private queueManager?;
299
446
  constructor(core: PlanetCore);
447
+ private metrics?;
448
+ /**
449
+ * Enable metrics collection.
450
+ */
451
+ enableMetrics(maxHistory?: number): void;
452
+ /**
453
+ * Get metrics summary.
454
+ */
455
+ getMetrics(since?: Date): MetricsSummary | undefined;
456
+ /**
457
+ * Get recent failures.
458
+ */
459
+ getRecentFailures(limit?: number): NotificationMetric[];
300
460
  /**
301
461
  * Register a notification channel.
302
462
  *
@@ -315,22 +475,50 @@ declare class NotificationManager {
315
475
  *
316
476
  * @param notifiable - The recipient of the notification.
317
477
  * @param notification - The notification instance.
318
- * @returns A promise that resolves when the notification is sent or queued.
478
+ * @param options - Options for sending.
479
+ * @returns A promise that resolves to the notification result.
319
480
  *
320
481
  * @example
321
482
  * ```typescript
322
- * await notificationManager.send(user, new InvoicePaid(invoice))
483
+ * const result = await notificationManager.send(user, new InvoicePaid(invoice))
484
+ * if (!result.allSuccess) { ... }
323
485
  * ```
324
486
  */
325
- send(notifiable: Notifiable, notification: Notification): Promise<void>;
487
+ send(notifiable: Notifiable, notification: Notification, options?: SendOptions): Promise<NotificationResult>;
326
488
  /**
327
- * Send immediately (without queue).
489
+ * Batch send notification to multiple recipients.
490
+ *
491
+ * @param notifiables - List of recipients.
492
+ * @param notification - The notification instance.
493
+ * @param options - Options for sending.
494
+ * @returns A promise that resolves to the batch result.
495
+ */
496
+ sendBatch(notifiables: Notifiable[], notification: Notification, options?: SendOptions & {
497
+ /** Batch concurrency (default: 10) */
498
+ batchConcurrency?: number;
499
+ }): Promise<BatchResult>;
500
+ /**
501
+ * Batch send notification to multiple recipients (streaming).
328
502
  *
329
- * @param notifiable - The recipient.
330
- * @param notification - The notification.
331
- * @param channels - The list of channels to send via.
503
+ * @param notifiables - AsyncIterable or Iterable of recipients.
504
+ * @param notification - The notification instance.
505
+ * @param options - Options for sending.
506
+ * @yields Notification results as they are processed.
507
+ */
508
+ sendBatchStream(notifiables: AsyncIterable<Notifiable> | Iterable<Notifiable>, notification: Notification, options?: SendOptions & {
509
+ batchSize?: number;
510
+ }): AsyncGenerator<NotificationResult>;
511
+ /**
512
+ * Send immediately (without queue).
332
513
  */
333
514
  private sendNow;
515
+ private sendSequential;
516
+ private sendParallel;
517
+ private sendWithConcurrencyLimit;
518
+ private processWithConcurrency;
519
+ private sendToChannel;
520
+ private executeChannelSend;
521
+ private getRetryConfig;
334
522
  /**
335
523
  * Serialize notification (for queuing).
336
524
  *
@@ -340,9 +528,6 @@ declare class NotificationManager {
340
528
  private serializeNotification;
341
529
  }
342
530
 
343
- /**
344
- * OrbitFlare options.
345
- */
346
531
  /**
347
532
  * Options for configuring OrbitFlare.
348
533
  * @public
@@ -389,12 +574,24 @@ declare class OrbitFlare implements GravitoOrbit {
389
574
  * @returns A new OrbitFlare instance.
390
575
  */
391
576
  static configure(options?: OrbitFlareOptions): OrbitFlare;
577
+ private validateOptions;
578
+ private isValidUrl;
392
579
  /**
393
580
  * Install OrbitFlare into PlanetCore.
394
581
  *
395
582
  * @param core - The PlanetCore instance.
396
583
  */
397
584
  install(core: PlanetCore): Promise<void>;
585
+ private setupMailChannel;
586
+ private setupDatabaseChannel;
587
+ private setupBroadcastChannel;
588
+ private setupSlackChannel;
589
+ private setupSmsChannel;
590
+ private setupQueueIntegration;
591
+ private isMailService;
592
+ private isDatabaseService;
593
+ private isBroadcastService;
594
+ private isQueueService;
398
595
  }
399
596
  declare module '@gravito/core' {
400
597
  interface GravitoVariables {
@@ -403,4 +600,32 @@ declare module '@gravito/core' {
403
600
  }
404
601
  }
405
602
 
406
- export { BroadcastChannel, type BroadcastNotification, DatabaseChannel, type DatabaseNotification, MailChannel, type MailMessage, type Notifiable, Notification, type NotificationChannel, NotificationManager, OrbitFlare, type OrbitFlareOptions, type ShouldQueue, SlackChannel, type SlackChannelConfig, type SlackMessage, SmsChannel, type SmsChannelConfig, type SmsMessage };
603
+ interface TemplateData {
604
+ [key: string]: unknown;
605
+ }
606
+ interface MailTemplate {
607
+ subject: string;
608
+ view?: string;
609
+ data?: TemplateData;
610
+ }
611
+ interface SlackTemplate {
612
+ text: string;
613
+ channel?: string;
614
+ attachments?: Array<{
615
+ color?: string;
616
+ title?: string;
617
+ text?: string;
618
+ }>;
619
+ }
620
+ declare abstract class TemplatedNotification extends Notification {
621
+ protected data: TemplateData;
622
+ with(data: TemplateData): this;
623
+ protected abstract mailTemplate(): MailTemplate;
624
+ protected slackTemplate?(): SlackTemplate;
625
+ toMail(notifiable: Notifiable): MailMessage;
626
+ toSlack(_notifiable: Notifiable): SlackMessage;
627
+ private interpolate;
628
+ private getRecipientEmail;
629
+ }
630
+
631
+ export { type BatchResult, BroadcastChannel, type BroadcastNotification, type ChannelFailurePayload, type ChannelHookPayload, type ChannelSuccessPayload, DatabaseChannel, type DatabaseNotification, MailChannel, type MailMessage, type MailTemplate, type MetricsSummary, type Notifiable, Notification, type NotificationBatchCompletePayload, type NotificationBatchStartPayload, type NotificationChannel, type NotificationCompletePayload, type NotificationHookPayload, NotificationManager, type NotificationMetric, NotificationMetricsCollector, type NotificationResult, OrbitFlare, type OrbitFlareOptions, type RetryConfig, type SendOptions, type SendResult, type ShouldQueue, type ShouldRetry, SlackChannel, type SlackChannelConfig, type SlackMessage, type SlackTemplate, SmsChannel, type SmsChannelConfig, type SmsMessage, type TemplateData, TemplatedNotification, toPrometheusFormat };
package/dist/index.d.ts CHANGED
@@ -118,6 +118,111 @@ interface SmsMessage {
118
118
  /** Sender ID or phone number */
119
119
  from?: string;
120
120
  }
121
+ /**
122
+ * Result of a single channel delivery attempt.
123
+ * @public
124
+ */
125
+ interface SendResult {
126
+ success: boolean;
127
+ channel: string;
128
+ error?: Error;
129
+ duration?: number;
130
+ }
131
+ /**
132
+ * Aggregated result of a notification delivery.
133
+ * @public
134
+ */
135
+ interface NotificationResult {
136
+ notification: string;
137
+ notifiable: string | number;
138
+ results: SendResult[];
139
+ allSuccess: boolean;
140
+ timestamp: Date;
141
+ }
142
+ /**
143
+ * Options for sending notifications.
144
+ * @public
145
+ */
146
+ interface SendOptions {
147
+ /** If true, throws an AggregateError when any channel fails */
148
+ throwOnError?: boolean;
149
+ /** Whether to send to channels in parallel (default: true) */
150
+ parallel?: boolean;
151
+ /** Maximum number of concurrent channel sends (default: unlimited) */
152
+ concurrency?: number;
153
+ /** Retry configuration */
154
+ retry?: Partial<RetryConfig> | boolean;
155
+ }
156
+ /**
157
+ * Retry configuration options.
158
+ * @public
159
+ */
160
+ interface RetryConfig {
161
+ /** Maximum number of retry attempts (default: 3) */
162
+ maxAttempts: number;
163
+ /** Base delay in milliseconds (default: 1000) */
164
+ baseDelay: number;
165
+ /** Backoff strategy: 'fixed' | 'linear' | 'exponential' (default: 'exponential') */
166
+ backoff: 'fixed' | 'linear' | 'exponential';
167
+ /** Maximum delay in milliseconds (default: 30000) */
168
+ maxDelay: number;
169
+ /** Function to determine if an error is retryable */
170
+ retryableErrors?: (error: Error) => boolean;
171
+ }
172
+ /**
173
+ * Interface for notifications that should retry on failure.
174
+ * @public
175
+ */
176
+ interface ShouldRetry {
177
+ /** Retry configuration for this notification */
178
+ retry?: Partial<RetryConfig>;
179
+ }
180
+ /**
181
+ * Result of a batch notification delivery.
182
+ * @public
183
+ */
184
+ interface BatchResult {
185
+ total: number;
186
+ success: number;
187
+ failed: number;
188
+ results: NotificationResult[];
189
+ duration: number;
190
+ }
191
+ interface NotificationHookPayload {
192
+ notification: Notification;
193
+ notifiable: Notifiable;
194
+ channels: string[];
195
+ }
196
+ interface ChannelHookPayload {
197
+ notification: Notification;
198
+ notifiable: Notifiable;
199
+ channel: string;
200
+ }
201
+ interface ChannelSuccessPayload extends ChannelHookPayload {
202
+ duration: number;
203
+ }
204
+ interface ChannelFailurePayload extends ChannelHookPayload {
205
+ error: Error;
206
+ duration: number;
207
+ }
208
+ interface NotificationCompletePayload {
209
+ notification: Notification;
210
+ notifiable: Notifiable;
211
+ results: SendResult[];
212
+ allSuccess: boolean;
213
+ totalDuration: number;
214
+ }
215
+ interface NotificationBatchStartPayload {
216
+ notification: Notification;
217
+ count: number;
218
+ }
219
+ interface NotificationBatchCompletePayload {
220
+ notification: Notification;
221
+ total: number;
222
+ success: number;
223
+ failed: number;
224
+ duration: number;
225
+ }
121
226
 
122
227
  /**
123
228
  * Marker interface for notifications that should be queued.
@@ -155,27 +260,27 @@ declare abstract class Notification {
155
260
  * Get mail message (optional).
156
261
  * Implement this if the notification will be sent via the mail channel.
157
262
  */
158
- toMail?(_notifiable: Notifiable): MailMessage;
263
+ toMail?(notifiable: Notifiable): MailMessage;
159
264
  /**
160
265
  * Get database notification (optional).
161
266
  * Implement this if the notification will be stored via the database channel.
162
267
  */
163
- toDatabase?(_notifiable: Notifiable): DatabaseNotification;
268
+ toDatabase?(notifiable: Notifiable): DatabaseNotification;
164
269
  /**
165
270
  * Get broadcast notification (optional).
166
271
  * Implement this if the notification will be sent via the broadcast channel.
167
272
  */
168
- toBroadcast?(_notifiable: Notifiable): BroadcastNotification;
273
+ toBroadcast?(notifiable: Notifiable): BroadcastNotification;
169
274
  /**
170
275
  * Get Slack message (optional).
171
276
  * Implement this if the notification will be sent via the Slack channel.
172
277
  */
173
- toSlack?(_notifiable: Notifiable): SlackMessage;
278
+ toSlack?(notifiable: Notifiable): SlackMessage;
174
279
  /**
175
280
  * Get SMS message (optional).
176
281
  * Implement this if the notification will be sent via the SMS channel.
177
282
  */
178
- toSms?(_notifiable: Notifiable): SmsMessage;
283
+ toSms?(notifiable: Notifiable): SmsMessage;
179
284
  /**
180
285
  * Check whether this notification should be queued.
181
286
  */
@@ -260,12 +365,14 @@ interface SmsChannelConfig {
260
365
  apiKey?: string;
261
366
  apiSecret?: string;
262
367
  from?: string;
368
+ region?: string;
369
+ accessKeyId?: string;
370
+ secretAccessKey?: string;
263
371
  }
264
372
  /**
265
373
  * SMS channel.
266
374
  *
267
375
  * Sends notifications via an SMS provider.
268
- * Only a basic interface is provided; real implementations should be extended per provider.
269
376
  */
270
377
  declare class SmsChannel implements NotificationChannel {
271
378
  private config;
@@ -281,6 +388,46 @@ declare class SmsChannel implements NotificationChannel {
281
388
  private sendViaAwsSns;
282
389
  }
283
390
 
391
+ interface NotificationMetric {
392
+ notification: string;
393
+ channel: string;
394
+ success: boolean;
395
+ duration: number;
396
+ timestamp: Date;
397
+ error?: string;
398
+ retryCount?: number;
399
+ }
400
+ interface MetricsSummary {
401
+ totalSent: number;
402
+ totalSuccess: number;
403
+ totalFailed: number;
404
+ avgDuration: number;
405
+ byChannel: Record<string, {
406
+ sent: number;
407
+ success: number;
408
+ failed: number;
409
+ avgDuration: number;
410
+ }>;
411
+ byNotification: Record<string, {
412
+ sent: number;
413
+ success: number;
414
+ failed: number;
415
+ avgDuration: number;
416
+ }>;
417
+ }
418
+ declare class NotificationMetricsCollector {
419
+ private metrics;
420
+ private readonly maxHistory;
421
+ constructor(maxHistory?: number);
422
+ record(metric: NotificationMetric): void;
423
+ getSummary(since?: Date): MetricsSummary;
424
+ getRecentFailures(limit?: number): NotificationMetric[];
425
+ getSlowNotifications(threshold: number, limit?: number): NotificationMetric[];
426
+ clear(): void;
427
+ }
428
+
429
+ declare function toPrometheusFormat(summary: MetricsSummary): string;
430
+
284
431
  /**
285
432
  * Notification manager.
286
433
  *
@@ -297,6 +444,19 @@ declare class NotificationManager {
297
444
  */
298
445
  private queueManager?;
299
446
  constructor(core: PlanetCore);
447
+ private metrics?;
448
+ /**
449
+ * Enable metrics collection.
450
+ */
451
+ enableMetrics(maxHistory?: number): void;
452
+ /**
453
+ * Get metrics summary.
454
+ */
455
+ getMetrics(since?: Date): MetricsSummary | undefined;
456
+ /**
457
+ * Get recent failures.
458
+ */
459
+ getRecentFailures(limit?: number): NotificationMetric[];
300
460
  /**
301
461
  * Register a notification channel.
302
462
  *
@@ -315,22 +475,50 @@ declare class NotificationManager {
315
475
  *
316
476
  * @param notifiable - The recipient of the notification.
317
477
  * @param notification - The notification instance.
318
- * @returns A promise that resolves when the notification is sent or queued.
478
+ * @param options - Options for sending.
479
+ * @returns A promise that resolves to the notification result.
319
480
  *
320
481
  * @example
321
482
  * ```typescript
322
- * await notificationManager.send(user, new InvoicePaid(invoice))
483
+ * const result = await notificationManager.send(user, new InvoicePaid(invoice))
484
+ * if (!result.allSuccess) { ... }
323
485
  * ```
324
486
  */
325
- send(notifiable: Notifiable, notification: Notification): Promise<void>;
487
+ send(notifiable: Notifiable, notification: Notification, options?: SendOptions): Promise<NotificationResult>;
326
488
  /**
327
- * Send immediately (without queue).
489
+ * Batch send notification to multiple recipients.
490
+ *
491
+ * @param notifiables - List of recipients.
492
+ * @param notification - The notification instance.
493
+ * @param options - Options for sending.
494
+ * @returns A promise that resolves to the batch result.
495
+ */
496
+ sendBatch(notifiables: Notifiable[], notification: Notification, options?: SendOptions & {
497
+ /** Batch concurrency (default: 10) */
498
+ batchConcurrency?: number;
499
+ }): Promise<BatchResult>;
500
+ /**
501
+ * Batch send notification to multiple recipients (streaming).
328
502
  *
329
- * @param notifiable - The recipient.
330
- * @param notification - The notification.
331
- * @param channels - The list of channels to send via.
503
+ * @param notifiables - AsyncIterable or Iterable of recipients.
504
+ * @param notification - The notification instance.
505
+ * @param options - Options for sending.
506
+ * @yields Notification results as they are processed.
507
+ */
508
+ sendBatchStream(notifiables: AsyncIterable<Notifiable> | Iterable<Notifiable>, notification: Notification, options?: SendOptions & {
509
+ batchSize?: number;
510
+ }): AsyncGenerator<NotificationResult>;
511
+ /**
512
+ * Send immediately (without queue).
332
513
  */
333
514
  private sendNow;
515
+ private sendSequential;
516
+ private sendParallel;
517
+ private sendWithConcurrencyLimit;
518
+ private processWithConcurrency;
519
+ private sendToChannel;
520
+ private executeChannelSend;
521
+ private getRetryConfig;
334
522
  /**
335
523
  * Serialize notification (for queuing).
336
524
  *
@@ -340,9 +528,6 @@ declare class NotificationManager {
340
528
  private serializeNotification;
341
529
  }
342
530
 
343
- /**
344
- * OrbitFlare options.
345
- */
346
531
  /**
347
532
  * Options for configuring OrbitFlare.
348
533
  * @public
@@ -389,12 +574,24 @@ declare class OrbitFlare implements GravitoOrbit {
389
574
  * @returns A new OrbitFlare instance.
390
575
  */
391
576
  static configure(options?: OrbitFlareOptions): OrbitFlare;
577
+ private validateOptions;
578
+ private isValidUrl;
392
579
  /**
393
580
  * Install OrbitFlare into PlanetCore.
394
581
  *
395
582
  * @param core - The PlanetCore instance.
396
583
  */
397
584
  install(core: PlanetCore): Promise<void>;
585
+ private setupMailChannel;
586
+ private setupDatabaseChannel;
587
+ private setupBroadcastChannel;
588
+ private setupSlackChannel;
589
+ private setupSmsChannel;
590
+ private setupQueueIntegration;
591
+ private isMailService;
592
+ private isDatabaseService;
593
+ private isBroadcastService;
594
+ private isQueueService;
398
595
  }
399
596
  declare module '@gravito/core' {
400
597
  interface GravitoVariables {
@@ -403,4 +600,32 @@ declare module '@gravito/core' {
403
600
  }
404
601
  }
405
602
 
406
- export { BroadcastChannel, type BroadcastNotification, DatabaseChannel, type DatabaseNotification, MailChannel, type MailMessage, type Notifiable, Notification, type NotificationChannel, NotificationManager, OrbitFlare, type OrbitFlareOptions, type ShouldQueue, SlackChannel, type SlackChannelConfig, type SlackMessage, SmsChannel, type SmsChannelConfig, type SmsMessage };
603
+ interface TemplateData {
604
+ [key: string]: unknown;
605
+ }
606
+ interface MailTemplate {
607
+ subject: string;
608
+ view?: string;
609
+ data?: TemplateData;
610
+ }
611
+ interface SlackTemplate {
612
+ text: string;
613
+ channel?: string;
614
+ attachments?: Array<{
615
+ color?: string;
616
+ title?: string;
617
+ text?: string;
618
+ }>;
619
+ }
620
+ declare abstract class TemplatedNotification extends Notification {
621
+ protected data: TemplateData;
622
+ with(data: TemplateData): this;
623
+ protected abstract mailTemplate(): MailTemplate;
624
+ protected slackTemplate?(): SlackTemplate;
625
+ toMail(notifiable: Notifiable): MailMessage;
626
+ toSlack(_notifiable: Notifiable): SlackMessage;
627
+ private interpolate;
628
+ private getRecipientEmail;
629
+ }
630
+
631
+ export { type BatchResult, BroadcastChannel, type BroadcastNotification, type ChannelFailurePayload, type ChannelHookPayload, type ChannelSuccessPayload, DatabaseChannel, type DatabaseNotification, MailChannel, type MailMessage, type MailTemplate, type MetricsSummary, type Notifiable, Notification, type NotificationBatchCompletePayload, type NotificationBatchStartPayload, type NotificationChannel, type NotificationCompletePayload, type NotificationHookPayload, NotificationManager, type NotificationMetric, NotificationMetricsCollector, type NotificationResult, OrbitFlare, type OrbitFlareOptions, type RetryConfig, type SendOptions, type SendResult, type ShouldQueue, type ShouldRetry, SlackChannel, type SlackChannelConfig, type SlackMessage, type SlackTemplate, SmsChannel, type SmsChannelConfig, type SmsMessage, type TemplateData, TemplatedNotification, toPrometheusFormat };