@geekmidas/emailkit 0.0.3 → 0.0.5

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.
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,18 @@
1
+ import { EmailClient, EmailClientConfig, EmailOptions, SendOptions, SendResult, TemplateNames, TemplatePropsFor, TemplateRecord } from "./types-DSf2ldGX.mjs";
2
+
3
+ //#region src/client.d.ts
4
+ declare class SMTPClient<T extends TemplateRecord> implements EmailClient<T> {
5
+ private transporter;
6
+ private config;
7
+ constructor(config: EmailClientConfig<T>);
8
+ send(options: SendOptions): Promise<SendResult>;
9
+ sendTemplate<K extends TemplateNames<T>>(template: K, options: Omit<EmailOptions, 'template'> & {
10
+ props: TemplatePropsFor<T, K>;
11
+ }): Promise<SendResult>;
12
+ verify(): Promise<boolean>;
13
+ close(): Promise<void>;
14
+ getTemplateNames(): TemplateNames<T>[];
15
+ }
16
+ declare function createEmailClient<T extends TemplateRecord>(config: EmailClientConfig<T>): SMTPClient<T>;
17
+ //#endregion
18
+ export { SMTPClient, createEmailClient };
@@ -0,0 +1,18 @@
1
+ import { EmailClient, EmailClientConfig, EmailOptions, SendOptions, SendResult, TemplateNames, TemplatePropsFor, TemplateRecord } from "./types-BQX9cJo1.cjs";
2
+
3
+ //#region src/client.d.ts
4
+ declare class SMTPClient<T extends TemplateRecord> implements EmailClient<T> {
5
+ private transporter;
6
+ private config;
7
+ constructor(config: EmailClientConfig<T>);
8
+ send(options: SendOptions): Promise<SendResult>;
9
+ sendTemplate<K extends TemplateNames<T>>(template: K, options: Omit<EmailOptions, 'template'> & {
10
+ props: TemplatePropsFor<T, K>;
11
+ }): Promise<SendResult>;
12
+ verify(): Promise<boolean>;
13
+ close(): Promise<void>;
14
+ getTemplateNames(): TemplateNames<T>[];
15
+ }
16
+ declare function createEmailClient<T extends TemplateRecord>(config: EmailClientConfig<T>): SMTPClient<T>;
17
+ //#endregion
18
+ export { SMTPClient, createEmailClient };
@@ -0,0 +1,3 @@
1
+ import "./types-BQX9cJo1.cjs";
2
+ import { SMTPClient, createEmailClient } from "./client-Dm7WOF9y.cjs";
3
+ export { SMTPClient, createEmailClient };
@@ -0,0 +1,3 @@
1
+ import "./types-DSf2ldGX.mjs";
2
+ import { SMTPClient, createEmailClient } from "./client-CEgPwECo.mjs";
3
+ export { SMTPClient, createEmailClient };
@@ -0,0 +1,3 @@
1
+ import { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendResult } from "./types-BQX9cJo1.cjs";
2
+ import { SMTPClient, createEmailClient } from "./client-Dm7WOF9y.cjs";
3
+ export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPClient, SMTPConfig, SendResult, createEmailClient };
@@ -0,0 +1,3 @@
1
+ import { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendResult } from "./types-DSf2ldGX.mjs";
2
+ import { SMTPClient, createEmailClient } from "./client-CEgPwECo.mjs";
3
+ export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPClient, SMTPConfig, SendResult, createEmailClient };
@@ -0,0 +1,78 @@
1
+ import { Address } from "nodemailer/lib/mailer";
2
+ import { ReactElement } from "react";
3
+
4
+ //#region src/types.d.ts
5
+ interface EmailOptions {
6
+ from: string | Address;
7
+ to: string | string[] | Address[];
8
+ cc?: string | string[] | Address[];
9
+ bcc?: string | string[] | Address[];
10
+ subject: string;
11
+ replyTo?: string | Address;
12
+ attachments?: Attachment[];
13
+ }
14
+ interface Attachment {
15
+ filename: string;
16
+ content?: string | Buffer;
17
+ path?: string;
18
+ contentType?: string;
19
+ cid?: string;
20
+ }
21
+ interface PlainEmailOptions extends EmailOptions {
22
+ text?: string;
23
+ html?: string;
24
+ }
25
+ type SendOptions = Omit<PlainEmailOptions, 'from'> & {
26
+ from?: string | Address;
27
+ };
28
+ interface SMTPConfig {
29
+ host: string;
30
+ port: number;
31
+ secure?: boolean;
32
+ auth?: {
33
+ user: string;
34
+ pass: string;
35
+ };
36
+ tls?: {
37
+ rejectUnauthorized?: boolean;
38
+ servername?: string;
39
+ };
40
+ pool?: boolean;
41
+ maxConnections?: number;
42
+ maxMessages?: number;
43
+ rateLimit?: number;
44
+ logger?: boolean;
45
+ debug?: boolean;
46
+ }
47
+ interface SendResult {
48
+ messageId: string;
49
+ accepted: string[];
50
+ rejected: string[];
51
+ response: string;
52
+ }
53
+ interface EmailTemplate<T = any> {
54
+ (props: T): ReactElement;
55
+ }
56
+ type TemplateProps<T> = T extends EmailTemplate<infer P> ? P : never;
57
+ type TemplateRecord = Record<string, EmailTemplate<any>>;
58
+ type TemplateNames<T extends TemplateRecord> = keyof T;
59
+ type TemplatePropsFor<T extends TemplateRecord, K extends TemplateNames<T>> = TemplateProps<T[K]>;
60
+ interface EmailClientConfig<T extends TemplateRecord = TemplateRecord> {
61
+ smtp: SMTPConfig;
62
+ templates: T;
63
+ defaults: {
64
+ from?: string | Address;
65
+ replyTo?: string | Address;
66
+ };
67
+ }
68
+ interface EmailClient<T extends TemplateRecord = TemplateRecord> {
69
+ send(options: SendOptions): Promise<SendResult>;
70
+ sendTemplate<K extends TemplateNames<T>>(template: K, options: Omit<EmailOptions, 'from'> & {
71
+ from?: string | Address;
72
+ props: TemplatePropsFor<T, K>;
73
+ }): Promise<SendResult>;
74
+ verify(): Promise<boolean>;
75
+ close(): Promise<void>;
76
+ }
77
+ //#endregion
78
+ export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord };
@@ -0,0 +1,78 @@
1
+ import { ReactElement } from "react";
2
+ import { Address } from "nodemailer/lib/mailer";
3
+
4
+ //#region src/types.d.ts
5
+ interface EmailOptions {
6
+ from: string | Address;
7
+ to: string | string[] | Address[];
8
+ cc?: string | string[] | Address[];
9
+ bcc?: string | string[] | Address[];
10
+ subject: string;
11
+ replyTo?: string | Address;
12
+ attachments?: Attachment[];
13
+ }
14
+ interface Attachment {
15
+ filename: string;
16
+ content?: string | Buffer;
17
+ path?: string;
18
+ contentType?: string;
19
+ cid?: string;
20
+ }
21
+ interface PlainEmailOptions extends EmailOptions {
22
+ text?: string;
23
+ html?: string;
24
+ }
25
+ type SendOptions = Omit<PlainEmailOptions, 'from'> & {
26
+ from?: string | Address;
27
+ };
28
+ interface SMTPConfig {
29
+ host: string;
30
+ port: number;
31
+ secure?: boolean;
32
+ auth?: {
33
+ user: string;
34
+ pass: string;
35
+ };
36
+ tls?: {
37
+ rejectUnauthorized?: boolean;
38
+ servername?: string;
39
+ };
40
+ pool?: boolean;
41
+ maxConnections?: number;
42
+ maxMessages?: number;
43
+ rateLimit?: number;
44
+ logger?: boolean;
45
+ debug?: boolean;
46
+ }
47
+ interface SendResult {
48
+ messageId: string;
49
+ accepted: string[];
50
+ rejected: string[];
51
+ response: string;
52
+ }
53
+ interface EmailTemplate<T = any> {
54
+ (props: T): ReactElement;
55
+ }
56
+ type TemplateProps<T> = T extends EmailTemplate<infer P> ? P : never;
57
+ type TemplateRecord = Record<string, EmailTemplate<any>>;
58
+ type TemplateNames<T extends TemplateRecord> = keyof T;
59
+ type TemplatePropsFor<T extends TemplateRecord, K extends TemplateNames<T>> = TemplateProps<T[K]>;
60
+ interface EmailClientConfig<T extends TemplateRecord = TemplateRecord> {
61
+ smtp: SMTPConfig;
62
+ templates: T;
63
+ defaults: {
64
+ from?: string | Address;
65
+ replyTo?: string | Address;
66
+ };
67
+ }
68
+ interface EmailClient<T extends TemplateRecord = TemplateRecord> {
69
+ send(options: SendOptions): Promise<SendResult>;
70
+ sendTemplate<K extends TemplateNames<T>>(template: K, options: Omit<EmailOptions, 'from'> & {
71
+ from?: string | Address;
72
+ props: TemplatePropsFor<T, K>;
73
+ }): Promise<SendResult>;
74
+ verify(): Promise<boolean>;
75
+ close(): Promise<void>;
76
+ }
77
+ //#endregion
78
+ export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord };
@@ -0,0 +1,2 @@
1
+ import { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord } from "./types-BQX9cJo1.cjs";
2
+ export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord };
@@ -0,0 +1,2 @@
1
+ import { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord } from "./types-DSf2ldGX.mjs";
2
+ export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@geekmidas/emailkit",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Type-safe email client with SMTP support and React templates",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
8
8
  "./*": {
9
+ "types": "./dist/*.d.ts",
9
10
  "import": "./dist/*.mjs",
10
- "require": "./dist/*.cjs",
11
- "types": "./src/*.ts"
11
+ "require": "./dist/*.cjs"
12
12
  }
13
13
  },
14
14
  "publishConfig": {
@@ -16,9 +16,7 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "nodemailer": "^6.9.7",
20
- "react": "~19.1.0",
21
- "react-dom": "~19.1.0"
19
+ "nodemailer": "^6.9.7"
22
20
  },
23
21
  "devDependencies": {
24
22
  "@types/node": "^22.0.0",
@@ -30,8 +28,8 @@
30
28
  "vitest": "^2.1.8"
31
29
  },
32
30
  "peerDependencies": {
33
- "react": ">=16.8.0",
34
- "react-dom": ">=16.8.0"
31
+ "react": ">=18.0.0",
32
+ "react-dom": ">=18.0.0"
35
33
  },
36
34
  "engines": {
37
35
  "node": ">=22.0.0"