@memberjunction/communication-types 2.124.0 → 2.126.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.
@@ -1,5 +1,7 @@
1
+ /// <reference types="node" />
1
2
  import { UserInfo } from "@memberjunction/core";
2
3
  import { CommunicationProviderEntity, CommunicationProviderMessageTypeEntity, CommunicationRunEntity, TemplateEntityExtended } from "@memberjunction/core-entities";
4
+ import { ProviderCredentialsBase } from "./CredentialUtils";
3
5
  /**
4
6
  * Information about a single recipient
5
7
  */
@@ -126,6 +128,14 @@ export type BaseMessageResult = {
126
128
  ErrorMessage?: string;
127
129
  };
128
130
  export type GetMessagesParams<T = Record<string, any>> = {
131
+ /**
132
+ * The identifier to get messages for - an email address, mailbox ID, in the case of SMS, could be a
133
+ * phone number. In the case of other systems could be a User ID for FB Messenger/WhatsApp, etc.
134
+ *
135
+ * This is optional if the provider supports getting messages based on credentials alone as some
136
+ * credentials/providers can be scoped to a specific mailbox/user.
137
+ */
138
+ Identifier?: string;
129
139
  /**
130
140
  * The number of messages to return
131
141
  */
@@ -229,34 +239,516 @@ export type CreateDraftResult<T = Record<string, any>> = BaseMessageResult & {
229
239
  */
230
240
  Result?: T;
231
241
  };
242
+ /**
243
+ * Parameters for getting a single message by ID
244
+ */
245
+ export type GetSingleMessageParams<T = Record<string, any>> = {
246
+ /**
247
+ * The ID of the message to retrieve
248
+ */
249
+ MessageID: string;
250
+ /**
251
+ * Optional, include the headers in the response (defaults to false)
252
+ */
253
+ IncludeHeaders?: boolean;
254
+ /**
255
+ * Optional, include attachments metadata in the response (defaults to false)
256
+ */
257
+ IncludeAttachments?: boolean;
258
+ /**
259
+ * Optional, provider-specific context data
260
+ */
261
+ ContextData?: T;
262
+ };
263
+ /**
264
+ * Result of getting a single message
265
+ */
266
+ export type GetSingleMessageResult<T = Record<string, any>> = BaseMessageResult & {
267
+ /**
268
+ * The retrieved message in standardized format
269
+ */
270
+ Message?: GetMessageMessage;
271
+ /**
272
+ * If populated, holds provider-specific data that is returned from the provider
273
+ */
274
+ SourceData?: T;
275
+ };
276
+ /**
277
+ * Parameters for deleting a message
278
+ */
279
+ export type DeleteMessageParams<T = Record<string, any>> = {
280
+ /**
281
+ * The ID of the message to delete
282
+ */
283
+ MessageID: string;
284
+ /**
285
+ * If true, permanently delete the message. If false, move to trash (if supported).
286
+ * Defaults to false.
287
+ */
288
+ PermanentDelete?: boolean;
289
+ /**
290
+ * Optional, provider-specific context data
291
+ */
292
+ ContextData?: T;
293
+ };
294
+ /**
295
+ * Result of deleting a message
296
+ */
297
+ export type DeleteMessageResult<T = Record<string, any>> = BaseMessageResult & {
298
+ /**
299
+ * If populated, holds provider-specific result data
300
+ */
301
+ Result?: T;
302
+ };
303
+ /**
304
+ * Parameters for moving a message to a different folder
305
+ */
306
+ export type MoveMessageParams<T = Record<string, any>> = {
307
+ /**
308
+ * The ID of the message to move
309
+ */
310
+ MessageID: string;
311
+ /**
312
+ * The ID of the destination folder
313
+ */
314
+ DestinationFolderID: string;
315
+ /**
316
+ * Optional, provider-specific context data
317
+ */
318
+ ContextData?: T;
319
+ };
320
+ /**
321
+ * Result of moving a message
322
+ */
323
+ export type MoveMessageResult<T = Record<string, any>> = BaseMessageResult & {
324
+ /**
325
+ * The new message ID after moving (some providers assign new IDs)
326
+ */
327
+ NewMessageID?: string;
328
+ /**
329
+ * If populated, holds provider-specific result data
330
+ */
331
+ Result?: T;
332
+ };
333
+ /**
334
+ * Represents a folder/mailbox in the provider's system
335
+ */
336
+ export type MessageFolder = {
337
+ /**
338
+ * The unique ID of the folder
339
+ */
340
+ ID: string;
341
+ /**
342
+ * The display name of the folder
343
+ */
344
+ Name: string;
345
+ /**
346
+ * The ID of the parent folder, if any
347
+ */
348
+ ParentFolderID?: string;
349
+ /**
350
+ * The number of messages in the folder (if available)
351
+ */
352
+ MessageCount?: number;
353
+ /**
354
+ * The number of unread messages in the folder (if available)
355
+ */
356
+ UnreadCount?: number;
357
+ /**
358
+ * Whether this is a system folder (Inbox, Sent, Drafts, etc.)
359
+ */
360
+ IsSystemFolder?: boolean;
361
+ /**
362
+ * The type of system folder if IsSystemFolder is true
363
+ */
364
+ SystemFolderType?: 'inbox' | 'sent' | 'drafts' | 'trash' | 'spam' | 'archive' | 'other';
365
+ };
366
+ /**
367
+ * Parameters for listing folders
368
+ */
369
+ export type ListFoldersParams<T = Record<string, any>> = {
370
+ /**
371
+ * Optional, the ID of the parent folder to list children of.
372
+ * If not provided, lists root-level folders.
373
+ */
374
+ ParentFolderID?: string;
375
+ /**
376
+ * Optional, include message counts in the response (defaults to false)
377
+ */
378
+ IncludeCounts?: boolean;
379
+ /**
380
+ * Optional, provider-specific context data
381
+ */
382
+ ContextData?: T;
383
+ };
384
+ /**
385
+ * Result of listing folders
386
+ */
387
+ export type ListFoldersResult<T = Record<string, any>> = BaseMessageResult & {
388
+ /**
389
+ * The list of folders
390
+ */
391
+ Folders?: MessageFolder[];
392
+ /**
393
+ * If populated, holds provider-specific result data
394
+ */
395
+ Result?: T;
396
+ };
397
+ /**
398
+ * Parameters for marking message(s) as read or unread
399
+ */
400
+ export type MarkAsReadParams<T = Record<string, any>> = {
401
+ /**
402
+ * The ID(s) of the message(s) to mark
403
+ */
404
+ MessageIDs: string[];
405
+ /**
406
+ * Whether to mark as read (true) or unread (false)
407
+ */
408
+ IsRead: boolean;
409
+ /**
410
+ * Optional, provider-specific context data
411
+ */
412
+ ContextData?: T;
413
+ };
414
+ /**
415
+ * Result of marking message(s) as read/unread
416
+ */
417
+ export type MarkAsReadResult<T = Record<string, any>> = BaseMessageResult & {
418
+ /**
419
+ * If populated, holds provider-specific result data
420
+ */
421
+ Result?: T;
422
+ };
423
+ /**
424
+ * Parameters for archiving a message
425
+ */
426
+ export type ArchiveMessageParams<T = Record<string, any>> = {
427
+ /**
428
+ * The ID of the message to archive
429
+ */
430
+ MessageID: string;
431
+ /**
432
+ * Optional, provider-specific context data
433
+ */
434
+ ContextData?: T;
435
+ };
436
+ /**
437
+ * Result of archiving a message
438
+ */
439
+ export type ArchiveMessageResult<T = Record<string, any>> = BaseMessageResult & {
440
+ /**
441
+ * If populated, holds provider-specific result data
442
+ */
443
+ Result?: T;
444
+ };
445
+ /**
446
+ * Parameters for searching messages
447
+ */
448
+ export type SearchMessagesParams<T = Record<string, any>> = {
449
+ /**
450
+ * The search query string
451
+ */
452
+ Query: string;
453
+ /**
454
+ * Maximum number of results to return
455
+ */
456
+ MaxResults?: number;
457
+ /**
458
+ * Optional folder ID to limit search scope
459
+ */
460
+ FolderID?: string;
461
+ /**
462
+ * Optional date range start
463
+ */
464
+ FromDate?: Date;
465
+ /**
466
+ * Optional date range end
467
+ */
468
+ ToDate?: Date;
469
+ /**
470
+ * Optional, search only in specific fields
471
+ */
472
+ SearchIn?: ('subject' | 'body' | 'from' | 'to' | 'all')[];
473
+ /**
474
+ * Optional, provider-specific context data
475
+ */
476
+ ContextData?: T;
477
+ };
478
+ /**
479
+ * Result of searching messages
480
+ */
481
+ export type SearchMessagesResult<T = Record<string, any>> = BaseMessageResult & {
482
+ /**
483
+ * Messages matching the search criteria
484
+ */
485
+ Messages?: GetMessageMessage[];
486
+ /**
487
+ * Total number of matches (may be greater than returned results)
488
+ */
489
+ TotalCount?: number;
490
+ /**
491
+ * If populated, holds provider-specific result data
492
+ */
493
+ SourceData?: T[];
494
+ };
495
+ /**
496
+ * Represents an attachment on a message
497
+ */
498
+ export type MessageAttachment = {
499
+ /**
500
+ * The unique ID of the attachment
501
+ */
502
+ ID: string;
503
+ /**
504
+ * The filename of the attachment
505
+ */
506
+ Filename: string;
507
+ /**
508
+ * The MIME type of the attachment
509
+ */
510
+ ContentType: string;
511
+ /**
512
+ * The size of the attachment in bytes
513
+ */
514
+ Size: number;
515
+ /**
516
+ * Whether this is an inline attachment (embedded in message body)
517
+ */
518
+ IsInline?: boolean;
519
+ /**
520
+ * Content ID for inline attachments
521
+ */
522
+ ContentID?: string;
523
+ };
524
+ /**
525
+ * Parameters for listing attachments on a message
526
+ */
527
+ export type ListAttachmentsParams<T = Record<string, any>> = {
528
+ /**
529
+ * The ID of the message to list attachments for
530
+ */
531
+ MessageID: string;
532
+ /**
533
+ * Optional, provider-specific context data
534
+ */
535
+ ContextData?: T;
536
+ };
537
+ /**
538
+ * Result of listing attachments
539
+ */
540
+ export type ListAttachmentsResult<T = Record<string, any>> = BaseMessageResult & {
541
+ /**
542
+ * The list of attachments
543
+ */
544
+ Attachments?: MessageAttachment[];
545
+ /**
546
+ * If populated, holds provider-specific result data
547
+ */
548
+ Result?: T;
549
+ };
550
+ /**
551
+ * Parameters for downloading an attachment
552
+ */
553
+ export type DownloadAttachmentParams<T = Record<string, any>> = {
554
+ /**
555
+ * The ID of the message containing the attachment
556
+ */
557
+ MessageID: string;
558
+ /**
559
+ * The ID of the attachment to download
560
+ */
561
+ AttachmentID: string;
562
+ /**
563
+ * Optional, provider-specific context data
564
+ */
565
+ ContextData?: T;
566
+ };
567
+ /**
568
+ * Result of downloading an attachment
569
+ */
570
+ export type DownloadAttachmentResult<T = Record<string, any>> = BaseMessageResult & {
571
+ /**
572
+ * The attachment content as a Buffer
573
+ */
574
+ Content?: Buffer;
575
+ /**
576
+ * The attachment content as a base64-encoded string
577
+ */
578
+ ContentBase64?: string;
579
+ /**
580
+ * The filename of the attachment
581
+ */
582
+ Filename?: string;
583
+ /**
584
+ * The MIME type of the attachment
585
+ */
586
+ ContentType?: string;
587
+ /**
588
+ * If populated, holds provider-specific result data
589
+ */
590
+ Result?: T;
591
+ };
592
+ /**
593
+ * Enumeration of all supported provider operations.
594
+ * Use with getSupportedOperations() to discover provider capabilities.
595
+ */
596
+ export type ProviderOperation = 'SendSingleMessage' | 'GetMessages' | 'GetSingleMessage' | 'ForwardMessage' | 'ReplyToMessage' | 'CreateDraft' | 'DeleteMessage' | 'MoveMessage' | 'ListFolders' | 'MarkAsRead' | 'ArchiveMessage' | 'SearchMessages' | 'ListAttachments' | 'DownloadAttachment';
232
597
  /**
233
598
  * Base class for all communication providers. Each provider sub-classes this base class and implements functionality specific to the provider.
599
+ *
600
+ * @remarks
601
+ * All methods accept an optional `credentials` parameter that allows per-request credential overrides.
602
+ * When credentials are provided, they take precedence over environment variables.
603
+ * Set `credentials.disableEnvironmentFallback = true` to disable environment variable fallback.
604
+ *
605
+ * Each provider defines its own credential interface that extends `ProviderCredentialsBase`.
606
+ * For example, `SendGridCredentials`, `MSGraphCredentials`, etc.
607
+ *
608
+ * @example
609
+ * ```typescript
610
+ * // Use environment credentials (default behavior)
611
+ * await provider.SendSingleMessage(message);
612
+ *
613
+ * // Override with request credentials
614
+ * await provider.SendSingleMessage(message, { apiKey: 'SG.xxx' });
615
+ *
616
+ * // Require explicit credentials (no env fallback)
617
+ * await provider.SendSingleMessage(message, {
618
+ * apiKey: 'SG.xxx',
619
+ * disableEnvironmentFallback: true
620
+ * });
621
+ * ```
234
622
  */
235
623
  export declare abstract class BaseCommunicationProvider {
236
624
  /**
237
- *
625
+ * Sends a single message using the provider
626
+ * @param message - The processed message to send
627
+ * @param credentials - Optional credentials override for this request.
628
+ * Provider-specific credential interface (e.g., SendGridCredentials).
629
+ * If not provided, uses environment variables.
630
+ * @returns Promise<MessageResult> - Result of the send operation
238
631
  */
239
- abstract SendSingleMessage(message: ProcessedMessage): Promise<MessageResult>;
632
+ abstract SendSingleMessage(message: ProcessedMessage, credentials?: ProviderCredentialsBase): Promise<MessageResult>;
240
633
  /**
241
634
  * Fetches messages using the provider
635
+ * @param params - Parameters for fetching messages
636
+ * @param credentials - Optional credentials override for this request
637
+ * @returns Promise<GetMessagesResult> - Retrieved messages
242
638
  */
243
- abstract GetMessages(params: GetMessagesParams): Promise<GetMessagesResult>;
639
+ abstract GetMessages(params: GetMessagesParams, credentials?: ProviderCredentialsBase): Promise<GetMessagesResult>;
244
640
  /**
245
641
  * Forwards a message to another client using the provider
642
+ * @param params - Parameters for forwarding the message
643
+ * @param credentials - Optional credentials override for this request
644
+ * @returns Promise<ForwardMessageResult> - Result of the forward operation
246
645
  */
247
- abstract ForwardMessage(params: ForwardMessageParams): Promise<ForwardMessageResult>;
646
+ abstract ForwardMessage(params: ForwardMessageParams, credentials?: ProviderCredentialsBase): Promise<ForwardMessageResult>;
248
647
  /**
249
648
  * Replies to a message using the provider
649
+ * @param params - Parameters for replying to the message
650
+ * @param credentials - Optional credentials override for this request
651
+ * @returns Promise<ReplyToMessageResult> - Result of the reply operation
250
652
  */
251
- abstract ReplyToMessage(params: ReplyToMessageParams): Promise<ReplyToMessageResult>;
653
+ abstract ReplyToMessage(params: ReplyToMessageParams, credentials?: ProviderCredentialsBase): Promise<ReplyToMessageResult>;
252
654
  /**
253
655
  * Creates a draft message using the provider.
254
656
  * Providers that don't support drafts should return Success: false
255
657
  * with an appropriate error message.
256
658
  * @param params - Parameters for creating the draft
659
+ * @param credentials - Optional credentials override for this request
257
660
  * @returns Promise<CreateDraftResult> - Result containing draft ID if successful
258
661
  */
259
- abstract CreateDraft(params: CreateDraftParams): Promise<CreateDraftResult>;
662
+ abstract CreateDraft(params: CreateDraftParams, credentials?: ProviderCredentialsBase): Promise<CreateDraftResult>;
663
+ /**
664
+ * Returns the name of this provider for use in error messages.
665
+ * Override in subclasses to provide a more descriptive name.
666
+ */
667
+ protected get ProviderName(): string;
668
+ /**
669
+ * Returns the list of operations supported by this provider.
670
+ * Override in subclasses to accurately reflect capabilities.
671
+ * Default implementation returns only the core abstract methods.
672
+ */
673
+ getSupportedOperations(): ProviderOperation[];
674
+ /**
675
+ * Checks if this provider supports a specific operation.
676
+ * @param operation - The operation to check
677
+ * @returns true if the operation is supported
678
+ */
679
+ supportsOperation(operation: ProviderOperation): boolean;
680
+ /**
681
+ * Gets a single message by ID.
682
+ * Override in subclasses that support this operation.
683
+ * @param params - Parameters for retrieving the message
684
+ * @param credentials - Optional credentials override for this request
685
+ * @returns Promise<GetSingleMessageResult> - The retrieved message
686
+ */
687
+ GetSingleMessage(params: GetSingleMessageParams, credentials?: ProviderCredentialsBase): Promise<GetSingleMessageResult>;
688
+ /**
689
+ * Deletes a message.
690
+ * Override in subclasses that support this operation.
691
+ * @param params - Parameters for deleting the message
692
+ * @param credentials - Optional credentials override for this request
693
+ * @returns Promise<DeleteMessageResult> - Result of the delete operation
694
+ */
695
+ DeleteMessage(params: DeleteMessageParams, credentials?: ProviderCredentialsBase): Promise<DeleteMessageResult>;
696
+ /**
697
+ * Moves a message to a different folder.
698
+ * Override in subclasses that support this operation.
699
+ * @param params - Parameters for moving the message
700
+ * @param credentials - Optional credentials override for this request
701
+ * @returns Promise<MoveMessageResult> - Result of the move operation
702
+ */
703
+ MoveMessage(params: MoveMessageParams, credentials?: ProviderCredentialsBase): Promise<MoveMessageResult>;
704
+ /**
705
+ * Lists folders/mailboxes available in the provider.
706
+ * Override in subclasses that support this operation.
707
+ * @param params - Parameters for listing folders
708
+ * @param credentials - Optional credentials override for this request
709
+ * @returns Promise<ListFoldersResult> - The list of folders
710
+ */
711
+ ListFolders(params: ListFoldersParams, credentials?: ProviderCredentialsBase): Promise<ListFoldersResult>;
712
+ /**
713
+ * Marks message(s) as read or unread.
714
+ * Override in subclasses that support this operation.
715
+ * @param params - Parameters for marking messages
716
+ * @param credentials - Optional credentials override for this request
717
+ * @returns Promise<MarkAsReadResult> - Result of the operation
718
+ */
719
+ MarkAsRead(params: MarkAsReadParams, credentials?: ProviderCredentialsBase): Promise<MarkAsReadResult>;
720
+ /**
721
+ * Archives a message.
722
+ * Override in subclasses that support this operation.
723
+ * @param params - Parameters for archiving the message
724
+ * @param credentials - Optional credentials override for this request
725
+ * @returns Promise<ArchiveMessageResult> - Result of the archive operation
726
+ */
727
+ ArchiveMessage(params: ArchiveMessageParams, credentials?: ProviderCredentialsBase): Promise<ArchiveMessageResult>;
728
+ /**
729
+ * Searches messages using a query string.
730
+ * Override in subclasses that support this operation.
731
+ * @param params - Parameters for searching messages
732
+ * @param credentials - Optional credentials override for this request
733
+ * @returns Promise<SearchMessagesResult> - Messages matching the search criteria
734
+ */
735
+ SearchMessages(params: SearchMessagesParams, credentials?: ProviderCredentialsBase): Promise<SearchMessagesResult>;
736
+ /**
737
+ * Lists attachments on a message.
738
+ * Override in subclasses that support this operation.
739
+ * @param params - Parameters for listing attachments
740
+ * @param credentials - Optional credentials override for this request
741
+ * @returns Promise<ListAttachmentsResult> - The list of attachments
742
+ */
743
+ ListAttachments(params: ListAttachmentsParams, credentials?: ProviderCredentialsBase): Promise<ListAttachmentsResult>;
744
+ /**
745
+ * Downloads an attachment from a message.
746
+ * Override in subclasses that support this operation.
747
+ * @param params - Parameters for downloading the attachment
748
+ * @param credentials - Optional credentials override for this request
749
+ * @returns Promise<DownloadAttachmentResult> - The attachment content
750
+ */
751
+ DownloadAttachment(params: DownloadAttachmentParams, credentials?: ProviderCredentialsBase): Promise<DownloadAttachmentResult>;
260
752
  }
261
753
  export declare class CommunicationProviderEntityExtended extends CommunicationProviderEntity {
262
754
  private _ProviderMessageTypes;
@@ -1 +1 @@
1
- {"version":3,"file":"BaseProvider.d.ts","sourceRoot":"","sources":["../src/BaseProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,2BAA2B,EAAE,sCAAsC,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEpK;;GAEG;AACH,qBAAa,gBAAgB;IACzB;;;OAGG;IACI,EAAE,EAAE,MAAM,CAAC;IAClB;;OAEG;IACI,QAAQ,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACI,WAAW,EAAE,GAAG,CAAC;CAC3B;AAGD;;GAEG;AACH,qBAAa,OAAO;IAChB;;OAEG;IACI,WAAW,EAAE,sCAAsC,CAAC;IAE3D;;;OAGG;IACI,IAAI,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACI,QAAQ,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACI,EAAE,EAAE,MAAM,CAAC;IAElB;;OAEG;IACI,YAAY,CAA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,uBAAuB,GACtC,OAAO,CAAC,mBAAmB,CAAC;IAO/B;;;;;;OAMG;IACU,WAAW,CACpB,MAAM,EAAE,iBAAiB,EACzB,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,iBAAiB,CAAC;IAO7B;;;;;;OAMG;IACU,WAAW,CACpB,MAAM,EAAE,iBAAiB,EACzB,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,iBAAiB,CAAC;IAO7B;;;;;;OAMG;IACU,UAAU,CACnB,MAAM,EAAE,gBAAgB,EACxB,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,gBAAgB,CAAC;IAO5B;;;;;;OAMG;IACU,cAAc,CACvB,MAAM,EAAE,oBAAoB,EAC5B,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,oBAAoB,CAAC;IAOhC;;;;;;OAMG;IACU,cAAc,CACvB,MAAM,EAAE,oBAAoB,EAC5B,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,oBAAoB,CAAC;IAOhC;;;;;;OAMG;IACU,eAAe,CACxB,MAAM,EAAE,qBAAqB,EAC7B,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,qBAAqB,CAAC;IAOjC;;;;;;OAMG;IACU,kBAAkB,CAC3B,MAAM,EAAE,wBAAwB,EAChC,WAAW,CAAC,EAAE,uBAAuB,GACtC,OAAO,CAAC,wBAAwB,CAAC;CAOvC;AAED,qBACa,mCAAoC,SAAQ,2BAA2B;IAChF,OAAO,CAAC,qBAAqB,CAA2C;IACxE,IAAW,YAAY,IAAI,sCAAsC,EAAE,CAElE;IACD,IAAW,YAAY,CAAC,KAAK,EAAE,sCAAsC,EAAE,EAEtE;CACJ"}
@@ -43,8 +43,175 @@ exports.MessageResult = MessageResult;
43
43
  ;
44
44
  /**
45
45
  * Base class for all communication providers. Each provider sub-classes this base class and implements functionality specific to the provider.
46
+ *
47
+ * @remarks
48
+ * All methods accept an optional `credentials` parameter that allows per-request credential overrides.
49
+ * When credentials are provided, they take precedence over environment variables.
50
+ * Set `credentials.disableEnvironmentFallback = true` to disable environment variable fallback.
51
+ *
52
+ * Each provider defines its own credential interface that extends `ProviderCredentialsBase`.
53
+ * For example, `SendGridCredentials`, `MSGraphCredentials`, etc.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Use environment credentials (default behavior)
58
+ * await provider.SendSingleMessage(message);
59
+ *
60
+ * // Override with request credentials
61
+ * await provider.SendSingleMessage(message, { apiKey: 'SG.xxx' });
62
+ *
63
+ * // Require explicit credentials (no env fallback)
64
+ * await provider.SendSingleMessage(message, {
65
+ * apiKey: 'SG.xxx',
66
+ * disableEnvironmentFallback: true
67
+ * });
68
+ * ```
46
69
  */
47
70
  class BaseCommunicationProvider {
71
+ // ========================================================================
72
+ // OPTIONAL OPERATIONS - Override in subclasses to provide implementation
73
+ // Default implementations return "not supported" error
74
+ // ========================================================================
75
+ /**
76
+ * Returns the name of this provider for use in error messages.
77
+ * Override in subclasses to provide a more descriptive name.
78
+ */
79
+ get ProviderName() {
80
+ return this.constructor.name;
81
+ }
82
+ /**
83
+ * Returns the list of operations supported by this provider.
84
+ * Override in subclasses to accurately reflect capabilities.
85
+ * Default implementation returns only the core abstract methods.
86
+ */
87
+ getSupportedOperations() {
88
+ return ['SendSingleMessage', 'GetMessages', 'ForwardMessage', 'ReplyToMessage', 'CreateDraft'];
89
+ }
90
+ /**
91
+ * Checks if this provider supports a specific operation.
92
+ * @param operation - The operation to check
93
+ * @returns true if the operation is supported
94
+ */
95
+ supportsOperation(operation) {
96
+ return this.getSupportedOperations().includes(operation);
97
+ }
98
+ /**
99
+ * Gets a single message by ID.
100
+ * Override in subclasses that support this operation.
101
+ * @param params - Parameters for retrieving the message
102
+ * @param credentials - Optional credentials override for this request
103
+ * @returns Promise<GetSingleMessageResult> - The retrieved message
104
+ */
105
+ async GetSingleMessage(params, credentials) {
106
+ return {
107
+ Success: false,
108
+ ErrorMessage: `${this.ProviderName} does not support GetSingleMessage (MessageID: ${params.MessageID}, credentials provided: ${!!credentials})`
109
+ };
110
+ }
111
+ /**
112
+ * Deletes a message.
113
+ * Override in subclasses that support this operation.
114
+ * @param params - Parameters for deleting the message
115
+ * @param credentials - Optional credentials override for this request
116
+ * @returns Promise<DeleteMessageResult> - Result of the delete operation
117
+ */
118
+ async DeleteMessage(params, credentials) {
119
+ return {
120
+ Success: false,
121
+ ErrorMessage: `${this.ProviderName} does not support DeleteMessage (MessageID: ${params.MessageID}, credentials provided: ${!!credentials})`
122
+ };
123
+ }
124
+ /**
125
+ * Moves a message to a different folder.
126
+ * Override in subclasses that support this operation.
127
+ * @param params - Parameters for moving the message
128
+ * @param credentials - Optional credentials override for this request
129
+ * @returns Promise<MoveMessageResult> - Result of the move operation
130
+ */
131
+ async MoveMessage(params, credentials) {
132
+ return {
133
+ Success: false,
134
+ ErrorMessage: `${this.ProviderName} does not support MoveMessage (MessageID: ${params.MessageID}, DestinationFolderID: ${params.DestinationFolderID}, credentials provided: ${!!credentials})`
135
+ };
136
+ }
137
+ /**
138
+ * Lists folders/mailboxes available in the provider.
139
+ * Override in subclasses that support this operation.
140
+ * @param params - Parameters for listing folders
141
+ * @param credentials - Optional credentials override for this request
142
+ * @returns Promise<ListFoldersResult> - The list of folders
143
+ */
144
+ async ListFolders(params, credentials) {
145
+ return {
146
+ Success: false,
147
+ ErrorMessage: `${this.ProviderName} does not support ListFolders (ParentFolderID: ${params.ParentFolderID || 'root'}, credentials provided: ${!!credentials})`
148
+ };
149
+ }
150
+ /**
151
+ * Marks message(s) as read or unread.
152
+ * Override in subclasses that support this operation.
153
+ * @param params - Parameters for marking messages
154
+ * @param credentials - Optional credentials override for this request
155
+ * @returns Promise<MarkAsReadResult> - Result of the operation
156
+ */
157
+ async MarkAsRead(params, credentials) {
158
+ return {
159
+ Success: false,
160
+ ErrorMessage: `${this.ProviderName} does not support MarkAsRead (MessageIDs: ${params.MessageIDs.length} message(s), IsRead: ${params.IsRead}, credentials provided: ${!!credentials})`
161
+ };
162
+ }
163
+ /**
164
+ * Archives a message.
165
+ * Override in subclasses that support this operation.
166
+ * @param params - Parameters for archiving the message
167
+ * @param credentials - Optional credentials override for this request
168
+ * @returns Promise<ArchiveMessageResult> - Result of the archive operation
169
+ */
170
+ async ArchiveMessage(params, credentials) {
171
+ return {
172
+ Success: false,
173
+ ErrorMessage: `${this.ProviderName} does not support ArchiveMessage (MessageID: ${params.MessageID}, credentials provided: ${!!credentials})`
174
+ };
175
+ }
176
+ /**
177
+ * Searches messages using a query string.
178
+ * Override in subclasses that support this operation.
179
+ * @param params - Parameters for searching messages
180
+ * @param credentials - Optional credentials override for this request
181
+ * @returns Promise<SearchMessagesResult> - Messages matching the search criteria
182
+ */
183
+ async SearchMessages(params, credentials) {
184
+ return {
185
+ Success: false,
186
+ ErrorMessage: `${this.ProviderName} does not support SearchMessages (Query: ${params.Query}, credentials provided: ${!!credentials})`
187
+ };
188
+ }
189
+ /**
190
+ * Lists attachments on a message.
191
+ * Override in subclasses that support this operation.
192
+ * @param params - Parameters for listing attachments
193
+ * @param credentials - Optional credentials override for this request
194
+ * @returns Promise<ListAttachmentsResult> - The list of attachments
195
+ */
196
+ async ListAttachments(params, credentials) {
197
+ return {
198
+ Success: false,
199
+ ErrorMessage: `${this.ProviderName} does not support ListAttachments (MessageID: ${params.MessageID}, credentials provided: ${!!credentials})`
200
+ };
201
+ }
202
+ /**
203
+ * Downloads an attachment from a message.
204
+ * Override in subclasses that support this operation.
205
+ * @param params - Parameters for downloading the attachment
206
+ * @param credentials - Optional credentials override for this request
207
+ * @returns Promise<DownloadAttachmentResult> - The attachment content
208
+ */
209
+ async DownloadAttachment(params, credentials) {
210
+ return {
211
+ Success: false,
212
+ ErrorMessage: `${this.ProviderName} does not support DownloadAttachment (MessageID: ${params.MessageID}, AttachmentID: ${params.AttachmentID}, credentials provided: ${!!credentials})`
213
+ };
214
+ }
48
215
  }
49
216
  exports.BaseCommunicationProvider = BaseCommunicationProvider;
50
217
  let CommunicationProviderEntityExtended = class CommunicationProviderEntityExtended extends core_entities_1.CommunicationProviderEntity {
@@ -1 +1 @@
1
- {"version":3,"file":"BaseProvider.js","sourceRoot":"","sources":["../src/BaseProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA4D;AAC5D,mDAAuD;AACvD,iEAAoK;AAEpK;;GAEG;AACH,MAAa,gBAAgB;CAe5B;AAfD,4CAeC;AAGD;;GAEG;AACH,MAAa,OAAO;IAgFhB,YAAY,QAAkB;QAC1B,yEAAyE;QACzE,IAAI,QAAQ,EAAC,CAAC;YACV,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;CACJ;AAtFD,0BAsFC;AAED;;GAEG;AACH,MAAsB,gBAAiB,SAAQ,OAAO;CAkBrD;AAlBD,4CAkBC;AAED;;GAEG;AACH,MAAa,aAAa;CAKzB;AALD,sCAKC;AAAA,CAAC;AA2IF;;GAEG;AACH,MAAsB,yBAAyB;CA8B9C;AA9BD,8DA8BC;AAGM,IAAM,mCAAmC,GAAzC,MAAM,mCAAoC,SAAQ,2CAA2B;IAEhF,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IACD,IAAW,YAAY,CAAC,KAA+C;QACnE,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC;IACvC,CAAC;CACJ,CAAA;AARY,kFAAmC;8CAAnC,mCAAmC;IAD/C,IAAA,sBAAa,EAAC,iBAAU,EAAE,yBAAyB,CAAC,CAAC,wDAAwD;GACjG,mCAAmC,CAQ/C"}
1
+ {"version":3,"file":"BaseProvider.js","sourceRoot":"","sources":["../src/BaseProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA4D;AAC5D,mDAAuD;AACvD,iEAAoK;AAGpK;;GAEG;AACH,MAAa,gBAAgB;CAe5B;AAfD,4CAeC;AAGD;;GAEG;AACH,MAAa,OAAO;IAgFh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AAC,eAAe,CACxB,MAA6B,EAC7B,WAAqC;QAErC,OAAO;YACH,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,GAAG,IAAI,CAAC,YAAY,iDAAiD,MAAM,CAAC,SAAS,2BAA2B,CAAC,CAAC,WAAW,GAAG;SACjJ,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,kBAAkB,CAC3B,MAAgC,EAChC,WAAqC;QAErC,OAAO;YACH,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,GAAG,IAAI,CAAC,YAAY,oDAAoD,MAAM,CAAC,SAAS,mBAAmB,MAAM,CAAC,YAAY,2BAA2B,CAAC,CAAC,WAAW,GAAG;SAC1L,CAAC;IACN,CAAC;CAEJ;AApPD,8DAoPC;AAGM,IAAM,mCAAmC,GAAzC,MAAM,mCAAoC,SAAQ,2CAA2B;IAEhF,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IACD,IAAW,YAAY,CAAC,KAA+C;QACnE,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC;IACvC,CAAC;CACJ,CAAA;AARY,kFAAmC;8CAAnC,mCAAmC;IAD/C,IAAA,sBAAa,EAAC,iBAAU,EAAE,yBAAyB,CAAC,CAAC,wDAAwD;GACjG,mCAAmC,CAQ/C"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Credential utilities for MemberJunction Communication providers.
3
+ *
4
+ * This module provides interim credential management functionality that allows
5
+ * per-request credential overrides while maintaining backward compatibility
6
+ * with environment variable-based configuration.
7
+ *
8
+ * @module CredentialUtils
9
+ */
10
+ /**
11
+ * Base interface for provider credentials.
12
+ * Each provider extends this with their specific credential fields.
13
+ *
14
+ * @remarks
15
+ * **TEMPORARY INTERFACE**: This interface is an interim solution for the 2.x patch release.
16
+ * In MemberJunction 3.0, this will be replaced by a more comprehensive credential management
17
+ * system with database storage, encryption, and multi-tenancy support. The replacement
18
+ * interface will be located in `@memberjunction/credentials` or `@memberjunction/core`.
19
+ *
20
+ * This interface is designed to be forward-compatible with the 3.0 `CredentialResolutionOptions`
21
+ * system. When migrating to 3.0, credential objects passed using this interface will work
22
+ * with the new system's `directValues` parameter.
23
+ *
24
+ * @see plans/3_0_credentials_design.md for the full 3.0 credential system design
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // Provider-specific credentials extend this base
29
+ * interface SendGridCredentials extends ProviderCredentialsBase {
30
+ * apiKey?: string;
31
+ * }
32
+ *
33
+ * // Usage with fallback enabled (default)
34
+ * await provider.SendSingleMessage(message, { apiKey: 'SG.xxx' });
35
+ *
36
+ * // Usage with fallback disabled
37
+ * await provider.SendSingleMessage(message, {
38
+ * apiKey: 'SG.xxx',
39
+ * disableEnvironmentFallback: true
40
+ * });
41
+ * ```
42
+ */
43
+ export interface ProviderCredentialsBase {
44
+ /**
45
+ * When true, environment variable fallback is DISABLED for this request.
46
+ * If credentials are incomplete and this is true, the request will fail
47
+ * rather than falling back to environment variables.
48
+ *
49
+ * @default false (fallback enabled for backward compatibility)
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // With fallback (default) - uses env var if apiKey not provided
54
+ * await provider.SendSingleMessage(message, {});
55
+ *
56
+ * // Without fallback - fails if apiKey not provided
57
+ * await provider.SendSingleMessage(message, {
58
+ * disableEnvironmentFallback: true
59
+ * });
60
+ * ```
61
+ */
62
+ disableEnvironmentFallback?: boolean;
63
+ }
64
+ /**
65
+ * Resolves a single credential value by checking the request value first,
66
+ * then falling back to the environment value if allowed.
67
+ *
68
+ * @param requestValue - Value provided in the request (takes precedence)
69
+ * @param envValue - Value from environment variable (fallback)
70
+ * @param disableFallback - If true, don't use the environment value
71
+ * @returns The resolved value, or undefined if not available
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const apiKey = resolveCredentialValue(
76
+ * credentials?.apiKey, // From request
77
+ * process.env.SENDGRID_API_KEY, // From environment
78
+ * credentials?.disableEnvironmentFallback ?? false
79
+ * );
80
+ * ```
81
+ */
82
+ export declare function resolveCredentialValue<T>(requestValue: T | undefined, envValue: T | undefined, disableFallback: boolean): T | undefined;
83
+ /**
84
+ * Validates that all required credential fields are present in the resolved credentials.
85
+ * Throws an error if any required fields are missing.
86
+ *
87
+ * @param resolved - Object containing resolved credential values
88
+ * @param requiredFields - Array of field names that must be present
89
+ * @param providerName - Name of the provider (for error messages)
90
+ * @throws Error if any required fields are missing
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const resolved = {
95
+ * apiKey: resolveCredentialValue(creds?.apiKey, envApiKey, disableFallback)
96
+ * };
97
+ *
98
+ * validateRequiredCredentials(resolved, ['apiKey'], 'SendGrid');
99
+ * // Throws: "Missing required credentials for SendGrid: apiKey. Provide in request or set environment variables."
100
+ * ```
101
+ */
102
+ export declare function validateRequiredCredentials(resolved: Record<string, unknown>, requiredFields: string[], providerName: string): void;
103
+ /**
104
+ * Result of credential resolution, tracking where each value came from.
105
+ * Useful for debugging and audit logging.
106
+ *
107
+ * @remarks
108
+ * This interface is designed to be forward-compatible with the 3.0 credential
109
+ * system's `ResolvedCredential` interface.
110
+ */
111
+ export interface CredentialResolutionResult<T extends Record<string, unknown>> {
112
+ /**
113
+ * The resolved credential values
114
+ */
115
+ values: T;
116
+ /**
117
+ * Source of the credentials: 'request', 'environment', or 'mixed'
118
+ */
119
+ source: 'request' | 'environment' | 'mixed';
120
+ /**
121
+ * Which fields came from request vs environment (for debugging)
122
+ */
123
+ fieldSources: Record<keyof T, 'request' | 'environment'>;
124
+ }
125
+ /**
126
+ * Resolves multiple credential fields at once, tracking the source of each value.
127
+ *
128
+ * @param requestCredentials - Credentials provided in the request
129
+ * @param envCredentials - Credentials from environment variables
130
+ * @param fieldNames - Array of field names to resolve
131
+ * @param disableFallback - If true, don't use environment values
132
+ * @returns Resolution result with values and source tracking
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const result = resolveCredentials(
137
+ * credentials,
138
+ * { tenantId: process.env.AZURE_TENANT_ID, clientId: process.env.AZURE_CLIENT_ID },
139
+ * ['tenantId', 'clientId', 'clientSecret'],
140
+ * credentials?.disableEnvironmentFallback ?? false
141
+ * );
142
+ *
143
+ * console.log(result.source); // 'mixed' if some from request, some from env
144
+ * console.log(result.fieldSources); // { tenantId: 'request', clientId: 'environment', ... }
145
+ * ```
146
+ */
147
+ export declare function resolveCredentials<T extends Record<string, unknown>>(requestCredentials: Partial<T> | undefined, envCredentials: Partial<T>, fieldNames: (keyof T)[], disableFallback: boolean): CredentialResolutionResult<Partial<T>>;
148
+ //# sourceMappingURL=CredentialUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialUtils.d.ts","sourceRoot":"","sources":["../src/CredentialUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,uBAAuB;IACpC;;;;;;;;;;;;;;;;;OAiBG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACpC,YAAY,EAAE,CAAC,GAAG,SAAS,EAC3B,QAAQ,EAAE,CAAC,GAAG,SAAS,EACvB,eAAe,EAAE,OAAO,GACzB,CAAC,GAAG,SAAS,CAYf;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,GACrB,IAAI,CAWN;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzE;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;IAEV;;OAEG;IACH,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,OAAO,CAAC;IAE5C;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,CAAC;CAC5D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,EAC1C,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EACvB,eAAe,EAAE,OAAO,GACzB,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAkCxC"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ /**
3
+ * Credential utilities for MemberJunction Communication providers.
4
+ *
5
+ * This module provides interim credential management functionality that allows
6
+ * per-request credential overrides while maintaining backward compatibility
7
+ * with environment variable-based configuration.
8
+ *
9
+ * @module CredentialUtils
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.resolveCredentials = exports.validateRequiredCredentials = exports.resolveCredentialValue = void 0;
13
+ /**
14
+ * Resolves a single credential value by checking the request value first,
15
+ * then falling back to the environment value if allowed.
16
+ *
17
+ * @param requestValue - Value provided in the request (takes precedence)
18
+ * @param envValue - Value from environment variable (fallback)
19
+ * @param disableFallback - If true, don't use the environment value
20
+ * @returns The resolved value, or undefined if not available
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const apiKey = resolveCredentialValue(
25
+ * credentials?.apiKey, // From request
26
+ * process.env.SENDGRID_API_KEY, // From environment
27
+ * credentials?.disableEnvironmentFallback ?? false
28
+ * );
29
+ * ```
30
+ */
31
+ function resolveCredentialValue(requestValue, envValue, disableFallback) {
32
+ // Request value takes precedence if it's a non-empty value
33
+ if (requestValue !== undefined && requestValue !== null && requestValue !== '') {
34
+ return requestValue;
35
+ }
36
+ // Fall back to environment value if allowed
37
+ if (!disableFallback) {
38
+ return envValue;
39
+ }
40
+ return undefined;
41
+ }
42
+ exports.resolveCredentialValue = resolveCredentialValue;
43
+ /**
44
+ * Validates that all required credential fields are present in the resolved credentials.
45
+ * Throws an error if any required fields are missing.
46
+ *
47
+ * @param resolved - Object containing resolved credential values
48
+ * @param requiredFields - Array of field names that must be present
49
+ * @param providerName - Name of the provider (for error messages)
50
+ * @throws Error if any required fields are missing
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const resolved = {
55
+ * apiKey: resolveCredentialValue(creds?.apiKey, envApiKey, disableFallback)
56
+ * };
57
+ *
58
+ * validateRequiredCredentials(resolved, ['apiKey'], 'SendGrid');
59
+ * // Throws: "Missing required credentials for SendGrid: apiKey. Provide in request or set environment variables."
60
+ * ```
61
+ */
62
+ function validateRequiredCredentials(resolved, requiredFields, providerName) {
63
+ const missing = requiredFields.filter(field => resolved[field] === undefined || resolved[field] === null || resolved[field] === '');
64
+ if (missing.length > 0) {
65
+ throw new Error(`Missing required credentials for ${providerName}: ${missing.join(', ')}. ` +
66
+ `Provide in request or set environment variables.`);
67
+ }
68
+ }
69
+ exports.validateRequiredCredentials = validateRequiredCredentials;
70
+ /**
71
+ * Resolves multiple credential fields at once, tracking the source of each value.
72
+ *
73
+ * @param requestCredentials - Credentials provided in the request
74
+ * @param envCredentials - Credentials from environment variables
75
+ * @param fieldNames - Array of field names to resolve
76
+ * @param disableFallback - If true, don't use environment values
77
+ * @returns Resolution result with values and source tracking
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const result = resolveCredentials(
82
+ * credentials,
83
+ * { tenantId: process.env.AZURE_TENANT_ID, clientId: process.env.AZURE_CLIENT_ID },
84
+ * ['tenantId', 'clientId', 'clientSecret'],
85
+ * credentials?.disableEnvironmentFallback ?? false
86
+ * );
87
+ *
88
+ * console.log(result.source); // 'mixed' if some from request, some from env
89
+ * console.log(result.fieldSources); // { tenantId: 'request', clientId: 'environment', ... }
90
+ * ```
91
+ */
92
+ function resolveCredentials(requestCredentials, envCredentials, fieldNames, disableFallback) {
93
+ const values = {};
94
+ const fieldSources = {};
95
+ let hasRequest = false;
96
+ let hasEnv = false;
97
+ for (const field of fieldNames) {
98
+ const requestValue = requestCredentials?.[field];
99
+ const envValue = envCredentials[field];
100
+ // Check if request has a valid value
101
+ const requestHasValue = requestValue !== undefined && requestValue !== null && requestValue !== '';
102
+ const envHasValue = envValue !== undefined && envValue !== null && envValue !== '';
103
+ if (requestHasValue) {
104
+ values[field] = requestValue;
105
+ fieldSources[field] = 'request';
106
+ hasRequest = true;
107
+ }
108
+ else if (envHasValue && !disableFallback) {
109
+ values[field] = envValue;
110
+ fieldSources[field] = 'environment';
111
+ hasEnv = true;
112
+ }
113
+ }
114
+ const source = hasRequest && hasEnv ? 'mixed' :
115
+ hasRequest ? 'request' : 'environment';
116
+ return {
117
+ values,
118
+ source,
119
+ fieldSources: fieldSources
120
+ };
121
+ }
122
+ exports.resolveCredentials = resolveCredentials;
123
+ //# sourceMappingURL=CredentialUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialUtils.js","sourceRoot":"","sources":["../src/CredentialUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAyDH;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CAClC,YAA2B,EAC3B,QAAuB,EACvB,eAAwB;IAExB,2DAA2D;IAC3D,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,EAAE,EAAE,CAAC;QAC7E,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,4CAA4C;IAC5C,IAAI,CAAC,eAAe,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAhBD,wDAgBC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,2BAA2B,CACvC,QAAiC,EACjC,cAAwB,EACxB,YAAoB;IAEpB,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CACjC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AC;YACzC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;YACzB,YAAY,CAAC,KAAe,CAAC,GAAG,aAAa,CAAC;YAC9C,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAChC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;IAEtD,OAAO;QACH,MAAM;QACN,MAAM;QACN,YAAY,EAAE,YAA0D;KAC3E,CAAC;AACN,CAAC;AAvCD,gDAuCC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './BaseEngine';
2
2
  export * from './BaseProvider';
3
+ export * from './CredentialUtils';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // PUBLIC API SURFACE AREA
18
18
  __exportStar(require("./BaseEngine"), exports);
19
19
  __exportStar(require("./BaseProvider"), exports);
20
+ __exportStar(require("./CredentialUtils"), exports);
20
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0BAA0B;AAC1B,+CAA6B;AAC7B,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0BAA0B;AAC1B,+CAA6B;AAC7B,iDAA+B;AAC/B,oDAAkC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/communication-types",
3
- "version": "2.124.0",
3
+ "version": "2.126.0",
4
4
  "description": "MemberJunction: Communication Framework Library Generic Types",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,10 +19,10 @@
19
19
  "typescript": "^5.4.5"
20
20
  },
21
21
  "dependencies": {
22
- "@memberjunction/global": "2.124.0",
23
- "@memberjunction/core": "2.124.0",
24
- "@memberjunction/templates-base-types": "2.124.0",
25
- "@memberjunction/core-entities": "2.124.0",
22
+ "@memberjunction/global": "2.126.0",
23
+ "@memberjunction/core": "2.126.0",
24
+ "@memberjunction/templates-base-types": "2.126.0",
25
+ "@memberjunction/core-entities": "2.126.0",
26
26
  "rxjs": "^7.8.1"
27
27
  },
28
28
  "repository": {