@parsrun/email 0.1.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/types.js ADDED
@@ -0,0 +1,50 @@
1
+ // src/types.ts
2
+ import {
3
+ type,
4
+ emailAddress,
5
+ emailAttachment,
6
+ sendEmailOptions,
7
+ sendTemplateEmailOptions,
8
+ emailSendResult,
9
+ smtpConfig,
10
+ resendConfig,
11
+ sendgridConfig,
12
+ sesConfig,
13
+ postmarkConfig,
14
+ emailConfig
15
+ } from "@parsrun/types";
16
+ var EmailError = class extends Error {
17
+ constructor(message, code, cause) {
18
+ super(message);
19
+ this.code = code;
20
+ this.cause = cause;
21
+ this.name = "EmailError";
22
+ }
23
+ };
24
+ var EmailErrorCodes = {
25
+ INVALID_CONFIG: "INVALID_CONFIG",
26
+ INVALID_RECIPIENT: "INVALID_RECIPIENT",
27
+ INVALID_CONTENT: "INVALID_CONTENT",
28
+ SEND_FAILED: "SEND_FAILED",
29
+ RATE_LIMITED: "RATE_LIMITED",
30
+ PROVIDER_ERROR: "PROVIDER_ERROR",
31
+ TEMPLATE_ERROR: "TEMPLATE_ERROR",
32
+ ATTACHMENT_ERROR: "ATTACHMENT_ERROR"
33
+ };
34
+ export {
35
+ EmailError,
36
+ EmailErrorCodes,
37
+ emailAddress,
38
+ emailAttachment,
39
+ emailConfig,
40
+ emailSendResult,
41
+ postmarkConfig,
42
+ resendConfig,
43
+ sendEmailOptions,
44
+ sendTemplateEmailOptions,
45
+ sendgridConfig,
46
+ sesConfig,
47
+ smtpConfig,
48
+ type
49
+ };
50
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @parsrun/email - Type Definitions\n * Email types and interfaces\n */\n\n// Re-export types from @parsrun/types for convenience\nexport {\n type,\n emailAddress,\n emailAttachment,\n sendEmailOptions,\n sendTemplateEmailOptions,\n emailSendResult,\n smtpConfig,\n resendConfig,\n sendgridConfig,\n sesConfig,\n postmarkConfig,\n emailConfig,\n type EmailAddress as ParsEmailAddress,\n type EmailAttachment as ParsEmailAttachment,\n type SendEmailOptions,\n type SendTemplateEmailOptions,\n type EmailSendResult,\n type SmtpConfig,\n type ResendConfig,\n type SendgridConfig,\n type SesConfig,\n type PostmarkConfig,\n type EmailConfig,\n} from \"@parsrun/types\";\n\n/**\n * Email provider type\n */\nexport type EmailProviderType = \"resend\" | \"sendgrid\" | \"postmark\" | \"ses\" | \"console\" | \"mailgun\";\n\n/**\n * Email address with optional name\n */\nexport interface EmailAddress {\n email: string;\n name?: string | undefined;\n}\n\n/**\n * Email attachment\n */\nexport interface EmailAttachment {\n /** File name */\n filename: string;\n /** File content (base64 encoded or Buffer) */\n content: string | Uint8Array;\n /** Content type (MIME type) */\n contentType?: string | undefined;\n /** Content ID for inline attachments */\n contentId?: string | undefined;\n}\n\n/**\n * Email options\n */\nexport interface EmailOptions {\n /** Recipient email address(es) */\n to: string | string[] | EmailAddress | EmailAddress[];\n /** Email subject */\n subject: string;\n /** HTML content */\n html?: string | undefined;\n /** Plain text content */\n text?: string | undefined;\n /** From address (overrides default) */\n from?: string | EmailAddress | undefined;\n /** Reply-to address */\n replyTo?: string | EmailAddress | undefined;\n /** CC recipients */\n cc?: string | string[] | EmailAddress | EmailAddress[] | undefined;\n /** BCC recipients */\n bcc?: string | string[] | EmailAddress | EmailAddress[] | undefined;\n /** Attachments */\n attachments?: EmailAttachment[] | undefined;\n /** Custom headers */\n headers?: Record<string, string> | undefined;\n /** Tags for tracking */\n tags?: Record<string, string> | undefined;\n /** Schedule send time */\n scheduledAt?: Date | undefined;\n}\n\n/**\n * Email send result\n */\nexport interface EmailResult {\n /** Whether send was successful */\n success: boolean;\n /** Message ID from provider */\n messageId?: string | undefined;\n /** Error message if failed */\n error?: string | undefined;\n /** Provider-specific response data */\n data?: unknown;\n}\n\n/**\n * Batch email options\n */\nexport interface BatchEmailOptions {\n /** List of emails to send */\n emails: EmailOptions[];\n /** Whether to stop on first error */\n stopOnError?: boolean | undefined;\n}\n\n/**\n * Batch email result\n */\nexport interface BatchEmailResult {\n /** Total emails attempted */\n total: number;\n /** Successful sends */\n successful: number;\n /** Failed sends */\n failed: number;\n /** Individual results */\n results: EmailResult[];\n}\n\n/**\n * Email provider configuration\n */\nexport interface EmailProviderConfig {\n /** API key for the provider */\n apiKey: string;\n /** Default from email */\n fromEmail: string;\n /** Default from name */\n fromName?: string | undefined;\n /** Provider-specific options */\n options?: Record<string, unknown> | undefined;\n}\n\n/**\n * Email provider interface\n */\nexport interface EmailProvider {\n /** Provider type */\n readonly type: EmailProviderType;\n\n /**\n * Send a single email\n */\n send(options: EmailOptions): Promise<EmailResult>;\n\n /**\n * Send multiple emails\n */\n sendBatch?(options: BatchEmailOptions): Promise<BatchEmailResult>;\n\n /**\n * Verify provider configuration\n */\n verify?(): Promise<boolean>;\n}\n\n/**\n * Email service configuration\n */\nexport interface EmailServiceConfig {\n /** Provider type */\n provider: EmailProviderType;\n /** API key */\n apiKey: string;\n /** Default from email */\n fromEmail: string;\n /** Default from name */\n fromName?: string | undefined;\n /** Enable debug logging */\n debug?: boolean | undefined;\n /** Provider-specific options */\n providerOptions?: Record<string, unknown> | undefined;\n}\n\n/**\n * Template data for email templates\n */\nexport interface TemplateData {\n [key: string]: string | number | boolean | undefined | null | TemplateData | TemplateData[];\n}\n\n/**\n * Email template\n */\nexport interface EmailTemplate {\n /** Template name */\n name: string;\n /** Subject template */\n subject: string;\n /** HTML template */\n html: string;\n /** Plain text template */\n text?: string | undefined;\n}\n\n/**\n * Email error\n */\nexport class EmailError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly cause?: unknown\n ) {\n super(message);\n this.name = \"EmailError\";\n }\n}\n\n/**\n * Common email error codes\n */\nexport const EmailErrorCodes = {\n INVALID_CONFIG: \"INVALID_CONFIG\",\n INVALID_RECIPIENT: \"INVALID_RECIPIENT\",\n INVALID_CONTENT: \"INVALID_CONTENT\",\n SEND_FAILED: \"SEND_FAILED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n PROVIDER_ERROR: \"PROVIDER_ERROR\",\n TEMPLATE_ERROR: \"TEMPLATE_ERROR\",\n ATTACHMENT_ERROR: \"ATTACHMENT_ERROR\",\n} as const;\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAYK;AAgLA,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YACE,SACgB,MACA,OAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,kBAAkB;AAAA,EAC7B,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,kBAAkB;AACpB;","names":[]}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@parsrun/email",
3
+ "version": "0.1.0",
4
+ "description": "Edge-compatible email sending for Pars - Resend, SendGrid, Postmark, AWS SES",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./types": {
15
+ "types": "./dist/types.d.ts",
16
+ "import": "./dist/types.js"
17
+ },
18
+ "./providers": {
19
+ "types": "./dist/providers/index.d.ts",
20
+ "import": "./dist/providers/index.js"
21
+ },
22
+ "./providers/resend": {
23
+ "types": "./dist/providers/resend.d.ts",
24
+ "import": "./dist/providers/resend.js"
25
+ },
26
+ "./providers/sendgrid": {
27
+ "types": "./dist/providers/sendgrid.d.ts",
28
+ "import": "./dist/providers/sendgrid.js"
29
+ },
30
+ "./providers/postmark": {
31
+ "types": "./dist/providers/postmark.d.ts",
32
+ "import": "./dist/providers/postmark.js"
33
+ },
34
+ "./providers/console": {
35
+ "types": "./dist/providers/console.d.ts",
36
+ "import": "./dist/providers/console.js"
37
+ },
38
+ "./templates": {
39
+ "types": "./dist/templates/index.d.ts",
40
+ "import": "./dist/templates/index.js"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md"
46
+ ],
47
+ "scripts": {
48
+ "build": "tsup",
49
+ "dev": "tsup --watch",
50
+ "test": "vitest run",
51
+ "typecheck": "tsc --noEmit"
52
+ },
53
+ "keywords": [
54
+ "email",
55
+ "resend",
56
+ "sendgrid",
57
+ "postmark",
58
+ "edge",
59
+ "pars"
60
+ ],
61
+ "author": "EMS Tech Solutions",
62
+ "license": "MIT",
63
+ "dependencies": {
64
+ "@parsrun/core": "workspace:*",
65
+ "@parsrun/types": "workspace:*"
66
+ },
67
+ "devDependencies": {
68
+ "tsup": "^8.0.0",
69
+ "typescript": "^5.0.0",
70
+ "vitest": "^2.0.0"
71
+ },
72
+ "peerDependencies": {
73
+ "resend": "^4.0.0"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "resend": {
77
+ "optional": true
78
+ }
79
+ }
80
+ }