@mailmodo/cli 0.0.56-beta.pr58.108 → 0.0.56-beta.pr58.94
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/commands/deploy/index.js +3 -5
- package/dist/commands/init/index.js +3 -11
- package/dist/commands/login/index.js +5 -2
- package/dist/lib/api-client.d.ts +0 -2
- package/dist/lib/api-client.js +2 -2
- package/dist/lib/base-command.d.ts +13 -10
- package/dist/lib/base-command.js +27 -86
- package/dist/lib/commands/edit/diff.js +2 -2
- package/dist/lib/commands/edit/persist.js +4 -5
- package/dist/lib/commands/emails/editor.js +1 -1
- package/dist/lib/commands/init/analysis.js +1 -5
- package/dist/lib/commands/login/output.d.ts +2 -2
- package/dist/lib/commands/login/output.js +18 -5
- package/dist/lib/config.d.ts +0 -2
- package/dist/lib/config.js +10 -19
- package/dist/lib/constants.d.ts +2 -3
- package/dist/lib/constants.js +5 -4
- package/dist/lib/messages.d.ts +0 -18
- package/dist/lib/messages.js +0 -38
- package/dist/lib/templates/missing-templates.d.ts +1 -1
- package/dist/lib/templates/missing-templates.js +2 -2
- package/dist/lib/yaml-config.d.ts +0 -1
- package/dist/lib/yaml-config.js +0 -8
- package/oclif.manifest.json +32 -199
- package/package.json +1 -1
- package/dist/commands/report/index.d.ts +0 -22
- package/dist/commands/report/index.js +0 -123
- package/dist/lib/commands/report/output-entries.d.ts +0 -2
- package/dist/lib/commands/report/output-entries.js +0 -59
- package/dist/lib/commands/report/output-timeseries.d.ts +0 -2
- package/dist/lib/commands/report/output-timeseries.js +0 -28
- package/dist/lib/commands/report/output.d.ts +0 -3
- package/dist/lib/commands/report/output.js +0 -56
- package/dist/lib/commands/report/payload.d.ts +0 -2
- package/dist/lib/commands/report/payload.js +0 -49
- package/dist/lib/commands/report/prompt.d.ts +0 -2
- package/dist/lib/commands/report/prompt.js +0 -82
- package/dist/lib/commands/report/types.d.ts +0 -97
- package/dist/lib/commands/report/types.js +0 -1
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
function fmtRate(n) {
|
|
3
|
-
return (n * 100).toFixed(1) + '%';
|
|
4
|
-
}
|
|
5
|
-
export function renderTimeseries(ctx, data) {
|
|
6
|
-
const { bucket, series, timeRange } = data;
|
|
7
|
-
const from = timeRange.from.slice(0, 10);
|
|
8
|
-
const to = timeRange.to.slice(0, 10);
|
|
9
|
-
ctx.log(`\n ${chalk.dim(`Bucket: ${bucket} (${from} → ${to})`)}`);
|
|
10
|
-
ctx.log(`\n ${'Time'.padEnd(22)}${'Sent'.padEnd(7)}${'Delivered'.padEnd(11)}${'Opened'.padEnd(8)}${'Clicked'.padEnd(9)}${'OpenRate'.padEnd(10)}${'ClickRate'.padEnd(10)}BounceRate`);
|
|
11
|
-
ctx.log(` ${'─'.repeat(87)}`);
|
|
12
|
-
if (!series?.length) {
|
|
13
|
-
ctx.log(` ${chalk.dim('No timeseries data.')}`);
|
|
14
|
-
ctx.log('');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
for (const point of series) {
|
|
18
|
-
ctx.log(` ${(point.ts || '').padEnd(22)}` +
|
|
19
|
-
`${String(point.sent).padEnd(7)}` +
|
|
20
|
-
`${String(point.delivered).padEnd(11)}` +
|
|
21
|
-
`${String(point.opened).padEnd(8)}` +
|
|
22
|
-
`${String(point.clicked).padEnd(9)}` +
|
|
23
|
-
`${fmtRate(point.openRate).padEnd(10)}` +
|
|
24
|
-
`${fmtRate(point.clickRate).padEnd(10)}` +
|
|
25
|
-
`${fmtRate(point.bounceRate)}`);
|
|
26
|
-
}
|
|
27
|
-
ctx.log('');
|
|
28
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { renderEntries } from './output-entries.js';
|
|
3
|
-
import { renderTimeseries } from './output-timeseries.js';
|
|
4
|
-
function fmtRate(n) {
|
|
5
|
-
return (n * 100).toFixed(1) + '%';
|
|
6
|
-
}
|
|
7
|
-
function statsColumns(s) {
|
|
8
|
-
return [
|
|
9
|
-
String(s.sent).padEnd(7),
|
|
10
|
-
String(s.delivered).padEnd(11),
|
|
11
|
-
String(s.opened).padEnd(8),
|
|
12
|
-
String(s.clicked).padEnd(9),
|
|
13
|
-
String(s.bounced).padEnd(9),
|
|
14
|
-
fmtRate(s.openRate).padEnd(10),
|
|
15
|
-
fmtRate(s.clickRate).padEnd(10),
|
|
16
|
-
fmtRate(s.bounceRate),
|
|
17
|
-
].join('');
|
|
18
|
-
}
|
|
19
|
-
function renderGroupedTable(ctx, data) {
|
|
20
|
-
ctx.log(`\n ${'Key'.padEnd(20)}${'Sent'.padEnd(7)}${'Delivered'.padEnd(11)}` +
|
|
21
|
-
`${'Opened'.padEnd(8)}${'Clicked'.padEnd(9)}${'Bounced'.padEnd(9)}` +
|
|
22
|
-
`${'OpenRate'.padEnd(10)}${'ClickRate'.padEnd(10)}BounceRate`);
|
|
23
|
-
ctx.log(` ${'─'.repeat(93)}`);
|
|
24
|
-
for (const g of data.groups) {
|
|
25
|
-
const key = g.key.slice(0, 19).padEnd(20);
|
|
26
|
-
ctx.log(` ${key}${statsColumns(g)}`);
|
|
27
|
-
}
|
|
28
|
-
ctx.log(` ${'─'.repeat(93)}`);
|
|
29
|
-
ctx.log(` ${chalk.bold('TOTAL'.padEnd(20))}${statsColumns(data.totals)}`);
|
|
30
|
-
}
|
|
31
|
-
function renderTotalsOnly(ctx, data) {
|
|
32
|
-
const t = data.totals;
|
|
33
|
-
ctx.log(`\n Sent: ${t.sent} Delivered: ${t.delivered} Opened: ${t.opened}` +
|
|
34
|
-
` Clicked: ${t.clicked} Bounced: ${t.bounced}`);
|
|
35
|
-
ctx.log(` Open rate: ${fmtRate(t.openRate)} Click rate: ${fmtRate(t.clickRate)}` +
|
|
36
|
-
` Bounce rate: ${fmtRate(t.bounceRate)}`);
|
|
37
|
-
}
|
|
38
|
-
export function renderSummary(ctx, data) {
|
|
39
|
-
const { from, to } = data.timeRange;
|
|
40
|
-
ctx.log(`\n ${chalk.dim(`${from.slice(0, 10)} → ${to.slice(0, 10)}`)}`);
|
|
41
|
-
if (data.groups.length > 0) {
|
|
42
|
-
renderGroupedTable(ctx, data);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
renderTotalsOnly(ctx, data);
|
|
46
|
-
}
|
|
47
|
-
ctx.log('');
|
|
48
|
-
}
|
|
49
|
-
export function renderReport(ctx, data, mode) {
|
|
50
|
-
if (mode === 'entries')
|
|
51
|
-
renderEntries(ctx, data);
|
|
52
|
-
else if (mode === 'timeseries')
|
|
53
|
-
renderTimeseries(ctx, data);
|
|
54
|
-
else
|
|
55
|
-
renderSummary(ctx, data);
|
|
56
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { REPORTS } from '../../messages.js';
|
|
2
|
-
function buildTimeRange(flags) {
|
|
3
|
-
if (flags.preset)
|
|
4
|
-
return { preset: flags.preset };
|
|
5
|
-
if (flags.from && flags.to)
|
|
6
|
-
return { from: flags.from, to: flags.to };
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
function buildFilters(flags) {
|
|
10
|
-
const f = {};
|
|
11
|
-
if (flags.sequence?.length)
|
|
12
|
-
f.sequenceIds = flags.sequence;
|
|
13
|
-
if (flags['email-id']?.length)
|
|
14
|
-
f.emailIds = flags['email-id'];
|
|
15
|
-
if (flags.contact?.length)
|
|
16
|
-
f.contactEmails = flags.contact;
|
|
17
|
-
if (flags.event?.length)
|
|
18
|
-
f.events = flags.event;
|
|
19
|
-
return Object.keys(f).length > 0 ? f : undefined;
|
|
20
|
-
}
|
|
21
|
-
function validateFilterSizes(flags, onError) {
|
|
22
|
-
const arrays = [
|
|
23
|
-
flags.sequence,
|
|
24
|
-
flags['email-id'],
|
|
25
|
-
flags.contact,
|
|
26
|
-
flags.event,
|
|
27
|
-
];
|
|
28
|
-
if (arrays.some((a) => a && a.length > 100))
|
|
29
|
-
onError(REPORTS.TOO_MANY_ITEMS);
|
|
30
|
-
}
|
|
31
|
-
export function buildReportPayload(flags, onError) {
|
|
32
|
-
validateFilterSizes(flags, onError);
|
|
33
|
-
const timeRange = buildTimeRange(flags);
|
|
34
|
-
if (!timeRange)
|
|
35
|
-
onError(REPORTS.TIME_RANGE_REQUIRED);
|
|
36
|
-
const payload = {
|
|
37
|
-
groupBy: flags['group-by'],
|
|
38
|
-
output: flags.output,
|
|
39
|
-
timeRange,
|
|
40
|
-
};
|
|
41
|
-
const filters = buildFilters(flags);
|
|
42
|
-
if (filters)
|
|
43
|
-
payload.filters = filters;
|
|
44
|
-
if (flags.output === 'entries') {
|
|
45
|
-
payload.page = flags.page;
|
|
46
|
-
payload.limit = flags.limit;
|
|
47
|
-
}
|
|
48
|
-
return payload;
|
|
49
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { input, select } from '@inquirer/prompts';
|
|
2
|
-
const PRESET_CHOICES = [
|
|
3
|
-
{ name: 'Today', value: 'today' },
|
|
4
|
-
{ name: 'Yesterday', value: 'yesterday' },
|
|
5
|
-
{ name: 'Last 7 days', value: 'last7d' },
|
|
6
|
-
{ name: 'Last 30 days', value: 'last30d' },
|
|
7
|
-
{ name: 'Last 90 days', value: 'last90d' },
|
|
8
|
-
{ name: 'This month', value: 'thisMonth' },
|
|
9
|
-
{ name: 'Last month', value: 'lastMonth' },
|
|
10
|
-
];
|
|
11
|
-
const OUTPUT_CHOICES = [
|
|
12
|
-
{ name: 'Summary — grouped aggregates', value: 'summary' },
|
|
13
|
-
{ name: 'Entries — paginated event log', value: 'entries' },
|
|
14
|
-
{ name: 'Timeseries — bucketed over time', value: 'timeseries' },
|
|
15
|
-
];
|
|
16
|
-
const GROUP_BY_CHOICES = [
|
|
17
|
-
{ name: 'None (totals only)', value: 'none' },
|
|
18
|
-
{ name: 'Email template', value: 'emailId' },
|
|
19
|
-
{ name: 'Sequence ID', value: 'sequenceId' },
|
|
20
|
-
{ name: 'Day', value: 'day' },
|
|
21
|
-
{ name: 'Hour', value: 'hour' },
|
|
22
|
-
{ name: 'Contact', value: 'contact' },
|
|
23
|
-
{ name: 'Status', value: 'status' },
|
|
24
|
-
];
|
|
25
|
-
function isValidIsoDate(value) {
|
|
26
|
-
if (!value?.trim())
|
|
27
|
-
return 'Date is required';
|
|
28
|
-
if (Number.isNaN(new Date(value).getTime()))
|
|
29
|
-
return 'Enter a valid date in YYYY-MM-DD format';
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
async function promptTimeRange() {
|
|
33
|
-
const usePreset = await select({
|
|
34
|
-
choices: [
|
|
35
|
-
{ name: 'Use a preset (today, last7d, last30d…)', value: true },
|
|
36
|
-
{ name: 'Enter a custom date range', value: false },
|
|
37
|
-
],
|
|
38
|
-
message: 'Time range:',
|
|
39
|
-
});
|
|
40
|
-
if (usePreset) {
|
|
41
|
-
const preset = await select({
|
|
42
|
-
choices: PRESET_CHOICES,
|
|
43
|
-
message: 'Preset:',
|
|
44
|
-
});
|
|
45
|
-
return { preset };
|
|
46
|
-
}
|
|
47
|
-
const from = await input({
|
|
48
|
-
message: 'Start date (YYYY-MM-DD):',
|
|
49
|
-
validate: isValidIsoDate,
|
|
50
|
-
});
|
|
51
|
-
const to = await input({
|
|
52
|
-
message: 'End date, exclusive (YYYY-MM-DD):',
|
|
53
|
-
validate(v) {
|
|
54
|
-
const check = isValidIsoDate(v);
|
|
55
|
-
if (check !== true)
|
|
56
|
-
return check;
|
|
57
|
-
if (new Date(v) <= new Date(from))
|
|
58
|
-
return 'End date must be after start date';
|
|
59
|
-
return true;
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
return { from, to };
|
|
63
|
-
}
|
|
64
|
-
export async function promptReportFlags(flags) {
|
|
65
|
-
const hasTimeRange = Boolean(flags.preset || (flags.from && flags.to));
|
|
66
|
-
if (hasTimeRange)
|
|
67
|
-
return flags;
|
|
68
|
-
const timeRange = await promptTimeRange();
|
|
69
|
-
const output = await select({
|
|
70
|
-
choices: OUTPUT_CHOICES,
|
|
71
|
-
default: flags.output,
|
|
72
|
-
message: 'Output mode:',
|
|
73
|
-
});
|
|
74
|
-
const groupBy = output === 'summary'
|
|
75
|
-
? await select({
|
|
76
|
-
choices: GROUP_BY_CHOICES,
|
|
77
|
-
default: flags['group-by'],
|
|
78
|
-
message: 'Group by:',
|
|
79
|
-
})
|
|
80
|
-
: 'none';
|
|
81
|
-
return { ...flags, ...timeRange, 'group-by': groupBy, output };
|
|
82
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import type { ApiResponse } from '../../api-client.js';
|
|
2
|
-
export interface ReportFilters {
|
|
3
|
-
contactEmails?: string[];
|
|
4
|
-
emailIds?: string[];
|
|
5
|
-
events?: string[];
|
|
6
|
-
sequenceIds?: string[];
|
|
7
|
-
}
|
|
8
|
-
export type ReportTimeRange = {
|
|
9
|
-
from: string;
|
|
10
|
-
to: string;
|
|
11
|
-
} | {
|
|
12
|
-
preset: string;
|
|
13
|
-
};
|
|
14
|
-
export interface ReportPayload {
|
|
15
|
-
filters?: ReportFilters;
|
|
16
|
-
groupBy: string;
|
|
17
|
-
limit?: number;
|
|
18
|
-
output: string;
|
|
19
|
-
page?: number;
|
|
20
|
-
timeRange?: ReportTimeRange;
|
|
21
|
-
}
|
|
22
|
-
export interface ReportGroup {
|
|
23
|
-
bounceRate: number;
|
|
24
|
-
bounced: number;
|
|
25
|
-
clickRate: number;
|
|
26
|
-
clicked: number;
|
|
27
|
-
complained: number;
|
|
28
|
-
delivered: number;
|
|
29
|
-
key: string;
|
|
30
|
-
openRate: number;
|
|
31
|
-
opened: number;
|
|
32
|
-
sent: number;
|
|
33
|
-
skipped: number;
|
|
34
|
-
unsubscribed: number;
|
|
35
|
-
}
|
|
36
|
-
export type ReportTotals = Omit<ReportGroup, 'key'>;
|
|
37
|
-
export interface SummaryResponse {
|
|
38
|
-
groupBy: string;
|
|
39
|
-
groups: ReportGroup[];
|
|
40
|
-
timeRange: {
|
|
41
|
-
from: string;
|
|
42
|
-
to: string;
|
|
43
|
-
};
|
|
44
|
-
totals: ReportTotals;
|
|
45
|
-
}
|
|
46
|
-
export interface EntryRecord {
|
|
47
|
-
contact: string;
|
|
48
|
-
emailId: string;
|
|
49
|
-
reason?: null | string;
|
|
50
|
-
sequenceId: string;
|
|
51
|
-
status: string;
|
|
52
|
-
timestamp: string;
|
|
53
|
-
}
|
|
54
|
-
export interface EntriesResponse {
|
|
55
|
-
entries: EntryRecord[];
|
|
56
|
-
limit: number;
|
|
57
|
-
page: number;
|
|
58
|
-
timeRange: {
|
|
59
|
-
from: string;
|
|
60
|
-
to: string;
|
|
61
|
-
};
|
|
62
|
-
total: number;
|
|
63
|
-
}
|
|
64
|
-
export type TimeseriesPoint = ReportTotals & {
|
|
65
|
-
ts: string;
|
|
66
|
-
};
|
|
67
|
-
export interface TimeseriesResponse {
|
|
68
|
-
bucket: string;
|
|
69
|
-
series: TimeseriesPoint[];
|
|
70
|
-
timeRange: {
|
|
71
|
-
from: string;
|
|
72
|
-
to: string;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export type ReportResponse = EntriesResponse | SummaryResponse | TimeseriesResponse;
|
|
76
|
-
export type ReportFlags = {
|
|
77
|
-
contact?: string[];
|
|
78
|
-
'email-id'?: string[];
|
|
79
|
-
event?: string[];
|
|
80
|
-
from?: string;
|
|
81
|
-
'group-by': string;
|
|
82
|
-
limit: number;
|
|
83
|
-
output: string;
|
|
84
|
-
page: number;
|
|
85
|
-
preset?: string;
|
|
86
|
-
sequence?: string[];
|
|
87
|
-
to?: string;
|
|
88
|
-
};
|
|
89
|
-
export type ReportCtx = {
|
|
90
|
-
log(msg?: string): void;
|
|
91
|
-
onApiError(resp: {
|
|
92
|
-
error?: string;
|
|
93
|
-
status: number;
|
|
94
|
-
}): never;
|
|
95
|
-
post<T = Record<string, unknown>>(path: string, body?: unknown): Promise<ApiResponse<T>>;
|
|
96
|
-
spinner<T>(text: string, json: boolean, work: () => Promise<T>): Promise<T>;
|
|
97
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|