@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.
- package/README.md +76 -217
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/simple-email-service.d.ts +58 -0
- package/dist/simple-email-service.d.ts.map +1 -0
- package/dist/simple-email-service.js +416 -0
- package/dist/simple-email-service.js.map +1 -0
- package/dist/types.d.ts +311 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +33 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -22
- package/.eslintrc.json +0 -112
- package/.flake8 +0 -18
- package/.github/workflows/ci.yml +0 -300
- package/EXTRACTION_SUMMARY.md +0 -265
- package/IMPLEMENTATION_STATUS.md +0 -159
- package/OPEN_SOURCE_SETUP.md +0 -420
- package/PACKAGE_USAGE.md +0 -471
- package/examples/fastapi-example/main.py +0 -257
- package/examples/nextjs-example/next-env.d.ts +0 -13
- package/examples/nextjs-example/package.json +0 -26
- package/examples/nextjs-example/pages/admin/templates.tsx +0 -157
- package/examples/nextjs-example/tsconfig.json +0 -28
- package/packages/core/package.json +0 -70
- package/packages/core/rollup.config.js +0 -37
- package/packages/core/specification.md +0 -416
- package/packages/core/src/adapters/supabase.ts +0 -291
- package/packages/core/src/core/scheduler.ts +0 -356
- package/packages/core/src/core/template-manager.ts +0 -388
- package/packages/core/src/index.ts +0 -30
- package/packages/core/src/providers/base.ts +0 -104
- package/packages/core/src/providers/sendgrid.ts +0 -368
- package/packages/core/src/types/provider.ts +0 -91
- package/packages/core/src/types/scheduled.ts +0 -78
- package/packages/core/src/types/template.ts +0 -97
- package/packages/core/tsconfig.json +0 -23
- package/packages/python/README.md +0 -106
- package/packages/python/email_template_manager/__init__.py +0 -66
- package/packages/python/email_template_manager/config.py +0 -98
- package/packages/python/email_template_manager/core/magic_links.py +0 -245
- package/packages/python/email_template_manager/core/manager.py +0 -344
- package/packages/python/email_template_manager/core/scheduler.py +0 -473
- package/packages/python/email_template_manager/exceptions.py +0 -67
- package/packages/python/email_template_manager/models/magic_link.py +0 -59
- package/packages/python/email_template_manager/models/scheduled.py +0 -78
- package/packages/python/email_template_manager/models/template.py +0 -90
- package/packages/python/email_template_manager/providers/aws_ses.py +0 -44
- package/packages/python/email_template_manager/providers/base.py +0 -94
- package/packages/python/email_template_manager/providers/sendgrid.py +0 -325
- package/packages/python/email_template_manager/providers/smtp.py +0 -44
- package/packages/python/pyproject.toml +0 -133
- package/packages/python/setup.py +0 -93
- package/packages/python/specification.md +0 -930
- package/packages/react/README.md +0 -13
- package/packages/react/package.json +0 -105
- package/packages/react/rollup.config.js +0 -37
- package/packages/react/specification.md +0 -569
- package/packages/react/src/index.ts +0 -20
- package/packages/react/tsconfig.json +0 -24
- package/plans/email-template-manager_app-admin.md +0 -590
- package/src/index.js +0 -1
- package/test_package.py +0 -125
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2025 Bernier LLC
|
|
3
|
-
|
|
4
|
-
This file is licensed to the client under a limited-use license.
|
|
5
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Email Template Manager - React Components
|
|
11
|
-
* React components for email template management
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// Re-export core types and classes
|
|
15
|
-
export * from '@email-template-manager/core';
|
|
16
|
-
|
|
17
|
-
// TODO: Add React components when implemented
|
|
18
|
-
// export { EmailTemplateProvider } from './components/EmailTemplateProvider';
|
|
19
|
-
// export { EmailTemplateEditor } from './components/EmailTemplateEditor';
|
|
20
|
-
// export { useEmailTemplates } from './hooks/useEmailTemplates';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"sourceMap": true,
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"rootDir": "./src",
|
|
11
|
-
"strict": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"allowSyntheticDefaultImports": true,
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"noEmit": false,
|
|
20
|
-
"jsx": "react-jsx"
|
|
21
|
-
},
|
|
22
|
-
"include": ["src/**/*"],
|
|
23
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
24
|
-
}
|
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
# Email Template Manager - App-Admin Integration Plan
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Update the existing email-template-manager tool to be fully pluggable with the app-admin system. This will allow the email template manager to register itself with app-admin, provide admin UI pages, and integrate seamlessly with the centralized user management and RBAC system.
|
|
6
|
-
|
|
7
|
-
## Current State Analysis
|
|
8
|
-
|
|
9
|
-
### What We Have:
|
|
10
|
-
- **Email Template Manager**: Existing tool with template management functionality
|
|
11
|
-
- **Template System**: Template creation, editing, and management
|
|
12
|
-
- **Email Sending**: Integration with email providers
|
|
13
|
-
- **Basic UI**: Template management interface
|
|
14
|
-
|
|
15
|
-
### What's Missing:
|
|
16
|
-
- **App-Admin Integration**: No registration with admin system
|
|
17
|
-
- **RBAC Integration**: No permission-based access control
|
|
18
|
-
- **Admin UI Pages**: No admin panel integration
|
|
19
|
-
- **User Management**: No integration with centralized user system
|
|
20
|
-
- **Configuration Management**: No admin-configurable settings
|
|
21
|
-
|
|
22
|
-
## Integration Requirements
|
|
23
|
-
|
|
24
|
-
### 1. App-Admin Registration
|
|
25
|
-
```typescript
|
|
26
|
-
// Register with app-admin system
|
|
27
|
-
const emailTemplateManagerRegistration = {
|
|
28
|
-
id: 'email-template-manager',
|
|
29
|
-
name: 'Email Template Manager',
|
|
30
|
-
version: '2.0.0',
|
|
31
|
-
description: 'Manage email templates and send emails',
|
|
32
|
-
icon: 'Mail',
|
|
33
|
-
permissions: [
|
|
34
|
-
'email-templates:read',
|
|
35
|
-
'email-templates:write',
|
|
36
|
-
'email-templates:delete',
|
|
37
|
-
'email-templates:send',
|
|
38
|
-
'email-templates:admin'
|
|
39
|
-
],
|
|
40
|
-
pages: [
|
|
41
|
-
{
|
|
42
|
-
path: '/admin/email-templates',
|
|
43
|
-
title: 'Email Templates',
|
|
44
|
-
component: 'EmailTemplatesPage',
|
|
45
|
-
permissions: ['email-templates:read']
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
path: '/admin/email-templates/new',
|
|
49
|
-
title: 'Create Template',
|
|
50
|
-
component: 'CreateTemplatePage',
|
|
51
|
-
permissions: ['email-templates:write']
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
path: '/admin/email-templates/[id]',
|
|
55
|
-
title: 'Edit Template',
|
|
56
|
-
component: 'EditTemplatePage',
|
|
57
|
-
permissions: ['email-templates:write']
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
path: '/admin/email-settings',
|
|
61
|
-
title: 'Email Settings',
|
|
62
|
-
component: 'EmailSettingsPage',
|
|
63
|
-
permissions: ['email-templates:admin']
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
hooks: [
|
|
67
|
-
'useEmailTemplates',
|
|
68
|
-
'useEmailSending',
|
|
69
|
-
'useEmailSettings'
|
|
70
|
-
],
|
|
71
|
-
config: {
|
|
72
|
-
defaultProvider: 'sendgrid',
|
|
73
|
-
allowedProviders: ['sendgrid', 'mailgun', 'ses'],
|
|
74
|
-
templateCategories: ['welcome', 'notification', 'marketing'],
|
|
75
|
-
maxTemplatesPerUser: 50
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### 2. RBAC Permission System
|
|
81
|
-
```typescript
|
|
82
|
-
// Define permissions for email template manager
|
|
83
|
-
const emailTemplatePermissions = [
|
|
84
|
-
{
|
|
85
|
-
id: 'email-templates:read',
|
|
86
|
-
name: 'Read Email Templates',
|
|
87
|
-
description: 'View email templates',
|
|
88
|
-
resource: 'email-templates',
|
|
89
|
-
action: 'read'
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: 'email-templates:write',
|
|
93
|
-
name: 'Write Email Templates',
|
|
94
|
-
description: 'Create and edit email templates',
|
|
95
|
-
resource: 'email-templates',
|
|
96
|
-
action: 'write'
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: 'email-templates:delete',
|
|
100
|
-
name: 'Delete Email Templates',
|
|
101
|
-
description: 'Delete email templates',
|
|
102
|
-
resource: 'email-templates',
|
|
103
|
-
action: 'delete'
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 'email-templates:send',
|
|
107
|
-
name: 'Send Emails',
|
|
108
|
-
description: 'Send emails using templates',
|
|
109
|
-
resource: 'email-templates',
|
|
110
|
-
action: 'send'
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: 'email-templates:admin',
|
|
114
|
-
name: 'Email Template Administration',
|
|
115
|
-
description: 'Manage email settings and configurations',
|
|
116
|
-
resource: 'email-templates',
|
|
117
|
-
action: 'admin'
|
|
118
|
-
}
|
|
119
|
-
];
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### 3. Admin UI Integration
|
|
123
|
-
```typescript
|
|
124
|
-
// Admin pages for email template manager
|
|
125
|
-
interface EmailTemplateAdminPages {
|
|
126
|
-
templates: {
|
|
127
|
-
path: '/admin/email-templates';
|
|
128
|
-
component: EmailTemplatesListPage;
|
|
129
|
-
permissions: ['email-templates:read'];
|
|
130
|
-
};
|
|
131
|
-
create: {
|
|
132
|
-
path: '/admin/email-templates/new';
|
|
133
|
-
component: CreateTemplatePage;
|
|
134
|
-
permissions: ['email-templates:write'];
|
|
135
|
-
};
|
|
136
|
-
edit: {
|
|
137
|
-
path: '/admin/email-templates/[id]';
|
|
138
|
-
component: EditTemplatePage;
|
|
139
|
-
permissions: ['email-templates:write'];
|
|
140
|
-
};
|
|
141
|
-
settings: {
|
|
142
|
-
path: '/admin/email-settings';
|
|
143
|
-
component: EmailSettingsPage;
|
|
144
|
-
permissions: ['email-templates:admin'];
|
|
145
|
-
};
|
|
146
|
-
analytics: {
|
|
147
|
-
path: '/admin/email-analytics';
|
|
148
|
-
component: EmailAnalyticsPage;
|
|
149
|
-
permissions: ['email-templates:read'];
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Implementation Plan
|
|
155
|
-
|
|
156
|
-
### Phase 1: App-Admin Integration (Week 1)
|
|
157
|
-
|
|
158
|
-
#### 1.1 Registration System
|
|
159
|
-
- [ ] Create app-admin registration module
|
|
160
|
-
- [ ] Implement utility registration API
|
|
161
|
-
- [ ] Add permission definitions
|
|
162
|
-
- [ ] Create admin page registrations
|
|
163
|
-
- [ ] Set up configuration management
|
|
164
|
-
|
|
165
|
-
#### 1.2 Permission Integration
|
|
166
|
-
- [ ] Integrate with app-admin RBAC system
|
|
167
|
-
- [ ] Add permission checking middleware
|
|
168
|
-
- [ ] Implement role-based template access
|
|
169
|
-
- [ ] Create user-specific template filtering
|
|
170
|
-
- [ ] Add group-based permissions
|
|
171
|
-
|
|
172
|
-
#### 1.3 Configuration Management
|
|
173
|
-
- [ ] Create admin-configurable settings
|
|
174
|
-
- [ ] Implement provider configuration
|
|
175
|
-
- [ ] Add template category management
|
|
176
|
-
- [ ] Create user limit configurations
|
|
177
|
-
- [ ] Set up audit logging
|
|
178
|
-
|
|
179
|
-
### Phase 2: Admin UI Development (Week 2)
|
|
180
|
-
|
|
181
|
-
#### 2.1 Template Management UI
|
|
182
|
-
- [ ] Create admin template list page
|
|
183
|
-
- [ ] Implement template creation form
|
|
184
|
-
- [ ] Add template editing interface
|
|
185
|
-
- [ ] Create template preview functionality
|
|
186
|
-
- [ ] Add bulk template operations
|
|
187
|
-
|
|
188
|
-
#### 2.2 Settings Management UI
|
|
189
|
-
- [ ] Create email provider settings
|
|
190
|
-
- [ ] Implement template category management
|
|
191
|
-
- [ ] Add user permission management
|
|
192
|
-
- [ ] Create system configuration interface
|
|
193
|
-
- [ ] Add audit log viewer
|
|
194
|
-
|
|
195
|
-
#### 2.3 Analytics Dashboard
|
|
196
|
-
- [ ] Create email analytics page
|
|
197
|
-
- [ ] Implement sending statistics
|
|
198
|
-
- [ ] Add template usage metrics
|
|
199
|
-
- [ ] Create delivery rate tracking
|
|
200
|
-
- [ ] Add performance monitoring
|
|
201
|
-
|
|
202
|
-
### Phase 3: API Enhancement (Week 3)
|
|
203
|
-
|
|
204
|
-
#### 3.1 User-Aware APIs
|
|
205
|
-
- [ ] Update template APIs for user context
|
|
206
|
-
- [ ] Add permission-based filtering
|
|
207
|
-
- [ ] Implement user-specific templates
|
|
208
|
-
- [ ] Add group-based template access
|
|
209
|
-
- [ ] Create audit trail APIs
|
|
210
|
-
|
|
211
|
-
#### 3.2 Admin APIs
|
|
212
|
-
- [ ] Create admin-specific endpoints
|
|
213
|
-
- [ ] Add bulk template operations
|
|
214
|
-
- [ ] Implement system configuration APIs
|
|
215
|
-
- [ ] Create analytics data endpoints
|
|
216
|
-
- [ ] Add user management APIs
|
|
217
|
-
|
|
218
|
-
#### 3.3 Integration APIs
|
|
219
|
-
- [ ] Create app-admin integration endpoints
|
|
220
|
-
- [ ] Add utility registration APIs
|
|
221
|
-
- [ ] Implement configuration sync
|
|
222
|
-
- [ ] Create permission sync APIs
|
|
223
|
-
- [ ] Add webhook endpoints
|
|
224
|
-
|
|
225
|
-
### Phase 4: Hook System (Week 4)
|
|
226
|
-
|
|
227
|
-
#### 4.1 React Hooks
|
|
228
|
-
- [ ] Create useEmailTemplates hook
|
|
229
|
-
- [ ] Implement useEmailSending hook
|
|
230
|
-
- [ ] Add useEmailSettings hook
|
|
231
|
-
- [ ] Create useEmailAnalytics hook
|
|
232
|
-
- [ ] Add useEmailPermissions hook
|
|
233
|
-
|
|
234
|
-
#### 4.2 Integration Hooks
|
|
235
|
-
- [ ] Create app-admin integration hooks
|
|
236
|
-
- [ ] Add permission checking hooks
|
|
237
|
-
- [ ] Implement user context hooks
|
|
238
|
-
- [ ] Create configuration hooks
|
|
239
|
-
- [ ] Add audit logging hooks
|
|
240
|
-
|
|
241
|
-
### Phase 5: Documentation and Testing (Week 5)
|
|
242
|
-
|
|
243
|
-
#### 5.1 Documentation
|
|
244
|
-
- [ ] Update installation guide
|
|
245
|
-
- [ ] Create app-admin integration guide
|
|
246
|
-
- [ ] Document new APIs and hooks
|
|
247
|
-
- [ ] Create configuration guide
|
|
248
|
-
- [ ] Add troubleshooting guide
|
|
249
|
-
|
|
250
|
-
#### 5.2 Testing
|
|
251
|
-
- [ ] Add integration tests for app-admin
|
|
252
|
-
- [ ] Create permission testing
|
|
253
|
-
- [ ] Add admin UI tests
|
|
254
|
-
- [ ] Implement configuration tests
|
|
255
|
-
- [ ] Create end-to-end tests
|
|
256
|
-
|
|
257
|
-
## Technical Implementation
|
|
258
|
-
|
|
259
|
-
### 1. App-Admin Registration Module
|
|
260
|
-
```typescript
|
|
261
|
-
// src/integrations/app-admin.ts
|
|
262
|
-
import { registerUtility } from '@app-admin/core';
|
|
263
|
-
|
|
264
|
-
export class AppAdminIntegration {
|
|
265
|
-
static async register() {
|
|
266
|
-
await registerUtility({
|
|
267
|
-
id: 'email-template-manager',
|
|
268
|
-
name: 'Email Template Manager',
|
|
269
|
-
version: '2.0.0',
|
|
270
|
-
description: 'Manage email templates and send emails',
|
|
271
|
-
icon: 'Mail',
|
|
272
|
-
permissions: emailTemplatePermissions,
|
|
273
|
-
pages: emailTemplateAdminPages,
|
|
274
|
-
hooks: emailTemplateHooks,
|
|
275
|
-
config: emailTemplateConfig
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
static async unregister() {
|
|
280
|
-
// Cleanup registration
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### 2. Enhanced Template Management
|
|
286
|
-
```typescript
|
|
287
|
-
// src/services/template-service.ts
|
|
288
|
-
export class TemplateService {
|
|
289
|
-
constructor(private userContext: UserContext) {}
|
|
290
|
-
|
|
291
|
-
async getTemplates(filters?: TemplateFilters): Promise<Template[]> {
|
|
292
|
-
// Apply user permissions
|
|
293
|
-
const userPermissions = await this.userContext.getPermissions();
|
|
294
|
-
|
|
295
|
-
if (!userPermissions.includes('email-templates:read')) {
|
|
296
|
-
throw new Error('Insufficient permissions');
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Filter by user access
|
|
300
|
-
const templates = await this.templateRepository.findByUser(
|
|
301
|
-
this.userContext.userId,
|
|
302
|
-
filters
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
return templates;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
async createTemplate(template: CreateTemplateRequest): Promise<Template> {
|
|
309
|
-
// Check permissions
|
|
310
|
-
if (!this.userContext.hasPermission('email-templates:write')) {
|
|
311
|
-
throw new Error('Insufficient permissions');
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Create template with user context
|
|
315
|
-
const newTemplate = await this.templateRepository.create({
|
|
316
|
-
...template,
|
|
317
|
-
createdBy: this.userContext.userId,
|
|
318
|
-
organizationId: this.userContext.organizationId
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// Audit log
|
|
322
|
-
await this.auditService.log({
|
|
323
|
-
action: 'template_created',
|
|
324
|
-
userId: this.userContext.userId,
|
|
325
|
-
resourceId: newTemplate.id,
|
|
326
|
-
details: template
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
return newTemplate;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### 3. Admin UI Components
|
|
335
|
-
```typescript
|
|
336
|
-
// src/components/admin/EmailTemplatesListPage.tsx
|
|
337
|
-
export function EmailTemplatesListPage() {
|
|
338
|
-
const { hasPermission } = useAdmin();
|
|
339
|
-
const { templates, loading, error } = useEmailTemplates();
|
|
340
|
-
const { user } = useAuth();
|
|
341
|
-
|
|
342
|
-
if (!hasPermission('email-templates:read')) {
|
|
343
|
-
return <AccessDenied />;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return (
|
|
347
|
-
<div className="space-y-6">
|
|
348
|
-
<div className="flex justify-between items-center">
|
|
349
|
-
<h1 className="text-2xl font-bold">Email Templates</h1>
|
|
350
|
-
{hasPermission('email-templates:write') && (
|
|
351
|
-
<Button asChild>
|
|
352
|
-
<Link href="/admin/email-templates/new">Create Template</Link>
|
|
353
|
-
</Button>
|
|
354
|
-
)}
|
|
355
|
-
</div>
|
|
356
|
-
|
|
357
|
-
<TemplatesList
|
|
358
|
-
templates={templates}
|
|
359
|
-
loading={loading}
|
|
360
|
-
error={error}
|
|
361
|
-
canEdit={hasPermission('email-templates:write')}
|
|
362
|
-
canDelete={hasPermission('email-templates:delete')}
|
|
363
|
-
/>
|
|
364
|
-
</div>
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### 4. Configuration Management
|
|
370
|
-
```typescript
|
|
371
|
-
// src/config/admin-config.ts
|
|
372
|
-
export interface EmailTemplateAdminConfig {
|
|
373
|
-
providers: {
|
|
374
|
-
sendgrid: SendGridConfig;
|
|
375
|
-
mailgun: MailgunConfig;
|
|
376
|
-
ses: SESConfig;
|
|
377
|
-
};
|
|
378
|
-
templates: {
|
|
379
|
-
maxPerUser: number;
|
|
380
|
-
allowedCategories: string[];
|
|
381
|
-
defaultCategory: string;
|
|
382
|
-
};
|
|
383
|
-
permissions: {
|
|
384
|
-
defaultRole: string;
|
|
385
|
-
adminRoles: string[];
|
|
386
|
-
};
|
|
387
|
-
features: {
|
|
388
|
-
analytics: boolean;
|
|
389
|
-
auditLogging: boolean;
|
|
390
|
-
bulkOperations: boolean;
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
export class AdminConfigManager {
|
|
395
|
-
static async getConfig(): Promise<EmailTemplateAdminConfig> {
|
|
396
|
-
// Get from app-admin configuration
|
|
397
|
-
const config = await getAdminConfig('email-template-manager');
|
|
398
|
-
return config;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
static async updateConfig(config: Partial<EmailTemplateAdminConfig>) {
|
|
402
|
-
// Update app-admin configuration
|
|
403
|
-
await updateAdminConfig('email-template-manager', config);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
## Database Schema Updates
|
|
409
|
-
|
|
410
|
-
### 1. User Context Tables
|
|
411
|
-
```sql
|
|
412
|
-
-- Add user context to templates
|
|
413
|
-
ALTER TABLE email_templates
|
|
414
|
-
ADD COLUMN created_by UUID REFERENCES users(id),
|
|
415
|
-
ADD COLUMN organization_id UUID REFERENCES organizations(id),
|
|
416
|
-
ADD COLUMN is_public BOOLEAN DEFAULT false;
|
|
417
|
-
|
|
418
|
-
-- Add permissions table
|
|
419
|
-
CREATE TABLE email_template_permissions (
|
|
420
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
421
|
-
user_id UUID REFERENCES users(id),
|
|
422
|
-
template_id UUID REFERENCES email_templates(id),
|
|
423
|
-
permission TEXT NOT NULL,
|
|
424
|
-
granted_by UUID REFERENCES users(id),
|
|
425
|
-
granted_at TIMESTAMP DEFAULT NOW(),
|
|
426
|
-
UNIQUE(user_id, template_id, permission)
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
-- Add audit log table
|
|
430
|
-
CREATE TABLE email_template_audit_log (
|
|
431
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
432
|
-
user_id UUID REFERENCES users(id),
|
|
433
|
-
action TEXT NOT NULL,
|
|
434
|
-
resource_type TEXT NOT NULL,
|
|
435
|
-
resource_id UUID,
|
|
436
|
-
details JSONB,
|
|
437
|
-
created_at TIMESTAMP DEFAULT NOW()
|
|
438
|
-
);
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### 2. Configuration Tables
|
|
442
|
-
```sql
|
|
443
|
-
-- Add configuration table
|
|
444
|
-
CREATE TABLE email_template_config (
|
|
445
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
446
|
-
organization_id UUID REFERENCES organizations(id),
|
|
447
|
-
config_key TEXT NOT NULL,
|
|
448
|
-
config_value JSONB,
|
|
449
|
-
created_at TIMESTAMP DEFAULT NOW(),
|
|
450
|
-
updated_at TIMESTAMP DEFAULT NOW(),
|
|
451
|
-
UNIQUE(organization_id, config_key)
|
|
452
|
-
);
|
|
453
|
-
|
|
454
|
-
-- Add analytics table
|
|
455
|
-
CREATE TABLE email_template_analytics (
|
|
456
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
457
|
-
template_id UUID REFERENCES email_templates(id),
|
|
458
|
-
sent_count INTEGER DEFAULT 0,
|
|
459
|
-
delivered_count INTEGER DEFAULT 0,
|
|
460
|
-
opened_count INTEGER DEFAULT 0,
|
|
461
|
-
clicked_count INTEGER DEFAULT 0,
|
|
462
|
-
last_sent_at TIMESTAMP,
|
|
463
|
-
created_at TIMESTAMP DEFAULT NOW(),
|
|
464
|
-
updated_at TIMESTAMP DEFAULT NOW()
|
|
465
|
-
);
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
## Integration Examples
|
|
469
|
-
|
|
470
|
-
### 1. Basic Integration
|
|
471
|
-
```typescript
|
|
472
|
-
// In your Next.js app
|
|
473
|
-
import { EmailTemplateManager } from '@email-template-manager/core';
|
|
474
|
-
import { AppAdminIntegration } from '@email-template-manager/integrations';
|
|
475
|
-
|
|
476
|
-
// Initialize with app-admin integration
|
|
477
|
-
const emailManager = new EmailTemplateManager({
|
|
478
|
-
provider: 'sendgrid',
|
|
479
|
-
apiKey: process.env.SENDGRID_API_KEY,
|
|
480
|
-
integrations: {
|
|
481
|
-
appAdmin: {
|
|
482
|
-
enabled: true,
|
|
483
|
-
config: {
|
|
484
|
-
defaultRole: 'email-manager',
|
|
485
|
-
adminRoles: ['admin', 'email-admin']
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
// Register with app-admin
|
|
492
|
-
await AppAdminIntegration.register();
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### 2. Using Admin UI
|
|
496
|
-
```typescript
|
|
497
|
-
// In your admin layout
|
|
498
|
-
import { AdminNavigation } from '@app-admin/ui';
|
|
499
|
-
|
|
500
|
-
const adminPages = [
|
|
501
|
-
// ... other admin pages
|
|
502
|
-
{
|
|
503
|
-
title: 'Email Templates',
|
|
504
|
-
href: '/admin/email-templates',
|
|
505
|
-
icon: 'Mail',
|
|
506
|
-
permission: 'email-templates:read'
|
|
507
|
-
}
|
|
508
|
-
];
|
|
509
|
-
|
|
510
|
-
export default function AdminLayout({ children }) {
|
|
511
|
-
return (
|
|
512
|
-
<div>
|
|
513
|
-
<AdminNavigation pages={adminPages} />
|
|
514
|
-
{children}
|
|
515
|
-
</div>
|
|
516
|
-
);
|
|
517
|
-
}
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
### 3. Using Hooks
|
|
521
|
-
```typescript
|
|
522
|
-
// In your components
|
|
523
|
-
import { useEmailTemplates, useEmailSending } from '@email-template-manager/hooks';
|
|
524
|
-
|
|
525
|
-
export function EmailDashboard() {
|
|
526
|
-
const { templates, loading } = useEmailTemplates();
|
|
527
|
-
const { sendEmail } = useEmailSending();
|
|
528
|
-
|
|
529
|
-
const handleSendEmail = async (templateId: string, data: any) => {
|
|
530
|
-
await sendEmail(templateId, data);
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
return (
|
|
534
|
-
<div>
|
|
535
|
-
{templates.map(template => (
|
|
536
|
-
<TemplateCard
|
|
537
|
-
key={template.id}
|
|
538
|
-
template={template}
|
|
539
|
-
onSend={handleSendEmail}
|
|
540
|
-
/>
|
|
541
|
-
))}
|
|
542
|
-
</div>
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
## Success Criteria
|
|
548
|
-
|
|
549
|
-
### Functional Requirements
|
|
550
|
-
- [ ] Complete app-admin registration
|
|
551
|
-
- [ ] Full RBAC integration
|
|
552
|
-
- [ ] Admin UI pages working
|
|
553
|
-
- [ ] User-specific template access
|
|
554
|
-
- [ ] Configuration management
|
|
555
|
-
- [ ] Audit logging system
|
|
556
|
-
- [ ] Analytics integration
|
|
557
|
-
|
|
558
|
-
### Technical Requirements
|
|
559
|
-
- [ ] TypeScript support throughout
|
|
560
|
-
- [ ] Permission-based access control
|
|
561
|
-
- [ ] User context integration
|
|
562
|
-
- [ ] Configuration management
|
|
563
|
-
- [ ] Audit trail implementation
|
|
564
|
-
- [ ] Performance optimization
|
|
565
|
-
|
|
566
|
-
### Integration Requirements
|
|
567
|
-
- [ ] Seamless app-admin integration
|
|
568
|
-
- [ ] Working admin UI pages
|
|
569
|
-
- [ ] Proper permission checking
|
|
570
|
-
- [ ] Configuration synchronization
|
|
571
|
-
- [ ] Hook system working
|
|
572
|
-
- [ ] Documentation complete
|
|
573
|
-
|
|
574
|
-
## Future Enhancements
|
|
575
|
-
|
|
576
|
-
### Advanced Features
|
|
577
|
-
- [ ] Multi-tenant support
|
|
578
|
-
- [ ] Advanced analytics
|
|
579
|
-
- [ ] Template versioning
|
|
580
|
-
- [ ] A/B testing
|
|
581
|
-
- [ ] Advanced scheduling
|
|
582
|
-
- [ ] Template marketplace
|
|
583
|
-
|
|
584
|
-
### Integration Features
|
|
585
|
-
- [ ] More email providers
|
|
586
|
-
- [ ] CRM integrations
|
|
587
|
-
- [ ] Marketing automation
|
|
588
|
-
- [ ] Webhook system
|
|
589
|
-
- [ ] API rate limiting
|
|
590
|
-
- [ ] Real-time notifications
|
package/src/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Entry point for @bernierllc/email package
|