@memberjunction/communication-gmail 3.3.0 → 4.0.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/GmailProvider.d.ts +175 -0
- package/dist/GmailProvider.d.ts.map +1 -0
- package/dist/GmailProvider.js +242 -70
- package/dist/GmailProvider.js.map +1 -1
- package/dist/auth.d.ts +3 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +13 -35
- package/dist/auth.js.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -35
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -19
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { BaseCommunicationProvider, CreateDraftParams, CreateDraftResult, ForwardMessageParams, ForwardMessageResult, GetMessagesParams, GetMessagesResult, MessageResult, ProcessedMessage, ProviderCredentialsBase, ReplyToMessageParams, ReplyToMessageResult, ProviderOperation, GetSingleMessageParams, GetSingleMessageResult, DeleteMessageParams, DeleteMessageResult, MoveMessageParams, MoveMessageResult, ListFoldersParams, ListFoldersResult, MarkAsReadParams, MarkAsReadResult, ArchiveMessageParams, ArchiveMessageResult, SearchMessagesParams, SearchMessagesResult, ListAttachmentsParams, ListAttachmentsResult, DownloadAttachmentParams, DownloadAttachmentResult } from "@memberjunction/communication-types";
|
|
2
|
+
/**
|
|
3
|
+
* Credentials for Gmail provider using OAuth2.
|
|
4
|
+
* Extend ProviderCredentialsBase to support per-request credential override.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* **TEMPORARY INTERFACE**: This interface is part of the interim credential solution for 2.x patch release.
|
|
8
|
+
* In MemberJunction 3.0, this will be integrated with the comprehensive credential management system.
|
|
9
|
+
*/
|
|
10
|
+
export interface GmailCredentials extends ProviderCredentialsBase {
|
|
11
|
+
/** Google OAuth2 Client ID */
|
|
12
|
+
clientId?: string;
|
|
13
|
+
/** Google OAuth2 Client Secret */
|
|
14
|
+
clientSecret?: string;
|
|
15
|
+
/** OAuth2 Redirect URI */
|
|
16
|
+
redirectUri?: string;
|
|
17
|
+
/** OAuth2 Refresh Token */
|
|
18
|
+
refreshToken?: string;
|
|
19
|
+
/** Service account email (optional) */
|
|
20
|
+
serviceAccountEmail?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Implementation of the Gmail provider for sending and receiving messages
|
|
24
|
+
*/
|
|
25
|
+
export declare class GmailProvider extends BaseCommunicationProvider {
|
|
26
|
+
/** Cached Gmail client for environment credentials */
|
|
27
|
+
private envGmailClient;
|
|
28
|
+
/** Cache of Gmail clients for per-request credentials */
|
|
29
|
+
private clientCache;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves credentials by merging request credentials with environment fallback
|
|
32
|
+
*/
|
|
33
|
+
private resolveCredentials;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a Gmail client with the given credentials
|
|
36
|
+
*/
|
|
37
|
+
private createGmailClient;
|
|
38
|
+
/**
|
|
39
|
+
* Gets a Gmail client for the given credentials, using caching for efficiency
|
|
40
|
+
*/
|
|
41
|
+
private getGmailClient;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the authenticated user's email address for a given cached client
|
|
44
|
+
*/
|
|
45
|
+
private getUserEmail;
|
|
46
|
+
/**
|
|
47
|
+
* Encode and format email content for Gmail API
|
|
48
|
+
*/
|
|
49
|
+
private createEmailContent;
|
|
50
|
+
/**
|
|
51
|
+
* Sends a single message using the Gmail API
|
|
52
|
+
* @param message - The message to send
|
|
53
|
+
* @param credentials - Optional credentials override for this request.
|
|
54
|
+
* If not provided, uses environment variables.
|
|
55
|
+
* Set `credentials.disableEnvironmentFallback = true` to require explicit credentials.
|
|
56
|
+
*/
|
|
57
|
+
SendSingleMessage(message: ProcessedMessage, credentials?: GmailCredentials): Promise<MessageResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets messages from Gmail
|
|
60
|
+
* @param params - Parameters for fetching messages
|
|
61
|
+
* @param credentials - Optional credentials override for this request.
|
|
62
|
+
* If not provided, uses environment variables.
|
|
63
|
+
* Set `credentials.disableEnvironmentFallback = true` to require explicit credentials.
|
|
64
|
+
*/
|
|
65
|
+
GetMessages(params: GetMessagesParams, credentials?: GmailCredentials): Promise<GetMessagesResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Reply to a message using Gmail API
|
|
68
|
+
* @param params - Parameters for replying to a message
|
|
69
|
+
* @param credentials - Optional credentials override for this request.
|
|
70
|
+
* If not provided, uses environment variables.
|
|
71
|
+
* Set `credentials.disableEnvironmentFallback = true` to require explicit credentials.
|
|
72
|
+
*/
|
|
73
|
+
ReplyToMessage(params: ReplyToMessageParams, credentials?: GmailCredentials): Promise<ReplyToMessageResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Forward a message using Gmail API
|
|
76
|
+
* @param params - Parameters for forwarding a message
|
|
77
|
+
* @param credentials - Optional credentials override for this request.
|
|
78
|
+
* If not provided, uses environment variables.
|
|
79
|
+
* Set `credentials.disableEnvironmentFallback = true` to require explicit credentials.
|
|
80
|
+
*/
|
|
81
|
+
ForwardMessage(params: ForwardMessageParams, credentials?: GmailCredentials): Promise<ForwardMessageResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Helper to mark a message as read
|
|
84
|
+
*/
|
|
85
|
+
private markMessageAsRead;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a draft message in Gmail
|
|
88
|
+
* @param params - Parameters for creating a draft
|
|
89
|
+
* @param credentials - Optional credentials override for this request.
|
|
90
|
+
* If not provided, uses environment variables.
|
|
91
|
+
* Set `credentials.disableEnvironmentFallback = true` to require explicit credentials.
|
|
92
|
+
*/
|
|
93
|
+
CreateDraft(params: CreateDraftParams, credentials?: GmailCredentials): Promise<CreateDraftResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the list of operations supported by the Gmail provider.
|
|
96
|
+
* Gmail supports all operations through its label-based system.
|
|
97
|
+
*/
|
|
98
|
+
getSupportedOperations(): ProviderOperation[];
|
|
99
|
+
/**
|
|
100
|
+
* Gets a single message by ID
|
|
101
|
+
* @param params - Parameters for retrieving the message
|
|
102
|
+
* @param credentials - Optional credentials override for this request
|
|
103
|
+
*/
|
|
104
|
+
GetSingleMessage(params: GetSingleMessageParams, credentials?: GmailCredentials): Promise<GetSingleMessageResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Deletes a message from Gmail
|
|
107
|
+
* @param params - Parameters for deleting the message
|
|
108
|
+
* @param credentials - Optional credentials override for this request
|
|
109
|
+
*/
|
|
110
|
+
DeleteMessage(params: DeleteMessageParams, credentials?: GmailCredentials): Promise<DeleteMessageResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Moves a message to a different label (Gmail's equivalent of folders)
|
|
113
|
+
* In Gmail, moving is done by adding/removing labels
|
|
114
|
+
* @param params - Parameters for moving the message
|
|
115
|
+
* @param credentials - Optional credentials override for this request
|
|
116
|
+
*/
|
|
117
|
+
MoveMessage(params: MoveMessageParams, credentials?: GmailCredentials): Promise<MoveMessageResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Lists Gmail labels (Gmail's equivalent of folders)
|
|
120
|
+
* @param params - Parameters for listing labels
|
|
121
|
+
* @param credentials - Optional credentials override for this request
|
|
122
|
+
*/
|
|
123
|
+
ListFolders(params: ListFoldersParams, credentials?: GmailCredentials): Promise<ListFoldersResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Marks messages as read or unread
|
|
126
|
+
* @param params - Parameters for marking messages
|
|
127
|
+
* @param credentials - Optional credentials override for this request
|
|
128
|
+
*/
|
|
129
|
+
MarkAsRead(params: MarkAsReadParams, credentials?: GmailCredentials): Promise<MarkAsReadResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Archives a message (removes INBOX label in Gmail)
|
|
132
|
+
* @param params - Parameters for archiving the message
|
|
133
|
+
* @param credentials - Optional credentials override for this request
|
|
134
|
+
*/
|
|
135
|
+
ArchiveMessage(params: ArchiveMessageParams, credentials?: GmailCredentials): Promise<ArchiveMessageResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Searches messages using Gmail's search syntax
|
|
138
|
+
* @param params - Parameters for searching messages
|
|
139
|
+
* @param credentials - Optional credentials override for this request
|
|
140
|
+
*/
|
|
141
|
+
SearchMessages(params: SearchMessagesParams, credentials?: GmailCredentials): Promise<SearchMessagesResult>;
|
|
142
|
+
/**
|
|
143
|
+
* Lists attachments on a message
|
|
144
|
+
* @param params - Parameters for listing attachments
|
|
145
|
+
* @param credentials - Optional credentials override for this request
|
|
146
|
+
*/
|
|
147
|
+
ListAttachments(params: ListAttachmentsParams, credentials?: GmailCredentials): Promise<ListAttachmentsResult>;
|
|
148
|
+
/**
|
|
149
|
+
* Downloads an attachment from a message
|
|
150
|
+
* @param params - Parameters for downloading the attachment
|
|
151
|
+
* @param credentials - Optional credentials override for this request
|
|
152
|
+
*/
|
|
153
|
+
DownloadAttachment(params: DownloadAttachmentParams, credentials?: GmailCredentials): Promise<DownloadAttachmentResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Parses a Gmail message into the standard GetMessageMessage format
|
|
156
|
+
*/
|
|
157
|
+
private parseGmailMessage;
|
|
158
|
+
/**
|
|
159
|
+
* Maps Gmail label IDs to system folder types
|
|
160
|
+
*/
|
|
161
|
+
private mapGmailLabelToSystemFolder;
|
|
162
|
+
/**
|
|
163
|
+
* Formats a date for Gmail search query (YYYY/MM/DD)
|
|
164
|
+
*/
|
|
165
|
+
private formatDateForGmail;
|
|
166
|
+
/**
|
|
167
|
+
* Recursively extracts attachment information from message parts
|
|
168
|
+
*/
|
|
169
|
+
private extractAttachments;
|
|
170
|
+
/**
|
|
171
|
+
* Finds attachment info (filename, content type) by attachment ID
|
|
172
|
+
*/
|
|
173
|
+
private findAttachmentInfo;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=GmailProvider.d.ts.map
|
|
@@ -0,0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