@bernierllc/email 1.0.1 → 1.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.
Files changed (65) hide show
  1. package/README.md +76 -217
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +28 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/simple-email-service.d.ts +58 -0
  7. package/dist/simple-email-service.d.ts.map +1 -0
  8. package/dist/simple-email-service.js +416 -0
  9. package/dist/simple-email-service.js.map +1 -0
  10. package/dist/types.d.ts +311 -0
  11. package/dist/types.d.ts.map +1 -0
  12. package/dist/types.js +33 -0
  13. package/dist/types.js.map +1 -0
  14. package/package.json +53 -22
  15. package/.eslintrc.json +0 -112
  16. package/.flake8 +0 -18
  17. package/.github/workflows/ci.yml +0 -300
  18. package/EXTRACTION_SUMMARY.md +0 -265
  19. package/IMPLEMENTATION_STATUS.md +0 -159
  20. package/OPEN_SOURCE_SETUP.md +0 -420
  21. package/PACKAGE_USAGE.md +0 -471
  22. package/examples/fastapi-example/main.py +0 -257
  23. package/examples/nextjs-example/next-env.d.ts +0 -13
  24. package/examples/nextjs-example/package.json +0 -26
  25. package/examples/nextjs-example/pages/admin/templates.tsx +0 -157
  26. package/examples/nextjs-example/tsconfig.json +0 -28
  27. package/packages/core/package.json +0 -70
  28. package/packages/core/rollup.config.js +0 -37
  29. package/packages/core/specification.md +0 -416
  30. package/packages/core/src/adapters/supabase.ts +0 -291
  31. package/packages/core/src/core/scheduler.ts +0 -356
  32. package/packages/core/src/core/template-manager.ts +0 -388
  33. package/packages/core/src/index.ts +0 -30
  34. package/packages/core/src/providers/base.ts +0 -104
  35. package/packages/core/src/providers/sendgrid.ts +0 -368
  36. package/packages/core/src/types/provider.ts +0 -91
  37. package/packages/core/src/types/scheduled.ts +0 -78
  38. package/packages/core/src/types/template.ts +0 -97
  39. package/packages/core/tsconfig.json +0 -23
  40. package/packages/python/README.md +0 -106
  41. package/packages/python/email_template_manager/__init__.py +0 -66
  42. package/packages/python/email_template_manager/config.py +0 -98
  43. package/packages/python/email_template_manager/core/magic_links.py +0 -245
  44. package/packages/python/email_template_manager/core/manager.py +0 -344
  45. package/packages/python/email_template_manager/core/scheduler.py +0 -473
  46. package/packages/python/email_template_manager/exceptions.py +0 -67
  47. package/packages/python/email_template_manager/models/magic_link.py +0 -59
  48. package/packages/python/email_template_manager/models/scheduled.py +0 -78
  49. package/packages/python/email_template_manager/models/template.py +0 -90
  50. package/packages/python/email_template_manager/providers/aws_ses.py +0 -44
  51. package/packages/python/email_template_manager/providers/base.py +0 -94
  52. package/packages/python/email_template_manager/providers/sendgrid.py +0 -325
  53. package/packages/python/email_template_manager/providers/smtp.py +0 -44
  54. package/packages/python/pyproject.toml +0 -133
  55. package/packages/python/setup.py +0 -93
  56. package/packages/python/specification.md +0 -930
  57. package/packages/react/README.md +0 -13
  58. package/packages/react/package.json +0 -105
  59. package/packages/react/rollup.config.js +0 -37
  60. package/packages/react/specification.md +0 -569
  61. package/packages/react/src/index.ts +0 -20
  62. package/packages/react/tsconfig.json +0 -24
  63. package/plans/email-template-manager_app-admin.md +0 -590
  64. package/src/index.js +0 -1
  65. package/test_package.py +0 -125
package/README.md CHANGED
@@ -1,232 +1,91 @@
1
- # Email Template Manager - Universal Email Management Component
1
+ # @bernierllc/email
2
2
 
3
- ## Overview
3
+ > **⚠️ DEPRECATED**: This package is deprecated as of v1.1.0. Please migrate to **[@bernierllc/email-service](../email-service)** for continued support and new features.
4
+ >
5
+ > **Migration Guide**: See [email-service/MIGRATION.md](../email-service/MIGRATION.md) for step-by-step migration instructions.
6
+ >
7
+ > **Why migrate?**
8
+ > - All features from `@bernierllc/email` are available in `@bernierllc/email-service`
9
+ > - Additional production features: database persistence, delivery tracking, subscriber management, webhooks
10
+ > - Active development and support
11
+ >
12
+ > **Timeline**: This package will receive critical bug fixes only. New features will be added to `@bernierllc/email-service`.
4
13
 
5
- A framework-agnostic email management library that provides template creation, scheduling, and delivery capabilities with support for React, Next.js, and Python applications. Extracted from the Event Venue Platform project to serve as a reusable component for any application requiring sophisticated email automation.
14
+ A comprehensive email service that orchestrates sending, templates, authentication, and retry logic using BernierLLC's core packages.
6
15
 
7
- ## Core Features
8
-
9
- ### 🎨 Template Management
10
-
11
- - **Visual Template Editor** - Rich HTML/text editor with live preview
12
- - **Liquid Template Engine** - Dynamic content with `{{variable}}` syntax
13
- - **Multi-format Support** - HTML and plain text versions
14
- - **Template Versioning** - Track changes and rollback capabilities
15
- - **Theme Support** - Customizable styling per application/tenant
16
-
17
- ### 📅 Email Scheduling
18
-
19
- - **Event-based Triggers** - Schedule emails relative to dates/events
20
- - **Batch Processing** - Queue and send multiple emails efficiently
21
- - **Retry Logic** - Automatic retry with exponential backoff
22
- - **Pause/Resume** - Admin control over scheduled campaigns
23
- - **Delivery Tracking** - Monitor sent, opened, clicked, bounced
24
-
25
- ### 🔐 Authentication & Security
26
-
27
- - **Magic Link Generation** - Secure token-based authentication
28
- - **Token Expiration** - Configurable expiry times
29
- - **One-time Use** - Prevent token reuse
30
- - **Rate Limiting** - Protect against abuse
31
- - **Encryption** - Secure token storage and transmission
32
-
33
- ### 🚀 Multi-platform Support
34
-
35
- - **React Components** - Pre-built UI components for template management
36
- - **Python SDK** - FastAPI/Django integration with ORM models
37
- - **REST API** - Framework-agnostic HTTP interface
38
- - **TypeScript Support** - Full type definitions included
39
- - **Database Agnostic** - Supports PostgreSQL, MySQL, SQLite
40
-
41
- ## Project Structure
42
-
43
- ```
44
- email-template-manager/
45
- ├── packages/
46
- │ ├── core/ # Core TypeScript/JavaScript library
47
- │ ├── react/ # React components and hooks
48
- │ ├── python/ # Python SDK and FastAPI integration
49
- │ └── api/ # Standalone REST API server
50
- ├── examples/
51
- │ ├── nextjs-example/ # Next.js integration example
52
- │ ├── react-example/ # React app example
53
- │ ├── fastapi-example/ # FastAPI backend example
54
- │ └── django-example/ # Django integration example
55
- ├── docs/ # Documentation website
56
- ├── scripts/ # Build and deployment scripts
57
- └── tests/ # End-to-end test suites
58
- ```
59
-
60
- ## Quick Start
61
-
62
- ### npm/yarn Installation
63
-
64
- ```bash
65
- # For React/Next.js projects
66
- npm install @email-template-manager/react
67
- npm install @email-template-manager/core
68
-
69
- # For Node.js backends
70
- npm install @email-template-manager/api
71
- ```
72
-
73
- ### pip Installation
16
+ ## Installation
74
17
 
75
18
  ```bash
76
- # For Python projects
77
- pip install email-template-manager[fastapi]
78
- pip install email-template-manager[django]
19
+ npm install @bernierllc/email
79
20
  ```
80
21
 
81
- ### CDN Usage
82
-
83
- ```html
84
- <!-- For vanilla JavaScript -->
85
- <script src="https://unpkg.com/@email-template-manager/core@latest/dist/index.js"></script>
22
+ ## Usage
23
+
24
+ ```typescript
25
+ import { EmailService } from '@bernierllc/email';
26
+
27
+ const emailService = new EmailService({
28
+ provider: {
29
+ type: 'sendgrid',
30
+ config: {
31
+ apiKey: process.env.SENDGRID_API_KEY
32
+ }
33
+ },
34
+ defaults: {
35
+ from: 'noreply@yourdomain.com',
36
+ replyTo: 'support@yourdomain.com'
37
+ },
38
+ templates: {
39
+ engine: 'liquid',
40
+ templateDir: './email-templates',
41
+ cache: true
42
+ },
43
+ magicLink: {
44
+ secret: process.env.MAGIC_LINK_SECRET,
45
+ expirationMinutes: 60,
46
+ issuer: 'YourApp'
47
+ },
48
+ retry: {
49
+ maxRetries: 3,
50
+ initialDelayMs: 1000,
51
+ maxDelayMs: 30000,
52
+ jitter: true,
53
+ enableMetrics: true
54
+ }
55
+ });
56
+
57
+ // Send a basic email
58
+ const result = await emailService.send({
59
+ to: 'user@example.com',
60
+ subject: 'Welcome!',
61
+ html: '<h1>Welcome to our service!</h1>',
62
+ text: 'Welcome to our service!'
63
+ });
64
+
65
+ console.log('Email sent:', result.success);
86
66
  ```
87
67
 
88
- ## Package Management & Distribution
89
-
90
- ### NPM Packages
91
-
92
- - `@email-template-manager/core` - Core functionality
93
- - `@email-template-manager/react` - React components
94
- - `@email-template-manager/api` - Node.js API server
95
-
96
- ### Python Packages
97
-
98
- - `email-template-manager` - Main Python package
99
- - `email-template-manager[fastapi]` - FastAPI extras
100
- - `email-template-manager[django]` - Django extras
101
-
102
- ### Docker Images
103
-
104
- - `email-template-manager/api` - Standalone API server
105
- - `email-template-manager/worker` - Background job processor
106
-
107
- ## Open Source Setup
108
-
109
- ### Repository Structure
110
-
111
- - **Monorepo** - All packages in single repository with Lerna/Nx
112
- - **MIT License** - Permissive open source license
113
- - **Contributing Guidelines** - Clear contribution process
114
- - **Code of Conduct** - Community standards
115
- - **Issue Templates** - Bug reports and feature requests
116
-
117
- ### Development Tools
68
+ ## Features
118
69
 
119
- - **TypeScript** - Type safety across all packages
120
- - **Jest** - Unit and integration testing
121
- - **ESLint/Prettier** - Code formatting and linting
122
- - **Husky** - Git hooks for quality control
123
- - **Semantic Release** - Automated versioning and publishing
70
+ - Multi-provider email sending (SMTP, SendGrid, SES, Mailgun, Postmark)
71
+ - Template rendering (Liquid/Handlebars)
72
+ - Magic link authentication
73
+ - Reliable delivery with retry logic
74
+ - Performance metrics and analytics
75
+ - Bulk email operations
76
+ - Rate limiting and batch processing
124
77
 
125
- ### CI/CD Pipeline
78
+ ## Dependencies
126
79
 
127
- - **GitHub Actions** - Automated testing and deployment
128
- - **Test Coverage** - Minimum 80% coverage requirement
129
- - **Security Scanning** - Automated vulnerability detection
130
- - **Performance Testing** - Load testing for API endpoints
131
-
132
- ## Supported Integrations
133
-
134
- ### Email Providers
135
-
136
- - **SendGrid** - Primary provider with full feature support
137
- - **AWS SES** - Cost-effective option for high volume
138
- - **Mailgun** - Developer-friendly API
139
- - **Postmark** - Transactional email specialist
140
- - **SMTP** - Generic SMTP server support
141
-
142
- ### Databases
143
-
144
- - **PostgreSQL** - Recommended for production
145
- - **MySQL** - Wide compatibility
146
- - **SQLite** - Development and testing
147
- - **MongoDB** - Document-based storage option
148
-
149
- ### Frontend Frameworks
150
-
151
- - **React** - Full component library
152
- - **Next.js** - SSR and API routes integration
153
- - **Vue.js** - Vue 3 composition API support
154
- - **Angular** - Angular 12+ compatibility
155
- - **Svelte** - Lightweight integration
156
-
157
- ### Backend Frameworks
158
-
159
- - **FastAPI** - Python async framework
160
- - **Django** - Django 3.2+ with admin integration
161
- - **Express.js** - Node.js middleware
162
- - **NestJS** - TypeScript decorators support
163
- - **Spring Boot** - Java integration (community)
164
-
165
- ## Getting Started Checklist
166
-
167
- ### For Package Publishing
168
-
169
- - [ ] Set up NPM organization (`@email-template-manager`)
170
- - [ ] Configure automated publishing with semantic-release
171
- - [ ] Set up PyPI account and package publishing
172
- - [ ] Create Docker Hub organization for container images
173
- - [ ] Set up CDN distribution for browser packages
174
-
175
- ### For Open Source
176
-
177
- - [ ] Create GitHub organization
178
- - [ ] Set up repository with proper README and documentation
179
- - [ ] Configure issue and PR templates
180
- - [ ] Set up community health files (CONTRIBUTING.md, CODE_OF_CONDUCT.md)
181
- - [ ] Enable GitHub Discussions for community support
182
- - [ ] Set up GitHub Sponsors for project sustainability
183
-
184
- ### For Documentation
185
-
186
- - [ ] Create documentation website (Docusaurus/GitBook)
187
- - [ ] Write comprehensive API documentation
188
- - [ ] Create integration guides for each framework
189
- - [ ] Record video tutorials for common use cases
190
- - [ ] Set up interactive playground/demo
191
-
192
- ## License and Legal
193
-
194
- - **MIT License** - Permissive open source license allowing commercial use
195
- - **Contributor License Agreement** - Ensure proper IP assignment
196
- - **Trademark Guidelines** - Protect project name and logo
197
- - **Privacy Policy** - For any hosted services or telemetry
198
-
199
- ## Community and Support
200
-
201
- ### Communication Channels
202
-
203
- - **GitHub Discussions** - Community Q&A and feature requests
204
- - **Discord Server** - Real-time chat and support
205
- - **Twitter Account** - Updates and announcements
206
- - **Blog/Newsletter** - Technical articles and release notes
207
-
208
- ### Contribution Types
209
-
210
- - **Code Contributions** - Bug fixes and new features
211
- - **Documentation** - Tutorials, guides, and API docs
212
- - **Testing** - Test cases and bug reports
213
- - **Translations** - Internationalization support
214
- - **Design** - UI/UX improvements and assets
215
-
216
- ## Monorepo Workspaces & Dependency Management
217
-
218
- This package is part of a monorepo using npm workspaces. All dependencies are hoisted to the root. Always run `npm install` from the root directory.
219
-
220
- ## React 19 and Testing Library Compatibility
221
-
222
- This package uses React 19.1.0. If you see peer dependency warnings with Testing Library, use:
223
-
224
- ```bash
225
- npm install --legacy-peer-deps
226
- ```
80
+ This package orchestrates the following BernierLLC core packages:
227
81
 
228
- This is a temporary workaround until official support is released.
82
+ - [`@bernierllc/email-sender`](../core/email-sender) - Multi-provider email sending
83
+ - [`@bernierllc/magic-link`](../core/magic-link) - Secure token generation
84
+ - [`@bernierllc/template-engine`](../core/template-engine) - Template rendering
85
+ - [`@bernierllc/retry-policy`](../core/retry-policy) - Retry algorithms
86
+ - [`@bernierllc/retry-state`](../core/retry-state) - Retry state management
87
+ - [`@bernierllc/retry-metrics`](../core/retry-metrics) - Performance metrics
229
88
 
230
- ---
89
+ ## License
231
90
 
232
- This specification provides the foundation for creating a world-class, open source email management solution that can be adopted by developers across multiple platforms and use cases.
91
+ Copyright (c) 2025 Bernier LLC. All rights reserved.
@@ -0,0 +1,3 @@
1
+ export { EmailService } from './simple-email-service';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.EmailService = void 0;
25
+ var simple_email_service_1 = require("./simple-email-service");
26
+ Object.defineProperty(exports, "EmailService", { enumerable: true, get: function () { return simple_email_service_1.EmailService; } });
27
+ __exportStar(require("./types"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;AAEF,+DAAsD;AAA7C,oHAAA,YAAY,OAAA;AACrB,0CAAwB"}
@@ -0,0 +1,58 @@
1
+ import { EmailServiceConfig, EmailMessage, TemplateEmailMessage, MagicLinkEmail, EmailResult, BulkEmailResult, MagicLinkResult, EmailMetrics, EmailDeliveryInfo, TemplateValidationResult, IEmailService } from './types';
2
+ /**
3
+ * Simplified email service demonstrating service layer orchestration pattern
4
+ * This implementation focuses on the service architecture rather than full integration
5
+ */
6
+ export declare class EmailService implements IEmailService {
7
+ private readonly config;
8
+ private readonly retryStorage;
9
+ constructor(config: EmailServiceConfig);
10
+ /**
11
+ * Send a single email with retry logic
12
+ */
13
+ send(message: EmailMessage): Promise<EmailResult>;
14
+ /**
15
+ * Send an email using a template
16
+ */
17
+ sendTemplate(message: TemplateEmailMessage): Promise<EmailResult>;
18
+ /**
19
+ * Send a magic link email
20
+ */
21
+ sendMagicLink(config: MagicLinkEmail): Promise<MagicLinkResult>;
22
+ /**
23
+ * Send multiple emails
24
+ */
25
+ sendBulk(messages: EmailMessage[]): Promise<BulkEmailResult>;
26
+ /**
27
+ * Validate template syntax
28
+ */
29
+ validateTemplate(template: string): Promise<TemplateValidationResult>;
30
+ /**
31
+ * Get email delivery metrics
32
+ */
33
+ getMetrics(): Promise<EmailMetrics>;
34
+ /**
35
+ * Get delivery status
36
+ */
37
+ getDeliveryStatus(messageId: string): Promise<EmailDeliveryInfo | null>;
38
+ /**
39
+ * Test configuration
40
+ */
41
+ testConfiguration(): Promise<{
42
+ success: boolean;
43
+ error?: string;
44
+ }>;
45
+ private normalizeConfig;
46
+ private applyDefaults;
47
+ private validateMessage;
48
+ private sendWithRetry;
49
+ private renderTemplate;
50
+ private generateMagicLink;
51
+ private extractTokenFromLink;
52
+ private createMagicLinkHtml;
53
+ private createMagicLinkText;
54
+ private extractTemplateVariables;
55
+ private generateMessageId;
56
+ private delay;
57
+ }
58
+ //# sourceMappingURL=simple-email-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-email-service.d.ts","sourceRoot":"","sources":["../src/simple-email-service.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EAGxB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;gBAE3C,MAAM,EAAE,kBAAkB;IAKtC;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAgCvD;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAsBvE;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAiCrE;;OAEG;IACG,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IA4ClE;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAwB3E;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC;IAezC;;OAEG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAyB7E;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAsBxE,OAAO,CAAC,eAAe;IAgCvB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,eAAe;YAkBT,aAAa;IAyD3B,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,iBAAiB;YAIX,KAAK;CAGpB"}