@bernierllc/email-campaign-management 1.3.2 → 1.5.1

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 (45) hide show
  1. package/dist/api/client.js +1 -0
  2. package/dist/errors.d.ts +11 -0
  3. package/dist/errors.js +27 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +3 -1
  6. package/package.json +8 -4
  7. package/.eslintrc.cjs +0 -45
  8. package/CHANGELOG.md +0 -168
  9. package/__tests__/api/campaigns.test.ts +0 -217
  10. package/__tests__/api/client.test.ts +0 -330
  11. package/__tests__/components/CampaignBuilder.test.tsx +0 -103
  12. package/__tests__/components/CampaignDashboard.test.tsx +0 -89
  13. package/__tests__/components/CampaignList.test.tsx +0 -144
  14. package/__tests__/components/MetricsOverview.test.tsx +0 -200
  15. package/__tests__/components/PerformanceChart.test.tsx +0 -206
  16. package/__tests__/hooks/useCampaignStore.test.ts +0 -450
  17. package/__tests__/hooks/useWorkflowValidation.test.ts +0 -176
  18. package/__tests__/utils/formatting.test.ts +0 -48
  19. package/__tests__/utils/validation.test.ts +0 -199
  20. package/__tests__/utils/workflow-helpers.test.ts +0 -134
  21. package/jest.config.cjs +0 -33
  22. package/jest.setup.cjs +0 -9
  23. package/src/api/campaigns.ts +0 -38
  24. package/src/api/client.ts +0 -131
  25. package/src/components/CampaignBuilder/index.tsx +0 -123
  26. package/src/components/CampaignDashboard/MetricsOverview.tsx +0 -41
  27. package/src/components/CampaignDashboard/PerformanceChart.tsx +0 -49
  28. package/src/components/CampaignDashboard/index.tsx +0 -52
  29. package/src/components/CampaignList/index.tsx +0 -53
  30. package/src/config.ts +0 -39
  31. package/src/hooks/useCampaignMetrics.ts +0 -41
  32. package/src/hooks/useCampaignStore.ts +0 -86
  33. package/src/hooks/useWorkflowValidation.ts +0 -17
  34. package/src/index.ts +0 -32
  35. package/src/types/abtest.ts +0 -25
  36. package/src/types/audience.ts +0 -30
  37. package/src/types/campaign.ts +0 -44
  38. package/src/types/index.ts +0 -14
  39. package/src/types/metrics.ts +0 -36
  40. package/src/types/schedule.ts +0 -26
  41. package/src/types/workflow.ts +0 -53
  42. package/src/utils/formatting.ts +0 -26
  43. package/src/utils/validation.ts +0 -103
  44. package/src/utils/workflow-helpers.ts +0 -64
  45. package/tsconfig.json +0 -24
@@ -1,103 +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
- import { ABTestConfig, CampaignWorkflow } from '../types';
10
-
11
- export interface ValidationResult {
12
- valid: boolean;
13
- errors: string[];
14
- }
15
-
16
- export function validateWorkflow(workflow: CampaignWorkflow): ValidationResult {
17
- const errors: string[] = [];
18
-
19
- if (!workflow.nodes || workflow.nodes.length === 0) {
20
- errors.push('Workflow must have at least one node');
21
- }
22
-
23
- // Check for disconnected nodes
24
- const connectedNodeIds = new Set<string>();
25
- workflow.edges.forEach(edge => {
26
- connectedNodeIds.add(edge.source);
27
- connectedNodeIds.add(edge.target);
28
- });
29
-
30
- const disconnectedNodes = workflow.nodes.filter(
31
- node => !connectedNodeIds.has(node.id) && workflow.nodes.length > 1
32
- );
33
-
34
- if (disconnectedNodes.length > 0) {
35
- errors.push(`Workflow has ${disconnectedNodes.length} disconnected node(s)`);
36
- }
37
-
38
- return {
39
- valid: errors.length === 0,
40
- errors
41
- };
42
- }
43
-
44
- export function validateABTest(config: ABTestConfig): ValidationResult {
45
- const errors: string[] = [];
46
-
47
- if (!config.enabled) {
48
- return { valid: true, errors: [] };
49
- }
50
-
51
- if (!config.variants || config.variants.length < 2) {
52
- errors.push('A/B test must have at least 2 variants');
53
- }
54
-
55
- if (config.variants) {
56
- const totalPercentage = config.variants.reduce((sum, v) => sum + v.percentage, 0);
57
- if (Math.abs(totalPercentage - 100) > 0.01) {
58
- errors.push(`Variant percentages must sum to 100% (currently ${totalPercentage}%)`);
59
- }
60
-
61
- config.variants.forEach((variant, index) => {
62
- if (variant.percentage < 0 || variant.percentage > 100) {
63
- errors.push(`Variant ${index + 1} percentage must be between 0 and 100`);
64
- }
65
- if (!variant.templateId) {
66
- errors.push(`Variant ${index + 1} must have a template selected`);
67
- }
68
- if (!variant.subjectLine || variant.subjectLine.trim() === '') {
69
- errors.push(`Variant ${index + 1} must have a subject line`);
70
- }
71
- });
72
- }
73
-
74
- if (config.testDuration <= 0) {
75
- errors.push('Test duration must be greater than 0 hours');
76
- }
77
-
78
- if (config.winnerPercentage < 0 || config.winnerPercentage > 100) {
79
- errors.push('Winner percentage must be between 0 and 100');
80
- }
81
-
82
- return {
83
- valid: errors.length === 0,
84
- errors
85
- };
86
- }
87
-
88
- export function validateCampaignName(name: string): ValidationResult {
89
- const errors: string[] = [];
90
-
91
- if (!name || name.trim() === '') {
92
- errors.push('Campaign name is required');
93
- }
94
-
95
- if (name && name.length > 100) {
96
- errors.push('Campaign name must be 100 characters or less');
97
- }
98
-
99
- return {
100
- valid: errors.length === 0,
101
- errors
102
- };
103
- }
@@ -1,64 +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
- import { WorkflowNode, WorkflowEdge, CampaignWorkflow, NodeType } from '../types';
10
-
11
- export function generateNodeId(): string {
12
- return `node_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
13
- }
14
-
15
- export function generateEdgeId(): string {
16
- return `edge_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
17
- }
18
-
19
- export function createNode(type: NodeType, position: { x: number; y: number }): WorkflowNode {
20
- return {
21
- id: generateNodeId(),
22
- type,
23
- data: {},
24
- position
25
- };
26
- }
27
-
28
- export function createEdge(source: string, target: string): WorkflowEdge {
29
- return {
30
- id: generateEdgeId(),
31
- source,
32
- target,
33
- type: 'default'
34
- };
35
- }
36
-
37
- export function getDefaultWorkflow(): CampaignWorkflow {
38
- return {
39
- id: `workflow_${Date.now()}`,
40
- nodes: [],
41
- edges: []
42
- };
43
- }
44
-
45
- export function findNodeById(workflow: CampaignWorkflow, nodeId: string): WorkflowNode | undefined {
46
- return workflow.nodes.find(node => node.id === nodeId);
47
- }
48
-
49
- export function removeNode(workflow: CampaignWorkflow, nodeId: string): CampaignWorkflow {
50
- return {
51
- ...workflow,
52
- nodes: workflow.nodes.filter(node => node.id !== nodeId),
53
- edges: workflow.edges.filter(edge => edge.source !== nodeId && edge.target !== nodeId)
54
- };
55
- }
56
-
57
- export function updateNode(workflow: CampaignWorkflow, nodeId: string, updates: Partial<WorkflowNode>): CampaignWorkflow {
58
- return {
59
- ...workflow,
60
- nodes: workflow.nodes.map(node =>
61
- node.id === nodeId ? { ...node, ...updates } : node
62
- )
63
- };
64
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
- "jsx": "react",
7
- "declaration": true,
8
- "outDir": "./dist",
9
- "rootDir": "./src",
10
- "strict": true,
11
- "esModuleInterop": true,
12
- "skipLibCheck": true,
13
- "forceConsistentCasingInFileNames": true,
14
- "resolveJsonModule": true,
15
- "moduleResolution": "node",
16
- "allowSyntheticDefaultImports": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "noImplicitReturns": true,
20
- "noFallthroughCasesInSwitch": true
21
- },
22
- "include": ["src/**/*"],
23
- "exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts", "**/*.test.tsx"]
24
- }