proca 1.7.4 → 1.7.5
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
CHANGED
|
@@ -445,20 +445,22 @@ set the mail to target (mtt) params
|
|
|
445
445
|
|
|
446
446
|
```
|
|
447
447
|
USAGE
|
|
448
|
-
$ proca campaign mtt [ID_NAME_DXID] --
|
|
449
|
-
|
|
450
|
-
<value>] [--email <value>]
|
|
448
|
+
$ proca campaign mtt [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
449
|
+
[--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--from <value>] [--to <value>] [--template <value>]
|
|
450
|
+
[--period <value>] [--email <value>] [--cc <value>] [--sender]
|
|
451
451
|
|
|
452
452
|
FLAGS
|
|
453
453
|
-i, --id=<value>
|
|
454
454
|
-n, --name=<the_short_name> name
|
|
455
455
|
-x, --dxid=<value> dxid
|
|
456
|
+
--cc=<value> comma-separated list of CC email addresses
|
|
456
457
|
--email=<value> test email address
|
|
457
458
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
458
|
-
--from=<value>
|
|
459
|
+
--from=<value> start date (yyyy-mm-dd)
|
|
459
460
|
--period=<value> [default: 09:09-18:18] period of the day (HH:HH-HH:HH)
|
|
461
|
+
--sender add sender to CC
|
|
460
462
|
--template=<value> mtt template to use
|
|
461
|
-
--to=<value>
|
|
463
|
+
--to=<value> end date (yyyy-mm-dd)
|
|
462
464
|
|
|
463
465
|
OUTPUT FLAGS
|
|
464
466
|
--csv Format output as csv
|
package/package.json
CHANGED
|
@@ -83,6 +83,8 @@ export default class CampaignGet extends Command {
|
|
|
83
83
|
result.period = `${hhmm(d.mtt.startAt)}↔${hhmm(d.mtt.endAt)}`;
|
|
84
84
|
result["test email"] = d.mtt.testEmail;
|
|
85
85
|
result["mtt template"] = d.mtt.template;
|
|
86
|
+
result["cc contacts"] = d.mtt.ccContacts?.join(", ");
|
|
87
|
+
result["cc sender"] = d.mtt.ccSender;
|
|
86
88
|
}
|
|
87
89
|
if (this.flags.stats) {
|
|
88
90
|
result["#Supporters"] = d.stats.supporterCount;
|
|
@@ -17,11 +17,11 @@ export default class CampaignMtt extends Command {
|
|
|
17
17
|
...this.flagify({ multiid: true }),
|
|
18
18
|
from: Flags.string({
|
|
19
19
|
description: "start date (yyyy-mm-dd)",
|
|
20
|
-
required:
|
|
20
|
+
required: false,
|
|
21
21
|
}),
|
|
22
22
|
to: Flags.string({
|
|
23
23
|
description: "end date (yyyy-mm-dd)",
|
|
24
|
-
required:
|
|
24
|
+
required: false,
|
|
25
25
|
}),
|
|
26
26
|
template: Flags.string({
|
|
27
27
|
description: "mtt template to use",
|
|
@@ -33,6 +33,13 @@ export default class CampaignMtt extends Command {
|
|
|
33
33
|
email: Flags.string({
|
|
34
34
|
description: "test email address",
|
|
35
35
|
}),
|
|
36
|
+
cc: Flags.string({
|
|
37
|
+
description: "comma-separated list of CC email addresses",
|
|
38
|
+
}),
|
|
39
|
+
sender: Flags.boolean({
|
|
40
|
+
description: "add sender to CC",
|
|
41
|
+
default: false,
|
|
42
|
+
}),
|
|
36
43
|
};
|
|
37
44
|
|
|
38
45
|
updateMtt = async (flags) => {
|
|
@@ -45,53 +52,67 @@ $mtt: CampaignMttInput!
|
|
|
45
52
|
updateCampaign (id:$id, name: $name, input: { mtt: $mtt }) {
|
|
46
53
|
id, name
|
|
47
54
|
...Mtt
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
55
|
+
}
|
|
56
|
+
${FragmentMtt}
|
|
57
|
+
}
|
|
51
58
|
`;
|
|
59
|
+
|
|
52
60
|
const testEmail = flags.email || `campaign+${flags.name}@proca.app`;
|
|
53
61
|
|
|
54
62
|
const [startPeriod, endPeriod] = flags.period.split("-");
|
|
55
63
|
const [startHour, startMinute] = startPeriod.split(":");
|
|
56
64
|
const [endHour, endMinute] = endPeriod.split(":");
|
|
57
65
|
|
|
58
|
-
const
|
|
59
|
-
|
|
66
|
+
const mtt = {
|
|
67
|
+
testEmail,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (flags.template) mtt.messageTemplate = flags.template;
|
|
71
|
+
if (flags.email) mtt.testEmail = testEmail;
|
|
72
|
+
if (flags.cc) mtt.ccContacts = flags.cc.split(",").map((e) => e.trim());
|
|
73
|
+
if (flags.sender) mtt.ccSender = flags.sender;
|
|
60
74
|
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
if (flags.from) {
|
|
76
|
+
const startAt = new Date(flags.from);
|
|
77
|
+
startAt.setHours(startHour, startMinute, 0, 0);
|
|
78
|
+
mtt.startAt = startAt.toISOString();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (flags.to) {
|
|
82
|
+
const endAt = new Date(flags.to);
|
|
83
|
+
endAt.setHours(endHour, endMinute, 0, 0);
|
|
84
|
+
mtt.endAt = endAt.toISOString();
|
|
85
|
+
}
|
|
63
86
|
|
|
64
87
|
const result = await mutation(Query, {
|
|
65
|
-
// org: props.org,
|
|
66
88
|
id: flags.id,
|
|
67
89
|
name: flags.name,
|
|
68
|
-
mtt
|
|
69
|
-
startAt: startAt.toISOString(),
|
|
70
|
-
endAt: endAt.toISOString(),
|
|
71
|
-
messageTemplate: flags.template,
|
|
72
|
-
testEmail: testEmail,
|
|
73
|
-
},
|
|
90
|
+
mtt,
|
|
74
91
|
});
|
|
75
|
-
|
|
76
92
|
return result.updateCampaign;
|
|
77
93
|
};
|
|
78
94
|
|
|
79
95
|
simplify = (d) => {
|
|
80
|
-
const result = {
|
|
81
|
-
id: d.id,
|
|
82
|
-
Name: d.name,
|
|
83
|
-
};
|
|
96
|
+
const result = { id: d.id, Name: d.name };
|
|
84
97
|
const hhmm = (date) =>
|
|
85
98
|
new Date(date).toLocaleTimeString(undefined, {
|
|
86
99
|
hour: "2-digit",
|
|
87
100
|
minute: "2-digit",
|
|
88
101
|
hour12: false,
|
|
89
102
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
if (d.mtt.startAt && d.mtt.endAt) {
|
|
104
|
+
result.from = d.mtt.startAt.substring(0, 10);
|
|
105
|
+
result.to = d.mtt.endAt.substring(0, 10);
|
|
106
|
+
result.period = `${hhmm(d.mtt.startAt)}↔${hhmm(d.mtt.endAt)}`;
|
|
107
|
+
}
|
|
93
108
|
result["test email"] = d.mtt.testEmail;
|
|
94
|
-
result["mtt template"] = d.mtt.
|
|
109
|
+
result["mtt template"] = d.mtt.messageTemplate;
|
|
110
|
+
if (d.mtt.ccContacts?.length)
|
|
111
|
+
result["cc contacts"] = d.mtt.ccContacts.join(", ");
|
|
112
|
+
if (typeof d.mtt.ccSender !== "undefined") {
|
|
113
|
+
result["cc sender"] = d.mtt.ccSender ? "yes" : "no";
|
|
114
|
+
}
|
|
115
|
+
|
|
95
116
|
return result;
|
|
96
117
|
};
|
|
97
118
|
|
|
@@ -101,7 +122,6 @@ $mtt: CampaignMttInput!
|
|
|
101
122
|
|
|
102
123
|
async run() {
|
|
103
124
|
const { args, flags } = await this.parse();
|
|
104
|
-
|
|
105
125
|
const result = await this.updateMtt(flags);
|
|
106
126
|
this.output(result);
|
|
107
127
|
}
|
|
@@ -60,6 +60,9 @@ export default class WidgetAdd extends Command {
|
|
|
60
60
|
const campapi = new CampaignGet();
|
|
61
61
|
campaign = await campapi.fetch({ name: flag.campaign });
|
|
62
62
|
flag.org = campaign.org.name;
|
|
63
|
+
if (!flag.name) {
|
|
64
|
+
flag.name = `${campaign.name}/${flag.lang}`;
|
|
65
|
+
}
|
|
63
66
|
} catch (e) {
|
|
64
67
|
console.log("error", e);
|
|
65
68
|
throw e;
|
|
@@ -70,6 +73,9 @@ export default class WidgetAdd extends Command {
|
|
|
70
73
|
throw new Error(`campaign not found: ${flag.campaign}`);
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
if (!flag.name) {
|
|
77
|
+
flag.name = `${flag.campaign}/${flag.org}/${flag.lang}`;
|
|
78
|
+
}
|
|
73
79
|
try {
|
|
74
80
|
const r = await mutation(addWidgetDocument, flag);
|
|
75
81
|
return { id: r.addActionPage.id };
|