@bernierllc/email-campaign-management 1.3.1 → 1.5.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/api/client.js +1 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +8 -4
- package/.eslintrc.cjs +0 -45
- package/CHANGELOG.md +0 -160
- package/__tests__/api/campaigns.test.ts +0 -217
- package/__tests__/api/client.test.ts +0 -330
- package/__tests__/components/CampaignBuilder.test.tsx +0 -103
- package/__tests__/components/CampaignDashboard.test.tsx +0 -89
- package/__tests__/components/CampaignList.test.tsx +0 -144
- package/__tests__/components/MetricsOverview.test.tsx +0 -200
- package/__tests__/components/PerformanceChart.test.tsx +0 -206
- package/__tests__/hooks/useCampaignStore.test.ts +0 -450
- package/__tests__/hooks/useWorkflowValidation.test.ts +0 -176
- package/__tests__/utils/formatting.test.ts +0 -48
- package/__tests__/utils/validation.test.ts +0 -199
- package/__tests__/utils/workflow-helpers.test.ts +0 -134
- package/jest.config.cjs +0 -33
- package/jest.setup.cjs +0 -9
- package/src/api/campaigns.ts +0 -38
- package/src/api/client.ts +0 -131
- package/src/components/CampaignBuilder/index.tsx +0 -123
- package/src/components/CampaignDashboard/MetricsOverview.tsx +0 -41
- package/src/components/CampaignDashboard/PerformanceChart.tsx +0 -49
- package/src/components/CampaignDashboard/index.tsx +0 -52
- package/src/components/CampaignList/index.tsx +0 -53
- package/src/config.ts +0 -39
- package/src/hooks/useCampaignMetrics.ts +0 -41
- package/src/hooks/useCampaignStore.ts +0 -86
- package/src/hooks/useWorkflowValidation.ts +0 -17
- package/src/index.ts +0 -32
- package/src/types/abtest.ts +0 -25
- package/src/types/audience.ts +0 -30
- package/src/types/campaign.ts +0 -44
- package/src/types/index.ts +0 -14
- package/src/types/metrics.ts +0 -36
- package/src/types/schedule.ts +0 -26
- package/src/types/workflow.ts +0 -53
- package/src/utils/formatting.ts +0 -26
- package/src/utils/validation.ts +0 -103
- package/src/utils/workflow-helpers.ts +0 -64
- package/tsconfig.json +0 -24
|
@@ -1,41 +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 React from 'react';
|
|
10
|
-
import { CampaignMetrics } from '../../types';
|
|
11
|
-
import { formatNumber, formatPercentage } from '../../utils/formatting';
|
|
12
|
-
|
|
13
|
-
export interface MetricsOverviewProps {
|
|
14
|
-
metrics: CampaignMetrics;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const MetricsOverview: React.FC<MetricsOverviewProps> = ({ metrics }) => {
|
|
18
|
-
return (
|
|
19
|
-
<div className="metrics-overview">
|
|
20
|
-
<div className="metric-card">
|
|
21
|
-
<div className="metric-value">{formatNumber(metrics.sent)}</div>
|
|
22
|
-
<div className="metric-label">Sent</div>
|
|
23
|
-
</div>
|
|
24
|
-
<div className="metric-card">
|
|
25
|
-
<div className="metric-value">{formatNumber(metrics.opened)}</div>
|
|
26
|
-
<div className="metric-label">Opened</div>
|
|
27
|
-
<div className="metric-rate">{formatPercentage(metrics.openRate)}</div>
|
|
28
|
-
</div>
|
|
29
|
-
<div className="metric-card">
|
|
30
|
-
<div className="metric-value">{formatNumber(metrics.clicked)}</div>
|
|
31
|
-
<div className="metric-label">Clicked</div>
|
|
32
|
-
<div className="metric-rate">{formatPercentage(metrics.clickRate)}</div>
|
|
33
|
-
</div>
|
|
34
|
-
<div className="metric-card">
|
|
35
|
-
<div className="metric-value">{formatNumber(metrics.converted)}</div>
|
|
36
|
-
<div className="metric-label">Converted</div>
|
|
37
|
-
<div className="metric-rate">{formatPercentage(metrics.conversionRate)}</div>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
@@ -1,49 +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 React from 'react';
|
|
10
|
-
import { CampaignMetrics } from '../../types';
|
|
11
|
-
|
|
12
|
-
export interface PerformanceChartProps {
|
|
13
|
-
metrics: CampaignMetrics;
|
|
14
|
-
type: 'open_rate' | 'click_rate' | 'conversion_rate';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const PerformanceChart: React.FC<PerformanceChartProps> = ({ metrics, type }) => {
|
|
18
|
-
const getTitle = () => {
|
|
19
|
-
switch (type) {
|
|
20
|
-
case 'open_rate':
|
|
21
|
-
return 'Open Rate';
|
|
22
|
-
case 'click_rate':
|
|
23
|
-
return 'Click Rate';
|
|
24
|
-
case 'conversion_rate':
|
|
25
|
-
return 'Conversion Rate';
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const getValue = () => {
|
|
30
|
-
switch (type) {
|
|
31
|
-
case 'open_rate':
|
|
32
|
-
return metrics.openRate;
|
|
33
|
-
case 'click_rate':
|
|
34
|
-
return metrics.clickRate;
|
|
35
|
-
case 'conversion_rate':
|
|
36
|
-
return metrics.conversionRate;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div className="performance-chart">
|
|
42
|
-
<h3>{getTitle()}</h3>
|
|
43
|
-
<div className="chart-placeholder">
|
|
44
|
-
<p>Chart: {getValue().toFixed(2)}%</p>
|
|
45
|
-
<p>(Integration with recharts or similar library needed)</p>
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
@@ -1,52 +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 React from 'react';
|
|
10
|
-
import { useCampaignMetrics, useEmailMetrics } from '../../hooks/useCampaignMetrics';
|
|
11
|
-
import { MetricsOverview } from './MetricsOverview';
|
|
12
|
-
import { PerformanceChart } from './PerformanceChart';
|
|
13
|
-
|
|
14
|
-
export interface CampaignDashboardProps {
|
|
15
|
-
campaignId: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const CampaignDashboard: React.FC<CampaignDashboardProps> = ({ campaignId }) => {
|
|
19
|
-
const { data: metrics, isLoading: metricsLoading, isError: metricsError } = useCampaignMetrics(campaignId);
|
|
20
|
-
const { data: emailMetrics, isLoading: emailLoading } = useEmailMetrics(campaignId);
|
|
21
|
-
|
|
22
|
-
if (metricsLoading || emailLoading) {
|
|
23
|
-
return <div className="loading">Loading campaign analytics...</div>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (metricsError || !metrics) {
|
|
27
|
-
return <div className="error">Failed to load campaign metrics</div>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="campaign-dashboard">
|
|
32
|
-
<h2>Campaign Analytics</h2>
|
|
33
|
-
<MetricsOverview metrics={metrics} />
|
|
34
|
-
<div className="charts-grid">
|
|
35
|
-
<PerformanceChart metrics={metrics} type="open_rate" />
|
|
36
|
-
<PerformanceChart metrics={metrics} type="click_rate" />
|
|
37
|
-
</div>
|
|
38
|
-
{emailMetrics && (
|
|
39
|
-
<div className="email-metrics">
|
|
40
|
-
<h3>Email Performance</h3>
|
|
41
|
-
<ul>
|
|
42
|
-
{emailMetrics.map(email => (
|
|
43
|
-
<li key={email.emailId}>
|
|
44
|
-
Node {email.nodeId}: {email.sent} sent, {email.openRate.toFixed(2)}% open rate
|
|
45
|
-
</li>
|
|
46
|
-
))}
|
|
47
|
-
</ul>
|
|
48
|
-
</div>
|
|
49
|
-
)}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|
|
@@ -1,53 +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 React, { useEffect } from 'react';
|
|
10
|
-
import { useCampaignStore } from '../../hooks/useCampaignStore';
|
|
11
|
-
import { Campaign } from '../../types';
|
|
12
|
-
|
|
13
|
-
export interface CampaignListProps {
|
|
14
|
-
onSelectCampaign?: (campaign: Campaign) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const CampaignList: React.FC<CampaignListProps> = ({ onSelectCampaign }) => {
|
|
18
|
-
const { campaigns, loading, error, fetchCampaigns } = useCampaignStore();
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
fetchCampaigns();
|
|
22
|
-
}, [fetchCampaigns]);
|
|
23
|
-
|
|
24
|
-
if (loading) {
|
|
25
|
-
return <div className="loading">Loading campaigns...</div>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (error) {
|
|
29
|
-
return <div className="error">Error: {error}</div>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className="campaign-list">
|
|
34
|
-
<h2>Campaigns</h2>
|
|
35
|
-
{campaigns.length === 0 ? (
|
|
36
|
-
<p>No campaigns found. Create your first campaign!</p>
|
|
37
|
-
) : (
|
|
38
|
-
<ul>
|
|
39
|
-
{campaigns.map(campaign => (
|
|
40
|
-
<li key={campaign.id} onClick={() => onSelectCampaign?.(campaign)}>
|
|
41
|
-
<div className="campaign-item">
|
|
42
|
-
<h3>{campaign.name}</h3>
|
|
43
|
-
<p>{campaign.description}</p>
|
|
44
|
-
<span className="campaign-status">{campaign.status}</span>
|
|
45
|
-
<span className="campaign-type">{campaign.type}</span>
|
|
46
|
-
</div>
|
|
47
|
-
</li>
|
|
48
|
-
))}
|
|
49
|
-
</ul>
|
|
50
|
-
)}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
};
|
package/src/config.ts
DELETED
|
@@ -1,39 +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
|
-
export interface CampaignUIConfig {
|
|
10
|
-
apiUrl: string;
|
|
11
|
-
enableABTesting: boolean;
|
|
12
|
-
enableAnalytics: boolean;
|
|
13
|
-
metricsRefreshInterval: number;
|
|
14
|
-
maxWorkflowNodes: number;
|
|
15
|
-
defaultTimezone: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const defaultConfig: CampaignUIConfig = {
|
|
19
|
-
apiUrl: process.env.REACT_APP_API_URL || 'http://localhost:3000/api',
|
|
20
|
-
enableABTesting: process.env.REACT_APP_ENABLE_AB_TESTING !== 'false',
|
|
21
|
-
enableAnalytics: process.env.REACT_APP_ENABLE_ANALYTICS !== 'false',
|
|
22
|
-
metricsRefreshInterval: parseInt(process.env.REACT_APP_METRICS_REFRESH_INTERVAL || '30000', 10),
|
|
23
|
-
maxWorkflowNodes: parseInt(process.env.REACT_APP_MAX_WORKFLOW_NODES || '50', 10),
|
|
24
|
-
defaultTimezone: process.env.REACT_APP_DEFAULT_TIMEZONE || 'UTC'
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
let currentConfig: CampaignUIConfig = { ...defaultConfig };
|
|
28
|
-
|
|
29
|
-
export function getConfig(): CampaignUIConfig {
|
|
30
|
-
return { ...currentConfig };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function setConfig(config: Partial<CampaignUIConfig>): void {
|
|
34
|
-
currentConfig = { ...currentConfig, ...config };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function resetConfig(): void {
|
|
38
|
-
currentConfig = { ...defaultConfig };
|
|
39
|
-
}
|
|
@@ -1,41 +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 { useQuery } from '@tanstack/react-query';
|
|
10
|
-
import { getCampaignMetrics, getEmailMetrics } from '../api/campaigns';
|
|
11
|
-
import { getConfig } from '../config';
|
|
12
|
-
|
|
13
|
-
export function useCampaignMetrics(campaignId: string) {
|
|
14
|
-
return useQuery({
|
|
15
|
-
queryKey: ['campaign-metrics', campaignId],
|
|
16
|
-
queryFn: async () => {
|
|
17
|
-
const response = await getCampaignMetrics(campaignId);
|
|
18
|
-
if (!response.success) {
|
|
19
|
-
throw new Error(response.error || 'Failed to fetch campaign metrics');
|
|
20
|
-
}
|
|
21
|
-
return response.data;
|
|
22
|
-
},
|
|
23
|
-
refetchInterval: getConfig().metricsRefreshInterval,
|
|
24
|
-
enabled: !!campaignId
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function useEmailMetrics(campaignId: string) {
|
|
29
|
-
return useQuery({
|
|
30
|
-
queryKey: ['email-metrics', campaignId],
|
|
31
|
-
queryFn: async () => {
|
|
32
|
-
const response = await getEmailMetrics(campaignId);
|
|
33
|
-
if (!response.success) {
|
|
34
|
-
throw new Error(response.error || 'Failed to fetch email metrics');
|
|
35
|
-
}
|
|
36
|
-
return response.data;
|
|
37
|
-
},
|
|
38
|
-
refetchInterval: getConfig().metricsRefreshInterval,
|
|
39
|
-
enabled: !!campaignId
|
|
40
|
-
});
|
|
41
|
-
}
|
|
@@ -1,86 +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 { create } from 'zustand';
|
|
10
|
-
import { Campaign } from '../types';
|
|
11
|
-
import * as campaignAPI from '../api/campaigns';
|
|
12
|
-
|
|
13
|
-
interface CampaignStore {
|
|
14
|
-
campaigns: Campaign[];
|
|
15
|
-
activeCampaign: Campaign | null;
|
|
16
|
-
loading: boolean;
|
|
17
|
-
error: string | null;
|
|
18
|
-
|
|
19
|
-
fetchCampaigns: () => Promise<void>;
|
|
20
|
-
createCampaign: (campaign: Partial<Campaign>) => Promise<Campaign | null>;
|
|
21
|
-
updateCampaign: (id: string, updates: Partial<Campaign>) => Promise<void>;
|
|
22
|
-
deleteCampaign: (id: string) => Promise<void>;
|
|
23
|
-
setActiveCampaign: (campaign: Campaign | null) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const useCampaignStore = create<CampaignStore>((set) => ({
|
|
27
|
-
campaigns: [],
|
|
28
|
-
activeCampaign: null,
|
|
29
|
-
loading: false,
|
|
30
|
-
error: null,
|
|
31
|
-
|
|
32
|
-
fetchCampaigns: async () => {
|
|
33
|
-
set({ loading: true, error: null });
|
|
34
|
-
const response = await campaignAPI.getCampaigns();
|
|
35
|
-
if (response.success && response.data) {
|
|
36
|
-
set({ campaigns: response.data, loading: false });
|
|
37
|
-
} else {
|
|
38
|
-
set({ error: response.error || 'Failed to fetch campaigns', loading: false });
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
createCampaign: async (campaign: Partial<Campaign>) => {
|
|
43
|
-
set({ loading: true, error: null });
|
|
44
|
-
const response = await campaignAPI.createCampaign(campaign);
|
|
45
|
-
if (response.success && response.data) {
|
|
46
|
-
set(state => ({
|
|
47
|
-
campaigns: [...state.campaigns, response.data as Campaign],
|
|
48
|
-
loading: false
|
|
49
|
-
}));
|
|
50
|
-
return response.data;
|
|
51
|
-
} else {
|
|
52
|
-
set({ error: response.error || 'Failed to create campaign', loading: false });
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
updateCampaign: async (id: string, updates: Partial<Campaign>) => {
|
|
58
|
-
set({ loading: true, error: null });
|
|
59
|
-
const response = await campaignAPI.updateCampaign(id, updates);
|
|
60
|
-
if (response.success && response.data) {
|
|
61
|
-
set(state => ({
|
|
62
|
-
campaigns: state.campaigns.map(c => c.id === id ? response.data as Campaign : c),
|
|
63
|
-
activeCampaign: state.activeCampaign?.id === id ? response.data : state.activeCampaign,
|
|
64
|
-
loading: false
|
|
65
|
-
}));
|
|
66
|
-
} else {
|
|
67
|
-
set({ error: response.error || 'Failed to update campaign', loading: false });
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
deleteCampaign: async (id: string) => {
|
|
72
|
-
set({ loading: true, error: null });
|
|
73
|
-
const response = await campaignAPI.deleteCampaign(id);
|
|
74
|
-
if (response.success) {
|
|
75
|
-
set(state => ({
|
|
76
|
-
campaigns: state.campaigns.filter(c => c.id !== id),
|
|
77
|
-
activeCampaign: state.activeCampaign?.id === id ? null : state.activeCampaign,
|
|
78
|
-
loading: false
|
|
79
|
-
}));
|
|
80
|
-
} else {
|
|
81
|
-
set({ error: response.error || 'Failed to delete campaign', loading: false });
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
setActiveCampaign: (campaign: Campaign | null) => set({ activeCampaign: campaign })
|
|
86
|
-
}));
|
|
@@ -1,17 +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 { useMemo } from 'react';
|
|
10
|
-
import { CampaignWorkflow } from '../types';
|
|
11
|
-
import { validateWorkflow, ValidationResult } from '../utils/validation';
|
|
12
|
-
|
|
13
|
-
export function useWorkflowValidation(workflow: CampaignWorkflow): ValidationResult {
|
|
14
|
-
return useMemo(() => {
|
|
15
|
-
return validateWorkflow(workflow);
|
|
16
|
-
}, [workflow]);
|
|
17
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,32 +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
|
-
// Components
|
|
10
|
-
export { CampaignDashboard } from './components/CampaignDashboard';
|
|
11
|
-
export { CampaignBuilder } from './components/CampaignBuilder';
|
|
12
|
-
export { CampaignList } from './components/CampaignList';
|
|
13
|
-
|
|
14
|
-
// Hooks
|
|
15
|
-
export { useCampaignStore } from './hooks/useCampaignStore';
|
|
16
|
-
export { useCampaignMetrics, useEmailMetrics } from './hooks/useCampaignMetrics';
|
|
17
|
-
export { useWorkflowValidation } from './hooks/useWorkflowValidation';
|
|
18
|
-
|
|
19
|
-
// Types
|
|
20
|
-
export * from './types';
|
|
21
|
-
|
|
22
|
-
// API
|
|
23
|
-
export * from './api/campaigns';
|
|
24
|
-
|
|
25
|
-
// Utils
|
|
26
|
-
export * from './utils/validation';
|
|
27
|
-
export * from './utils/formatting';
|
|
28
|
-
export * from './utils/workflow-helpers';
|
|
29
|
-
|
|
30
|
-
// Config
|
|
31
|
-
export { getConfig, setConfig, resetConfig } from './config';
|
|
32
|
-
export type { CampaignUIConfig } from './config';
|
package/src/types/abtest.ts
DELETED
|
@@ -1,25 +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
|
-
export interface ABTestConfig {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
variants: ABTestVariant[];
|
|
12
|
-
winnerCriteria: WinnerCriteria;
|
|
13
|
-
testDuration: number; // hours
|
|
14
|
-
winnerPercentage: number; // 0-100
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type WinnerCriteria = 'open_rate' | 'click_rate' | 'conversion_rate';
|
|
18
|
-
|
|
19
|
-
export interface ABTestVariant {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
percentage: number; // 0-100
|
|
23
|
-
templateId: string;
|
|
24
|
-
subjectLine: string;
|
|
25
|
-
}
|
package/src/types/audience.ts
DELETED
|
@@ -1,30 +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
|
-
export interface AudienceConfig {
|
|
10
|
-
type: AudienceType;
|
|
11
|
-
segmentId?: string;
|
|
12
|
-
listId?: string;
|
|
13
|
-
dynamicQuery?: DynamicQuery;
|
|
14
|
-
estimatedSize?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type AudienceType = 'all' | 'segment' | 'list' | 'dynamic';
|
|
18
|
-
|
|
19
|
-
export interface DynamicQuery {
|
|
20
|
-
filters: AudienceFilter[];
|
|
21
|
-
operator: 'AND' | 'OR';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface AudienceFilter {
|
|
25
|
-
field: string;
|
|
26
|
-
operator: FilterOperator;
|
|
27
|
-
value: unknown;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type FilterOperator = 'equals' | 'contains' | 'gt' | 'lt' | 'in' | 'not_in';
|
package/src/types/campaign.ts
DELETED
|
@@ -1,44 +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 { CampaignWorkflow } from './workflow';
|
|
10
|
-
import { AudienceConfig } from './audience';
|
|
11
|
-
import { ScheduleConfig } from './schedule';
|
|
12
|
-
import { ABTestConfig } from './abtest';
|
|
13
|
-
|
|
14
|
-
export interface Campaign {
|
|
15
|
-
id: string;
|
|
16
|
-
name: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
type: CampaignType;
|
|
19
|
-
status: CampaignStatus;
|
|
20
|
-
workflow: CampaignWorkflow;
|
|
21
|
-
audience: AudienceConfig;
|
|
22
|
-
schedule: ScheduleConfig;
|
|
23
|
-
abTest?: ABTestConfig;
|
|
24
|
-
createdAt: Date;
|
|
25
|
-
updatedAt: Date;
|
|
26
|
-
createdBy: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type CampaignType = 'one-time' | 'drip' | 'welcome' | 'nurture' | 'automated';
|
|
30
|
-
|
|
31
|
-
export type CampaignStatus = 'draft' | 'scheduled' | 'active' | 'paused' | 'completed';
|
|
32
|
-
|
|
33
|
-
export interface CampaignResult<T = unknown> {
|
|
34
|
-
success: boolean;
|
|
35
|
-
data?: T;
|
|
36
|
-
error?: CampaignError;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface CampaignError {
|
|
40
|
-
code: string;
|
|
41
|
-
message: string;
|
|
42
|
-
details?: unknown;
|
|
43
|
-
retryable?: boolean;
|
|
44
|
-
}
|
package/src/types/index.ts
DELETED
|
@@ -1,14 +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
|
-
export * from './campaign';
|
|
10
|
-
export * from './workflow';
|
|
11
|
-
export * from './audience';
|
|
12
|
-
export * from './schedule';
|
|
13
|
-
export * from './abtest';
|
|
14
|
-
export * from './metrics';
|
package/src/types/metrics.ts
DELETED
|
@@ -1,36 +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
|
-
export interface CampaignMetrics {
|
|
10
|
-
campaignId: string;
|
|
11
|
-
sent: number;
|
|
12
|
-
delivered: number;
|
|
13
|
-
bounced: number;
|
|
14
|
-
opened: number;
|
|
15
|
-
clicked: number;
|
|
16
|
-
converted: number;
|
|
17
|
-
unsubscribed: number;
|
|
18
|
-
openRate: number;
|
|
19
|
-
clickRate: number;
|
|
20
|
-
conversionRate: number;
|
|
21
|
-
lastUpdated: Date;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface EmailMetrics {
|
|
25
|
-
emailId: string;
|
|
26
|
-
nodeId: string;
|
|
27
|
-
sent: number;
|
|
28
|
-
delivered: number;
|
|
29
|
-
bounced: number;
|
|
30
|
-
opened: number;
|
|
31
|
-
clicked: number;
|
|
32
|
-
converted: number;
|
|
33
|
-
openRate: number;
|
|
34
|
-
clickRate: number;
|
|
35
|
-
conversionRate: number;
|
|
36
|
-
}
|
package/src/types/schedule.ts
DELETED
|
@@ -1,26 +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
|
-
export interface ScheduleConfig {
|
|
10
|
-
type: ScheduleType;
|
|
11
|
-
scheduledAt?: Date;
|
|
12
|
-
timezone?: string;
|
|
13
|
-
triggerEvent?: string;
|
|
14
|
-
recurringRule?: RecurringRule;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type ScheduleType = 'immediate' | 'scheduled' | 'triggered';
|
|
18
|
-
|
|
19
|
-
export interface RecurringRule {
|
|
20
|
-
frequency: RecurringFrequency;
|
|
21
|
-
interval: number;
|
|
22
|
-
daysOfWeek?: number[];
|
|
23
|
-
endDate?: Date;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type RecurringFrequency = 'daily' | 'weekly' | 'monthly';
|
package/src/types/workflow.ts
DELETED
|
@@ -1,53 +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
|
-
export interface CampaignWorkflow {
|
|
10
|
-
id: string;
|
|
11
|
-
nodes: WorkflowNode[];
|
|
12
|
-
edges: WorkflowEdge[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface WorkflowNode {
|
|
16
|
-
id: string;
|
|
17
|
-
type: NodeType;
|
|
18
|
-
data: WorkflowNodeData;
|
|
19
|
-
position: Position;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type NodeType = 'email' | 'delay' | 'condition' | 'split' | 'action';
|
|
23
|
-
|
|
24
|
-
export interface WorkflowNodeData {
|
|
25
|
-
templateId?: string;
|
|
26
|
-
delayAmount?: number;
|
|
27
|
-
delayUnit?: DelayUnit;
|
|
28
|
-
condition?: ConditionalLogic;
|
|
29
|
-
splitPercentages?: number[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type DelayUnit = 'minutes' | 'hours' | 'days' | 'weeks';
|
|
33
|
-
|
|
34
|
-
export interface ConditionalLogic {
|
|
35
|
-
field: string;
|
|
36
|
-
operator: 'equals' | 'contains' | 'gt' | 'lt' | 'in' | 'not_in';
|
|
37
|
-
value: unknown;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface WorkflowEdge {
|
|
41
|
-
id: string;
|
|
42
|
-
source: string;
|
|
43
|
-
target: string;
|
|
44
|
-
type?: EdgeType;
|
|
45
|
-
label?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export type EdgeType = 'default' | 'conditional';
|
|
49
|
-
|
|
50
|
-
export interface Position {
|
|
51
|
-
x: number;
|
|
52
|
-
y: number;
|
|
53
|
-
}
|
package/src/utils/formatting.ts
DELETED
|
@@ -1,26 +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 { format } from 'date-fns';
|
|
10
|
-
|
|
11
|
-
export function formatPercentage(value: number, decimals = 2): string {
|
|
12
|
-
return `${value.toFixed(decimals)}%`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function formatNumber(value: number): string {
|
|
16
|
-
return value.toLocaleString();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function formatDate(date: Date, formatString = 'PPpp'): string {
|
|
20
|
-
return format(date, formatString);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function formatMetricRate(numerator: number, denominator: number): number {
|
|
24
|
-
if (denominator === 0) return 0;
|
|
25
|
-
return (numerator / denominator) * 100;
|
|
26
|
-
}
|