proca 2.5.0 → 2.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.
- package/README.md +17 -52
- package/package.json +1 -1
- package/src/commands/action/add.mjs +14 -21
- package/src/commands/org/email.mjs +7 -0
- package/src/commands/user/join.mjs +1 -0
- package/src/commands/action/add/mtt.mjs +0 -192
package/README.md
CHANGED
|
@@ -48,7 +48,6 @@ you should also use the local proca-api in your [widget generator](https://githu
|
|
|
48
48
|
|
|
49
49
|
<!-- commands -->
|
|
50
50
|
* [`proca action add`](#proca-action-add)
|
|
51
|
-
* [`proca action add mtt`](#proca-action-add-mtt)
|
|
52
51
|
* [`proca action confirm`](#proca-action-confirm)
|
|
53
52
|
* [`proca action count`](#proca-action-count)
|
|
54
53
|
* [`proca action list [TITLE]`](#proca-action-list-title)
|
|
@@ -126,8 +125,8 @@ you should also use the local proca-api in your [widget generator](https://githu
|
|
|
126
125
|
USAGE
|
|
127
126
|
$ proca action add [ID_NAME_DXID...] -i <value> --firstname <value> --email <value>
|
|
128
127
|
[--json | --csv | --markdown] [--env <value>] [--simplify] [-n <the_short_name>] [-x <value>] [--testing] [--optin]
|
|
129
|
-
[--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>] [--
|
|
130
|
-
<value>] [--utm <value>] [--target <value>] [--subject <value>] [--body <value>]
|
|
128
|
+
[--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>] [--postcode
|
|
129
|
+
<value>] [--country <value>] [--utm <value>] [--target <value>] [--subject <value>] [--body <value>]
|
|
131
130
|
|
|
132
131
|
FLAGS
|
|
133
132
|
-i, --id=<value> (required) widget's id
|
|
@@ -143,6 +142,7 @@ FLAGS
|
|
|
143
142
|
--locality=<value>
|
|
144
143
|
--[no-]optin Whether the user opts in (default: false). Use --optin to enable or --no-optin to
|
|
145
144
|
explicitly disable.
|
|
145
|
+
--postcode=<value>
|
|
146
146
|
--region=<value>
|
|
147
147
|
--street=<value>
|
|
148
148
|
--subject=<value> [mtt] subject of the email
|
|
@@ -164,50 +164,6 @@ EXAMPLES
|
|
|
164
164
|
$ proca action add -i <widget_id> --firstname=John --email=john@example.org target=715a9580-cfe6-4005-9e23-61a62ddecfea --subject='MTT subject' --body='message MTT'
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
## `proca action add mtt`
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
USAGE
|
|
171
|
-
$ proca action add mtt [ID_NAME_DXID...] -i <value> --firstname <value> --email <value>
|
|
172
|
-
[--json | --csv | --markdown] [--env <value>] [--simplify] [-n <the_short_name>] [-x <value>] [--testing] [--optin]
|
|
173
|
-
[--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>] [--country
|
|
174
|
-
<value>] [--utm <value>] [--target <value>] [--subject <value>] [--body <value>]
|
|
175
|
-
|
|
176
|
-
FLAGS
|
|
177
|
-
-i, --id=<value> (required) widget's id
|
|
178
|
-
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
179
|
-
-x, --dxid=<value> dxid
|
|
180
|
-
--action_type=<value> [default: email]
|
|
181
|
-
--body=<value> [mtt] body of the email
|
|
182
|
-
--country=<value> 2-letter country iso code
|
|
183
|
-
--email=<value> (required) email
|
|
184
|
-
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
185
|
-
--firstname=<value> (required) supporter's firstname
|
|
186
|
-
--lastname=<value>
|
|
187
|
-
--locality=<value>
|
|
188
|
-
--[no-]optin Whether the user opts in (default: false). Use --optin to enable or --no-optin to
|
|
189
|
-
explicitly disable.
|
|
190
|
-
--region=<value>
|
|
191
|
-
--street=<value>
|
|
192
|
-
--subject=<value> [mtt] subject of the email
|
|
193
|
-
--target=<value> [mtt] uid of the target
|
|
194
|
-
--[no-]testing Run action in testing mode (default: true). Use --no-testing to disable.
|
|
195
|
-
--utm=<value> utm=campaign.source.medium
|
|
196
|
-
|
|
197
|
-
OUTPUT FLAGS
|
|
198
|
-
--csv Format output as csv
|
|
199
|
-
--json Format output as json
|
|
200
|
-
--markdown Format output as markdown table
|
|
201
|
-
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
202
|
-
|
|
203
|
-
EXAMPLES
|
|
204
|
-
$ proca action add mtt -i <widget_id> --firstname=John --email=john@example.org
|
|
205
|
-
|
|
206
|
-
$ proca action add mtt -i <widget_id> --firstname=John --email=john@example.org --country=FR custom1=A custom2=B
|
|
207
|
-
|
|
208
|
-
$ proca action add mtt -i <widget_id> --firstname=John --email=john@example.org target=715a9580-cfe6-4005-9e23-61a62ddecfea --subject='MTT subject' --body='message MTT'
|
|
209
|
-
```
|
|
210
|
-
|
|
211
167
|
## `proca action confirm`
|
|
212
168
|
|
|
213
169
|
Should the supporter confirm the action? it can be set either for all the widgets or an organisation or all the widgets of a campaign
|
|
@@ -1206,6 +1162,15 @@ OUTPUT FLAGS
|
|
|
1206
1162
|
|
|
1207
1163
|
DESCRIPTION
|
|
1208
1164
|
Set email service and supporter confirmation for an org
|
|
1165
|
+
|
|
1166
|
+
EXAMPLES
|
|
1167
|
+
$ proca org email myorg --mailer=ses --from=hello@example.com
|
|
1168
|
+
|
|
1169
|
+
$ proca org email myorg --mailer=mailjet
|
|
1170
|
+
|
|
1171
|
+
$ proca org email myorg --supporter-confirm --supporter-confirm-template=confirm_v2
|
|
1172
|
+
|
|
1173
|
+
$ proca org email myorg --no-supporter-confirm
|
|
1209
1174
|
```
|
|
1210
1175
|
|
|
1211
1176
|
## `proca org get`
|
|
@@ -1268,7 +1233,7 @@ EXAMPLES
|
|
|
1268
1233
|
$ proca org logo <name of the ngo>
|
|
1269
1234
|
```
|
|
1270
1235
|
|
|
1271
|
-
_See code: [src/commands/org/logo.ts](https://github.com/fixthestatusquo/proca-cli/blob/v2.5.
|
|
1236
|
+
_See code: [src/commands/org/logo.ts](https://github.com/fixthestatusquo/proca-cli/blob/v2.5.1/src/commands/org/logo.ts)_
|
|
1272
1237
|
|
|
1273
1238
|
## `proca org user get`
|
|
1274
1239
|
|
|
@@ -1782,14 +1747,14 @@ let a user join an organisation with a role
|
|
|
1782
1747
|
```
|
|
1783
1748
|
USAGE
|
|
1784
1749
|
$ proca user join [ID_NAME_DXID] [--json | --csv | --markdown] [--env <value>]
|
|
1785
|
-
[--simplify] [-n <org>] [
|
|
1750
|
+
[--simplify] [-n <org>] [-r owner|campaigner|coordinator|translator] [-u <user email>]
|
|
1786
1751
|
|
|
1787
1752
|
FLAGS
|
|
1788
1753
|
-n, --name=<org> name (technical short name, also called slug)
|
|
1754
|
+
-r, --role=<option> [default: campaigner] permission level in that org
|
|
1755
|
+
<options: owner|campaigner|coordinator|translator>
|
|
1789
1756
|
-u, --user=<user email> email, default current user
|
|
1790
1757
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
1791
|
-
--role=<option> [default: campaigner] permission level in that org
|
|
1792
|
-
<options: owner|campaigner|coordinator|translator>
|
|
1793
1758
|
|
|
1794
1759
|
OUTPUT FLAGS
|
|
1795
1760
|
--csv Format output as csv
|
|
@@ -2050,7 +2015,7 @@ EXAMPLES
|
|
|
2050
2015
|
$ proca widget external cron
|
|
2051
2016
|
```
|
|
2052
2017
|
|
|
2053
|
-
_See code: [src/commands/widget/external/cron.ts](https://github.com/fixthestatusquo/proca-cli/blob/v2.5.
|
|
2018
|
+
_See code: [src/commands/widget/external/cron.ts](https://github.com/fixthestatusquo/proca-cli/blob/v2.5.1/src/commands/widget/external/cron.ts)_
|
|
2054
2019
|
|
|
2055
2020
|
## `proca widget get`
|
|
2056
2021
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { error, stdout, ux } from "@oclif/core/ux";
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
3
2
|
import Command from "#src/procaCommand.mjs";
|
|
4
3
|
import { gql, mutation } from "#src/urql.mjs";
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
export const addAction = async (params) => {
|
|
6
|
+
const d = new ActionAdd([]);
|
|
7
|
+
if (params.utm) {
|
|
8
|
+
const [campaign, source, medium] = params.utm.split(".");
|
|
9
|
+
params.tracking = { source, medium, campaign };
|
|
10
|
+
} else params.tracking = {};
|
|
11
|
+
const data = await d.create(params);
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
6
14
|
|
|
7
15
|
export default class ActionAdd extends Command {
|
|
8
16
|
static examples = [
|
|
@@ -44,6 +52,7 @@ export default class ActionAdd extends Command {
|
|
|
44
52
|
street: Flags.string(),
|
|
45
53
|
locality: Flags.string(),
|
|
46
54
|
region: Flags.string(),
|
|
55
|
+
postcode: Flags.string(),
|
|
47
56
|
country: Flags.string({
|
|
48
57
|
description: "2-letter country iso code",
|
|
49
58
|
parse: async (input) => {
|
|
@@ -116,7 +125,6 @@ export default class ActionAdd extends Command {
|
|
|
116
125
|
};
|
|
117
126
|
values.action.actionType = "mail2target";
|
|
118
127
|
}
|
|
119
|
-
console.log(values.action.mtt);
|
|
120
128
|
|
|
121
129
|
const query = gql`
|
|
122
130
|
mutation (
|
|
@@ -139,11 +147,9 @@ export default class ActionAdd extends Command {
|
|
|
139
147
|
firstName
|
|
140
148
|
}
|
|
141
149
|
}`;
|
|
142
|
-
|
|
143
150
|
const result = await mutation(query, values);
|
|
144
151
|
|
|
145
|
-
|
|
146
|
-
return result;
|
|
152
|
+
return result.addActionContact;
|
|
147
153
|
};
|
|
148
154
|
|
|
149
155
|
parseUnknownFlags = (argv) => {
|
|
@@ -151,20 +157,6 @@ export default class ActionAdd extends Command {
|
|
|
151
157
|
const chars = def.char ? [def.char] : [];
|
|
152
158
|
return [key, ...chars];
|
|
153
159
|
});
|
|
154
|
-
/* doesn't work static=false has no effect const unknownFlags = Object.fromEntries(
|
|
155
|
-
argv
|
|
156
|
-
.filter(arg =>
|
|
157
|
-
(/^--?\w+=/.test(arg)) // --key=val or -x=val
|
|
158
|
-
)
|
|
159
|
-
.map(arg => {
|
|
160
|
-
const keyval = arg.replace(/^-+/, '').split('=')
|
|
161
|
-
return [keyval[0], keyval[1]]
|
|
162
|
-
})
|
|
163
|
-
.filter(([key]) => !knownFlags.includes(key))
|
|
164
|
-
)
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
// Extract key=val style positional args (e.g. foo=bar)
|
|
168
160
|
const kvArgs = Object.fromEntries(
|
|
169
161
|
argv
|
|
170
162
|
.filter((arg) => !arg.startsWith("-") && arg.includes("="))
|
|
@@ -175,6 +167,7 @@ export default class ActionAdd extends Command {
|
|
|
175
167
|
|
|
176
168
|
return kvArgs;
|
|
177
169
|
};
|
|
170
|
+
|
|
178
171
|
async run() {
|
|
179
172
|
const { args, flags } = await this.parse(ActionAdd, {
|
|
180
173
|
context: { strict: false /* this does not work*/ },
|
|
@@ -18,6 +18,13 @@ export default class OrgEmail extends Command {
|
|
|
18
18
|
static description =
|
|
19
19
|
"Set email service and supporter confirmation for an org";
|
|
20
20
|
|
|
21
|
+
static examples = [
|
|
22
|
+
"<%= config.bin %> <%= command.id %> myorg --mailer=ses --from=hello@example.com",
|
|
23
|
+
"<%= config.bin %> <%= command.id %> myorg --mailer=mailjet",
|
|
24
|
+
"<%= config.bin %> <%= command.id %> myorg --supporter-confirm --supporter-confirm-template=confirm_v2",
|
|
25
|
+
"<%= config.bin %> <%= command.id %> myorg --no-supporter-confirm",
|
|
26
|
+
];
|
|
27
|
+
|
|
21
28
|
static args = this.multiid();
|
|
22
29
|
|
|
23
30
|
static flags = {
|
|
@@ -14,6 +14,7 @@ export default class UserJoinOrg extends Command {
|
|
|
14
14
|
// flag with no value (-f, --force)
|
|
15
15
|
...this.flagify({ multiid: false, name: "org", char: "o" }),
|
|
16
16
|
role: Flags.string({
|
|
17
|
+
char: "r",
|
|
17
18
|
description: "permission level in that org",
|
|
18
19
|
default: "campaigner",
|
|
19
20
|
options: ["owner", "campaigner", "coordinator", "translator"],
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
-
import Command from "#src/procaCommand.mjs";
|
|
4
|
-
import { gql, mutation } from "#src/urql.mjs";
|
|
5
|
-
import { getTwitter } from "#src/util/twitter.mjs";
|
|
6
|
-
|
|
7
|
-
export default class ActionAdd extends Command {
|
|
8
|
-
static examples = [
|
|
9
|
-
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org",
|
|
10
|
-
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org --country=FR custom1=A custom2=B",
|
|
11
|
-
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org target=715a9580-cfe6-4005-9e23-61a62ddecfea --subject='MTT subject' --body='message MTT'",
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
static args = this.multiid();
|
|
15
|
-
static strict = false; //THIS DOES NOT WORK
|
|
16
|
-
|
|
17
|
-
static flags = {
|
|
18
|
-
...this.flagify({ multiid: true }),
|
|
19
|
-
id: Flags.integer({
|
|
20
|
-
char: "i",
|
|
21
|
-
description: "widget's id",
|
|
22
|
-
required: true,
|
|
23
|
-
}),
|
|
24
|
-
testing: Flags.boolean({
|
|
25
|
-
default: true,
|
|
26
|
-
allowNo: true, // ✅ enables --no-testing
|
|
27
|
-
description:
|
|
28
|
-
"Run action in testing mode (default: true). Use --no-testing to disable.",
|
|
29
|
-
}),
|
|
30
|
-
optin: Flags.boolean({
|
|
31
|
-
default: false,
|
|
32
|
-
allowNo: true, // ✅ enables --no-optin
|
|
33
|
-
description:
|
|
34
|
-
"Whether the user opts in (default: false). Use --optin to enable or --no-optin to explicitly disable.",
|
|
35
|
-
}),
|
|
36
|
-
action_type: Flags.string({
|
|
37
|
-
default: "email",
|
|
38
|
-
}),
|
|
39
|
-
firstname: Flags.string({
|
|
40
|
-
description: "supporter's firstname",
|
|
41
|
-
required: true,
|
|
42
|
-
}),
|
|
43
|
-
lastname: Flags.string(),
|
|
44
|
-
street: Flags.string(),
|
|
45
|
-
locality: Flags.string(),
|
|
46
|
-
region: Flags.string(),
|
|
47
|
-
country: Flags.string({
|
|
48
|
-
description: "2-letter country iso code",
|
|
49
|
-
parse: async (input) => {
|
|
50
|
-
if (input && !/^[A-Za-z]{2}$/.test(input)) {
|
|
51
|
-
throw new Error("Country code must be exactly 2 letters");
|
|
52
|
-
}
|
|
53
|
-
return input?.toUpperCase(); // optional: normalize to uppercase
|
|
54
|
-
},
|
|
55
|
-
}),
|
|
56
|
-
utm: Flags.string({
|
|
57
|
-
description: "utm=campaign.source.medium",
|
|
58
|
-
}),
|
|
59
|
-
email: Flags.string({
|
|
60
|
-
description: "email",
|
|
61
|
-
required: true,
|
|
62
|
-
}),
|
|
63
|
-
target: Flags.string({ description: "[mtt] uid of the target" }),
|
|
64
|
-
subject: Flags.string({ description: "[mtt] subject of the email" }),
|
|
65
|
-
body: Flags.string({ description: "[mtt] body of the email" }),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
create = async (flags) => {
|
|
69
|
-
const values = {
|
|
70
|
-
action: {
|
|
71
|
-
actionType: flags.action_type,
|
|
72
|
-
customFields: flags.customFields,
|
|
73
|
-
/* "mtt": {
|
|
74
|
-
"body": "body",
|
|
75
|
-
"files": [
|
|
76
|
-
"files"
|
|
77
|
-
],
|
|
78
|
-
"subject": "subject",
|
|
79
|
-
"targets": [
|
|
80
|
-
"targets"
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
*/
|
|
84
|
-
testing: flags.testing,
|
|
85
|
-
},
|
|
86
|
-
actionPageId: flags.id,
|
|
87
|
-
contact: {
|
|
88
|
-
address: {
|
|
89
|
-
country: flags.country,
|
|
90
|
-
locality: flags.locality,
|
|
91
|
-
postcode: flags.postcode,
|
|
92
|
-
region: flags.region,
|
|
93
|
-
street: flags.street,
|
|
94
|
-
// "streetNumber": "streetNumber"
|
|
95
|
-
},
|
|
96
|
-
email: flags.email,
|
|
97
|
-
firstName: flags.firstname,
|
|
98
|
-
lastName: flags.lastname,
|
|
99
|
-
phone: flags.phone,
|
|
100
|
-
},
|
|
101
|
-
privacy: {
|
|
102
|
-
// "leadOptIn": true,
|
|
103
|
-
optIn: flags.optin,
|
|
104
|
-
},
|
|
105
|
-
tracking: {
|
|
106
|
-
...flags.tracking,
|
|
107
|
-
location: "proca-cli/action/add",
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
if (flags.target) {
|
|
112
|
-
values.action.mtt = {
|
|
113
|
-
targets: [flags.target],
|
|
114
|
-
subject: flags.subject || "Test MTT",
|
|
115
|
-
body: flags.body || "Please ignore, this is a test",
|
|
116
|
-
};
|
|
117
|
-
values.action.actionType = "mail2target";
|
|
118
|
-
}
|
|
119
|
-
console.log(values.action.mtt);
|
|
120
|
-
|
|
121
|
-
const query = gql`
|
|
122
|
-
mutation (
|
|
123
|
-
$action: ActionInput!
|
|
124
|
-
$actionPageId: Int!
|
|
125
|
-
$contact: ContactInput!
|
|
126
|
-
$contactRef: ID
|
|
127
|
-
$privacy: ConsentInput!
|
|
128
|
-
$tracking: TrackingInput
|
|
129
|
-
) {
|
|
130
|
-
addActionContact(
|
|
131
|
-
action: $action
|
|
132
|
-
actionPageId: $actionPageId
|
|
133
|
-
contact: $contact
|
|
134
|
-
contactRef: $contactRef
|
|
135
|
-
privacy: $privacy
|
|
136
|
-
tracking: $tracking
|
|
137
|
-
) {
|
|
138
|
-
contactRef
|
|
139
|
-
firstName
|
|
140
|
-
}
|
|
141
|
-
}`;
|
|
142
|
-
|
|
143
|
-
const result = await mutation(query, values);
|
|
144
|
-
|
|
145
|
-
console.log("result", result);
|
|
146
|
-
return result;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
parseUnknownFlags = (argv) => {
|
|
150
|
-
const knownFlags = Object.entries(ActionAdd.flags).flatMap(([key, def]) => {
|
|
151
|
-
const chars = def.char ? [def.char] : [];
|
|
152
|
-
return [key, ...chars];
|
|
153
|
-
});
|
|
154
|
-
/* doesn't work static=false has no effect const unknownFlags = Object.fromEntries(
|
|
155
|
-
argv
|
|
156
|
-
.filter(arg =>
|
|
157
|
-
(/^--?\w+=/.test(arg)) // --key=val or -x=val
|
|
158
|
-
)
|
|
159
|
-
.map(arg => {
|
|
160
|
-
const keyval = arg.replace(/^-+/, '').split('=')
|
|
161
|
-
return [keyval[0], keyval[1]]
|
|
162
|
-
})
|
|
163
|
-
.filter(([key]) => !knownFlags.includes(key))
|
|
164
|
-
)
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
// Extract key=val style positional args (e.g. foo=bar)
|
|
168
|
-
const kvArgs = Object.fromEntries(
|
|
169
|
-
argv
|
|
170
|
-
.filter((arg) => !arg.startsWith("-") && arg.includes("="))
|
|
171
|
-
.map((arg) => arg.split("=")),
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
if (!Object.keys(kvArgs).length) return undefined;
|
|
175
|
-
|
|
176
|
-
return kvArgs;
|
|
177
|
-
};
|
|
178
|
-
async run() {
|
|
179
|
-
const { args, flags } = await this.parse(ActionAdd, {
|
|
180
|
-
context: { strict: false /* this does not work*/ },
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const customFields = this.parseUnknownFlags(this.argv);
|
|
184
|
-
if (customFields) flags.customFields = JSON.stringify(customFields);
|
|
185
|
-
if (flags.utm) {
|
|
186
|
-
const [campaign, source, medium] = flags.utm.split(".");
|
|
187
|
-
flags.tracking = { source, medium, campaign };
|
|
188
|
-
} else flags.tracking = {};
|
|
189
|
-
const data = await this.create(flags);
|
|
190
|
-
return this.output(data);
|
|
191
|
-
}
|
|
192
|
-
}
|