@builderbot/provider-email 1.3.15-alpha.8
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/LICENSE.md +21 -0
- package/README.md +254 -0
- package/dist/email/core.d.ts +77 -0
- package/dist/email/core.d.ts.map +1 -0
- package/dist/email/provider.d.ts +92 -0
- package/dist/email/provider.d.ts.map +1 -0
- package/dist/index.cjs +871 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/interface/email.d.ts +58 -0
- package/dist/interface/email.d.ts.map +1 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/parser.d.ts +71 -0
- package/dist/utils/parser.d.ts.map +1 -0
- package/package.json +51 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { EmailProvider } from './email/provider';
|
|
2
|
+
export { EmailCoreVendor } from './email/core';
|
|
3
|
+
export type { IEmailProviderArgs, ImapConfig, SmtpConfig, EmailBotContext, EmailSendOptions, EmailAttachment, ParsedEmail, EmailVendorEvents, } from './types';
|
|
4
|
+
export type { EmailInterface } from './interface/email';
|
|
5
|
+
export * from './utils';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EACR,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,iBAAiB,GACpB,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { SendOptions, BotContext } from '@builderbot/bot/dist/types';
|
|
2
|
+
import type { EmailBotContext, EmailSendOptions } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the Email Provider
|
|
5
|
+
*/
|
|
6
|
+
export interface EmailInterface {
|
|
7
|
+
/**
|
|
8
|
+
* Send an email with optional media attachment
|
|
9
|
+
* @param to - Recipient email address
|
|
10
|
+
* @param message - Email body content
|
|
11
|
+
* @param mediaPath - Path to media file to attach
|
|
12
|
+
* @param options - Additional email options
|
|
13
|
+
*/
|
|
14
|
+
sendMedia: (to: string, message: string, mediaPath: string, options?: EmailSendOptions) => Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Send an email message
|
|
17
|
+
* @param to - Recipient email address
|
|
18
|
+
* @param message - Email body content
|
|
19
|
+
* @param options - Send options including subject, attachments, etc.
|
|
20
|
+
*/
|
|
21
|
+
sendMessage: (to: string, message: string, options?: SendOptions & EmailSendOptions) => Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Save an attachment from an email to disk
|
|
24
|
+
* @param ctx - Email context with attachments
|
|
25
|
+
* @param options - Save options (path, attachment index)
|
|
26
|
+
*/
|
|
27
|
+
saveFile: (ctx: Partial<EmailBotContext & BotContext>, options?: {
|
|
28
|
+
path?: string;
|
|
29
|
+
attachmentIndex?: number;
|
|
30
|
+
}) => Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Reply to an existing email thread
|
|
33
|
+
* @param ctx - Original email context
|
|
34
|
+
* @param message - Reply message content
|
|
35
|
+
* @param options - Additional email options
|
|
36
|
+
*/
|
|
37
|
+
reply: (ctx: EmailBotContext, message: string, options?: Omit<EmailSendOptions, 'inReplyTo' | 'references'>) => Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Get all attachments from an email
|
|
40
|
+
* @param ctx - Email context
|
|
41
|
+
*/
|
|
42
|
+
getAttachments: (ctx: EmailBotContext) => EmailBotContext['attachments'];
|
|
43
|
+
/**
|
|
44
|
+
* Check if the email is a reply to another email
|
|
45
|
+
* @param ctx - Email context
|
|
46
|
+
*/
|
|
47
|
+
isReply: (ctx: EmailBotContext) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Get the thread ID from an email
|
|
50
|
+
* @param ctx - Email context
|
|
51
|
+
*/
|
|
52
|
+
getThreadId: (ctx: EmailBotContext) => string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Disconnect the email provider
|
|
55
|
+
*/
|
|
56
|
+
disconnect: () => Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/interface/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAEvG;;;;;OAKG;IACH,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,gBAAgB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAEpG;;;;OAIG;IACH,QAAQ,EAAE,CACN,GAAG,EAAE,OAAO,CAAC,eAAe,GAAG,UAAU,CAAC,EAC1C,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,KACpD,OAAO,CAAC,MAAM,CAAC,CAAA;IAEpB;;;;;OAKG;IACH,KAAK,EAAE,CACH,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,YAAY,CAAC,KAC3D,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjB;;;OAGG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,eAAe,CAAC,aAAa,CAAC,CAAA;IAExE;;;OAGG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAA;IAE1C;;;OAGG;IACH,WAAW,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,MAAM,GAAG,SAAS,CAAA;IAEzD;;OAEG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { BotContext, GlobalVendorArgs } from '@builderbot/bot/dist/types';
|
|
2
|
+
/**
|
|
3
|
+
* IMAP server configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface ImapConfig {
|
|
6
|
+
/** IMAP server host (e.g., 'imap.gmail.com') */
|
|
7
|
+
host: string;
|
|
8
|
+
/** IMAP server port (e.g., 993 for SSL) */
|
|
9
|
+
port: number;
|
|
10
|
+
/** Use secure connection (SSL/TLS) */
|
|
11
|
+
secure?: boolean;
|
|
12
|
+
/** Authentication credentials */
|
|
13
|
+
auth: {
|
|
14
|
+
user: string;
|
|
15
|
+
pass: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* SMTP server configuration
|
|
20
|
+
*/
|
|
21
|
+
export interface SmtpConfig {
|
|
22
|
+
/** SMTP server host (e.g., 'smtp.gmail.com') */
|
|
23
|
+
host: string;
|
|
24
|
+
/** SMTP server port (e.g., 465 for SSL, 587 for TLS) */
|
|
25
|
+
port: number;
|
|
26
|
+
/** Use secure connection (SSL/TLS) */
|
|
27
|
+
secure?: boolean;
|
|
28
|
+
/** Authentication credentials */
|
|
29
|
+
auth: {
|
|
30
|
+
user: string;
|
|
31
|
+
pass: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Email provider configuration arguments
|
|
36
|
+
*/
|
|
37
|
+
export interface IEmailProviderArgs extends GlobalVendorArgs {
|
|
38
|
+
/** IMAP server configuration for receiving emails */
|
|
39
|
+
imap: ImapConfig;
|
|
40
|
+
/** SMTP server configuration for sending emails */
|
|
41
|
+
smtp: SmtpConfig;
|
|
42
|
+
/** Mailbox to monitor (default: 'INBOX') */
|
|
43
|
+
mailbox?: string;
|
|
44
|
+
/** Mark emails as read after processing (default: true) */
|
|
45
|
+
markAsRead?: boolean;
|
|
46
|
+
/** From email address for outgoing emails (defaults to imap.auth.user) */
|
|
47
|
+
fromEmail?: string;
|
|
48
|
+
/** From name for outgoing emails */
|
|
49
|
+
fromName?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Email attachment information
|
|
53
|
+
*/
|
|
54
|
+
export interface EmailAttachment {
|
|
55
|
+
/** Attachment filename */
|
|
56
|
+
filename: string;
|
|
57
|
+
/** MIME content type */
|
|
58
|
+
contentType: string;
|
|
59
|
+
/** File size in bytes */
|
|
60
|
+
size: number;
|
|
61
|
+
/** Content ID for inline attachments */
|
|
62
|
+
contentId?: string;
|
|
63
|
+
/** Raw content buffer (available when downloading) */
|
|
64
|
+
content?: Buffer;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Email context extending BotContext
|
|
68
|
+
*/
|
|
69
|
+
export interface EmailBotContext extends BotContext {
|
|
70
|
+
/** Sender's email address */
|
|
71
|
+
from: string;
|
|
72
|
+
/** Sender's display name */
|
|
73
|
+
name: string;
|
|
74
|
+
/** Email body content (plain text preferred, fallback to HTML) */
|
|
75
|
+
body: string;
|
|
76
|
+
/** Email subject line */
|
|
77
|
+
subject: string;
|
|
78
|
+
/** Unique Message-ID header */
|
|
79
|
+
messageId: string;
|
|
80
|
+
/** Thread ID (derived from References header) */
|
|
81
|
+
threadId?: string;
|
|
82
|
+
/** In-Reply-To header value (if this is a reply) */
|
|
83
|
+
inReplyTo?: string;
|
|
84
|
+
/** List of attachments in the email */
|
|
85
|
+
attachments?: EmailAttachment[];
|
|
86
|
+
/** Whether this email is a reply to another email */
|
|
87
|
+
isReply: boolean;
|
|
88
|
+
/** Original HTML content */
|
|
89
|
+
html?: string;
|
|
90
|
+
/** All recipients (To field) */
|
|
91
|
+
to?: string[];
|
|
92
|
+
/** CC recipients */
|
|
93
|
+
cc?: string[];
|
|
94
|
+
/** Email date */
|
|
95
|
+
date?: Date;
|
|
96
|
+
/** Raw email UID from IMAP */
|
|
97
|
+
uid?: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Options for sending emails
|
|
101
|
+
*/
|
|
102
|
+
export interface EmailSendOptions {
|
|
103
|
+
/** Email subject (required for new threads) */
|
|
104
|
+
subject?: string;
|
|
105
|
+
/** CC recipients */
|
|
106
|
+
cc?: string | string[];
|
|
107
|
+
/** BCC recipients */
|
|
108
|
+
bcc?: string | string[];
|
|
109
|
+
/** Reply-To address */
|
|
110
|
+
replyTo?: string;
|
|
111
|
+
/** Attachments to send */
|
|
112
|
+
attachments?: Array<{
|
|
113
|
+
filename: string;
|
|
114
|
+
path?: string;
|
|
115
|
+
content?: Buffer | string;
|
|
116
|
+
contentType?: string;
|
|
117
|
+
}>;
|
|
118
|
+
/** HTML content (alternative to plain text) */
|
|
119
|
+
html?: string;
|
|
120
|
+
/** In-Reply-To header for replies */
|
|
121
|
+
inReplyTo?: string;
|
|
122
|
+
/** References header for thread continuity */
|
|
123
|
+
references?: string | string[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Internal email message structure from IMAP
|
|
127
|
+
*/
|
|
128
|
+
export interface ParsedEmail {
|
|
129
|
+
uid: number;
|
|
130
|
+
messageId: string;
|
|
131
|
+
from: {
|
|
132
|
+
address: string;
|
|
133
|
+
name: string;
|
|
134
|
+
};
|
|
135
|
+
to: Array<{
|
|
136
|
+
address: string;
|
|
137
|
+
name: string;
|
|
138
|
+
}>;
|
|
139
|
+
cc?: Array<{
|
|
140
|
+
address: string;
|
|
141
|
+
name: string;
|
|
142
|
+
}>;
|
|
143
|
+
subject: string;
|
|
144
|
+
text?: string;
|
|
145
|
+
html?: string;
|
|
146
|
+
date: Date;
|
|
147
|
+
inReplyTo?: string;
|
|
148
|
+
references?: string[];
|
|
149
|
+
attachments: EmailAttachment[];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Email vendor events
|
|
153
|
+
*/
|
|
154
|
+
export type EmailVendorEvents = {
|
|
155
|
+
message: [payload: EmailBotContext];
|
|
156
|
+
ready: [];
|
|
157
|
+
auth_failure: [error: Error];
|
|
158
|
+
error: [error: Error];
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE9E;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,iCAAiC;IACjC,IAAI,EAAE;QACF,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;KACf,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,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,CAAC,CAAA;IACF,EAAE,CAAC,EAAE,KAAK,CAAC;QACP,OAAO,EAAE,MAAM,CAAA;QACf,IAAI,EAAE,MAAM,CAAA;KACf,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,EAAE,eAAe,EAAE,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IACnC,KAAK,EAAE,EAAE,CAAA;IACT,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;CACxB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { extractEmailAddress, extractEmailName, isValidEmail, cleanEmail, parseEmailList, formatEmailAddress, htmlToText, isHtml, extractThreadId, isReplySubject, stripReplyPrefix, addReplyPrefix, generateMessageId, parseMimeType, mimeToExtension, } from './parser';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,eAAe,GAClB,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email parsing utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extract email address from a string that might contain name and email
|
|
6
|
+
* e.g., "John Doe <john@example.com>" -> "john@example.com"
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractEmailAddress(input: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Extract name from email string
|
|
11
|
+
* e.g., "John Doe <john@example.com>" -> "John Doe"
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractEmailName(input: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Validate email address format
|
|
16
|
+
*/
|
|
17
|
+
export declare function isValidEmail(email: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Clean and normalize email address
|
|
20
|
+
*/
|
|
21
|
+
export declare function cleanEmail(email: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Parse email list (comma or semicolon separated)
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseEmailList(input: string): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Format email address with optional name
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatEmailAddress(email: string, name?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Extract plain text from HTML email content
|
|
32
|
+
* Basic implementation - strips HTML tags
|
|
33
|
+
*/
|
|
34
|
+
export declare function htmlToText(html: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Check if content is likely HTML
|
|
37
|
+
*/
|
|
38
|
+
export declare function isHtml(content: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Extract thread ID from References or In-Reply-To headers
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractThreadId(references?: string | string[], inReplyTo?: string): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Check if email subject indicates a reply
|
|
45
|
+
*/
|
|
46
|
+
export declare function isReplySubject(subject: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Strip reply prefixes from subject
|
|
49
|
+
*/
|
|
50
|
+
export declare function stripReplyPrefix(subject: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Add reply prefix to subject if not present
|
|
53
|
+
*/
|
|
54
|
+
export declare function addReplyPrefix(subject: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Generate a unique message ID
|
|
57
|
+
*/
|
|
58
|
+
export declare function generateMessageId(domain: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Parse MIME content type
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseMimeType(contentType: string): {
|
|
63
|
+
type: string;
|
|
64
|
+
subtype: string;
|
|
65
|
+
parameters: Record<string, string>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get file extension from MIME type
|
|
69
|
+
*/
|
|
70
|
+
export declare function mimeToExtension(mimeType: string): string;
|
|
71
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/utils/parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAatD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAInD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAOtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuB/C;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG/C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkBtG;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAItD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC,CA4BA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA2BxD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@builderbot/provider-email",
|
|
3
|
+
"version": "1.3.15-alpha.8",
|
|
4
|
+
"description": "Email provider for BuilderBot using IMAP/SMTP",
|
|
5
|
+
"author": "Leifer Mendez <leifer33@gmail.com>",
|
|
6
|
+
"homepage": "https://github.com/codigoencasa/bot-whatsapp#readme",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "dist/index.cjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"files": [
|
|
12
|
+
"./dist/"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/codigoencasa/bot-whatsapp.git"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rimraf dist && rollup --config",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"test:coverage": "jest --coverage",
|
|
22
|
+
"test:watch": "jest --watchAll --coverage"
|
|
23
|
+
},
|
|
24
|
+
"directories": {
|
|
25
|
+
"lib": "dist",
|
|
26
|
+
"test": "__tests__"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/codigoencasa/bot-whatsapp/issues"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@builderbot/bot": "^1.3.15-alpha.8",
|
|
33
|
+
"@jest/globals": "^30.2.0",
|
|
34
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
35
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
36
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
37
|
+
"@types/node": "^24.10.2",
|
|
38
|
+
"@types/nodemailer": "^6.4.17",
|
|
39
|
+
"@types/polka": "^0.5.7",
|
|
40
|
+
"cors": "^2.8.5",
|
|
41
|
+
"rimraf": "^6.1.2",
|
|
42
|
+
"rollup-plugin-typescript2": "^0.36.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"body-parser": "^2.2.1",
|
|
46
|
+
"imapflow": "^1.0.171",
|
|
47
|
+
"mailparser": "^3.7.2",
|
|
48
|
+
"nodemailer": "^6.10.1",
|
|
49
|
+
"polka": "^0.5.2"
|
|
50
|
+
}
|
|
51
|
+
}
|