@velaro/cli 1.4.139 → 1.4.141
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/lib/commands/campaigns.js +35 -0
- package/lib/commands/workflow.js +57 -1
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* velaro campaigns - Email campaign reporting
|
|
3
3
|
*
|
|
4
4
|
* velaro campaigns benchmarks Your broadcast open/click rate vs. the Velaro average
|
|
5
|
+
* velaro campaigns revenue [--days N] Order revenue attributed to campaign email
|
|
6
|
+
* velaro campaigns revenue-window [--set DAYS] Read or set the attribution window (1-30 days)
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
9
|
import { request } from '../api.js';
|
|
@@ -27,6 +29,27 @@ async function benchmarksHandler() {
|
|
|
27
29
|
console.log(`\n ${DIM}${r.note}${RST}\n`);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
// -- revenue attribution -----------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
async function revenueHandler(argv) {
|
|
35
|
+
const days = argv.days || 90;
|
|
36
|
+
const r = await request('GET', `/CampaignReports/Performance?days=${days}`);
|
|
37
|
+
const s = r.summary || {};
|
|
38
|
+
console.log(`\n${BOLD}Campaign revenue attribution (last ${days} days)${RST}\n`);
|
|
39
|
+
console.log(` Attributed revenue: ${GRN}${s.attributedRevenue ?? 0}${RST} from ${s.attributedOrders ?? 0} orders`);
|
|
40
|
+
for (const x of (r.revenueByCampaign || [])) console.log(` campaign ${x.broadcastId}: ${x.orders} orders, revenue ${x.revenue}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function revenueWindowHandler(argv) {
|
|
44
|
+
if (argv.set) {
|
|
45
|
+
const r = await request('PUT', '/CampaignReports/RevenueSettings', { windowDays: argv.set });
|
|
46
|
+
console.log(`Attribution window set to ${r.windowDays} days.`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const r = await request('GET', '/CampaignReports/RevenueSettings');
|
|
50
|
+
console.log(`Attribution window: ${r.windowDays} days (max ${r.maxWindowDays})`);
|
|
51
|
+
}
|
|
52
|
+
|
|
30
53
|
// -- command export ------------------------------------------------------------------
|
|
31
54
|
|
|
32
55
|
export const campaignsCommand = {
|
|
@@ -38,6 +61,18 @@ export const campaignsCommand = {
|
|
|
38
61
|
describe: 'Your broadcast email open/click rate vs. the all-Velaro-customer average',
|
|
39
62
|
handler: runCommand(benchmarksHandler),
|
|
40
63
|
})
|
|
64
|
+
.command({
|
|
65
|
+
command: 'revenue',
|
|
66
|
+
describe: 'Order revenue attributed to campaign email clicks/opens',
|
|
67
|
+
builder: y2 => y2.option('days', { type: 'number', describe: 'Lookback days (default 90)' }),
|
|
68
|
+
handler: runCommand(revenueHandler),
|
|
69
|
+
})
|
|
70
|
+
.command({
|
|
71
|
+
command: 'revenue-window',
|
|
72
|
+
describe: 'Read or set the order attribution window in days (1-30)',
|
|
73
|
+
builder: y2 => y2.option('set', { type: 'number', describe: 'New window in days' }),
|
|
74
|
+
handler: runCommand(revenueWindowHandler),
|
|
75
|
+
})
|
|
41
76
|
.demandCommand(1, 'Specify a subcommand. Try: velaro campaigns --help')
|
|
42
77
|
.strict(),
|
|
43
78
|
handler: () => {},
|
package/lib/commands/workflow.js
CHANGED
|
@@ -18,11 +18,14 @@ export const workflowCommand = {
|
|
|
18
18
|
.command(workflowEnableCommand)
|
|
19
19
|
.command(workflowDisableCommand)
|
|
20
20
|
.command(workflowRunCommand)
|
|
21
|
+
.command(workflowVersionsCommand)
|
|
22
|
+
.command(workflowDownloadCommand)
|
|
23
|
+
.command(workflowRestoreCommand)
|
|
21
24
|
.command(workflowNodeOptionsCommand)
|
|
22
25
|
.command(workflowAiFollowupsCommand)
|
|
23
26
|
.command(workflowScheduleCommand)
|
|
24
27
|
.command(siteAiFollowupsCommand)
|
|
25
|
-
.demandCommand(1, 'Specify a subcommand: list, get, create, enable, disable, node-options, integrity-scan, ai-followups, ai-followups-site, schedule'),
|
|
28
|
+
.demandCommand(1, 'Specify a subcommand: list, get, create, enable, disable, versions, download, restore, node-options, integrity-scan, ai-followups, ai-followups-site, schedule'),
|
|
26
29
|
handler: () => {},
|
|
27
30
|
};
|
|
28
31
|
|
|
@@ -119,6 +122,59 @@ const workflowCreateCommand = {
|
|
|
119
122
|
}),
|
|
120
123
|
};
|
|
121
124
|
|
|
125
|
+
// ── versions / download / restore ─────────────────────────────────────────────
|
|
126
|
+
// Every save of a workflow (editor, API, MCP, Moshky, SiteSync) keeps the PRIOR state as a version;
|
|
127
|
+
// the newest 5 per workflow are kept. Restoring first saves the current state as a new version, so a
|
|
128
|
+
// restore can itself be undone. Enabled state is not changed by a restore.
|
|
129
|
+
|
|
130
|
+
const workflowVersionsCommand = {
|
|
131
|
+
command: 'versions <id>',
|
|
132
|
+
describe: 'List the last 5 prior versions of a workflow (newest first)',
|
|
133
|
+
builder: (y) => y.positional('id', { type: 'number', describe: 'Workflow ID' }),
|
|
134
|
+
handler: runCommand(async (argv) => {
|
|
135
|
+
await requireFeature('enableAutomation', 'Workflows');
|
|
136
|
+
const r = await messagingGet(`/Workflows/${argv.id}/versions`);
|
|
137
|
+
const rows = r?.versions ?? [];
|
|
138
|
+
if (!rows.length) { console.log(`No prior versions saved for workflow ${argv.id} yet.`); return; }
|
|
139
|
+
console.log(`
|
|
140
|
+
version saved (UTC) by source nodes name`);
|
|
141
|
+
for (const v of rows) {
|
|
142
|
+
console.log(`${String(v.id).padStart(7)} ${String(v.createdAt).slice(0, 19).padEnd(21)} ${String(v.savedBy ?? '').padEnd(25)} ${String(v.source ?? '').padEnd(21)} ${String(v.nodeCount).padStart(5)} ${v.name ?? ''}`);
|
|
143
|
+
}
|
|
144
|
+
console.log(`
|
|
145
|
+
${rows.length} version(s). Download: velaro workflow download ${argv.id} <version> Restore: velaro workflow restore ${argv.id} <version>`);
|
|
146
|
+
}),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const workflowDownloadCommand = {
|
|
150
|
+
command: 'download <id> <version>',
|
|
151
|
+
describe: 'Download one prior workflow version as JSON (stdout, or --out file)',
|
|
152
|
+
builder: (y) => y
|
|
153
|
+
.positional('id', { type: 'number', describe: 'Workflow ID' })
|
|
154
|
+
.positional('version', { type: 'number', describe: 'Version id from "workflow versions"' })
|
|
155
|
+
.option('out', { type: 'string', describe: 'Write the JSON to this file instead of stdout' }),
|
|
156
|
+
handler: runCommand(async (argv) => {
|
|
157
|
+
await requireFeature('enableAutomation', 'Workflows');
|
|
158
|
+
const v = await messagingGet(`/Workflows/${argv.id}/versions/${argv.version}`);
|
|
159
|
+
const json = JSON.stringify(v, null, 2);
|
|
160
|
+
if (argv.out) { fs.writeFileSync(argv.out, json); console.log(`Saved version ${argv.version} of workflow ${argv.id} to ${argv.out}`); }
|
|
161
|
+
else console.log(json);
|
|
162
|
+
}),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const workflowRestoreCommand = {
|
|
166
|
+
command: 'restore <id> <version>',
|
|
167
|
+
describe: 'Restore a prior workflow version (the current state is saved as a new version first)',
|
|
168
|
+
builder: (y) => y
|
|
169
|
+
.positional('id', { type: 'number', describe: 'Workflow ID' })
|
|
170
|
+
.positional('version', { type: 'number', describe: 'Version id from "workflow versions"' }),
|
|
171
|
+
handler: runCommand(async (argv) => {
|
|
172
|
+
await requireFeature('enableAutomation', 'Workflows');
|
|
173
|
+
const r = await messagingPost(`/Workflows/${argv.id}/versions/${argv.version}/restore`, null);
|
|
174
|
+
console.log(`Workflow ${argv.id} restored to version ${argv.version} (${r?.name ?? ''}). Enabled state unchanged (${r?.enabled ? 'enabled' : 'disabled'}). The replaced state is saved as a new version.`);
|
|
175
|
+
}),
|
|
176
|
+
};
|
|
177
|
+
|
|
122
178
|
// ── enable / disable ──────────────────────────────────────────────────────────
|
|
123
179
|
|
|
124
180
|
// ── run ────────────────────────────────────────────────────────────────────────
|
package/package.json
CHANGED