proca 1.7.0 → 1.7.3

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
@@ -48,9 +48,11 @@ 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 confirm`](#proca-action-confirm)
51
52
  * [`proca action count`](#proca-action-count)
52
53
  * [`proca action list [TITLE]`](#proca-action-list-title)
53
54
  * [`proca action replay`](#proca-action-replay)
55
+ * [`proca action requeue`](#proca-action-requeue)
54
56
  * [`proca campaign add [TITLE]`](#proca-campaign-add-title)
55
57
  * [`proca campaign close`](#proca-campaign-close)
56
58
  * [`proca campaign delete`](#proca-campaign-delete)
@@ -71,8 +73,8 @@ you should also use the local proca-api in your [widget generator](https://githu
71
73
  * [`proca org add`](#proca-org-add)
72
74
  * [`proca org crm`](#proca-org-crm)
73
75
  * [`proca org delete`](#proca-org-delete)
76
+ * [`proca org email`](#proca-org-email)
74
77
  * [`proca org get`](#proca-org-get)
75
- * [`proca org join`](#proca-org-join)
76
78
  * [`proca plugins`](#proca-plugins)
77
79
  * [`proca plugins add PLUGIN`](#proca-plugins-add-plugin)
78
80
  * [`proca plugins:inspect PLUGIN...`](#proca-pluginsinspect-plugin)
@@ -83,13 +85,21 @@ you should also use the local proca-api in your [widget generator](https://githu
83
85
  * [`proca plugins uninstall [PLUGIN]`](#proca-plugins-uninstall-plugin)
84
86
  * [`proca plugins unlink [PLUGIN]`](#proca-plugins-unlink-plugin)
85
87
  * [`proca plugins update`](#proca-plugins-update)
88
+ * [`proca service add`](#proca-service-add)
89
+ * [`proca service list`](#proca-service-list)
86
90
  * [`proca target add`](#proca-target-add)
91
+ * [`proca template add`](#proca-template-add)
92
+ * [`proca template list`](#proca-template-list)
87
93
  * [`proca user get`](#proca-user-get)
94
+ * [`proca user invite`](#proca-user-invite)
95
+ * [`proca user join`](#proca-user-join)
88
96
  * [`proca user leave`](#proca-user-leave)
89
97
  * [`proca user list`](#proca-user-list)
98
+ * [`proca user me`](#proca-user-me)
90
99
  * [`proca user reset [USER]`](#proca-user-reset-user)
91
100
  * [`proca user whoami`](#proca-user-whoami)
92
101
  * [`proca widget add`](#proca-widget-add)
102
+ * [`proca widget delete`](#proca-widget-delete)
93
103
  * [`proca widget get`](#proca-widget-get)
94
104
  * [`proca widget list`](#proca-widget-list)
95
105
 
@@ -114,12 +124,13 @@ FLAGS
114
124
  --firstname=<value> (required) supporter's firstname
115
125
  --lastname=<value>
116
126
  --locality=<value>
117
- --optin
127
+ --[no-]optin Whether the user opts in (default: false). Use --optin to enable or --no-optin to
128
+ explicitly disable.
118
129
  --region=<value>
119
130
  --street=<value>
120
131
  --subject=<value> [mtt] subject of the email
121
132
  --target=<value> [mtt] uid of the target
122
- --testing
133
+ --[no-]testing Run action in testing mode (default: true). Use --no-testing to disable.
123
134
  --utm=<value> utm=campaign.source.medium
124
135
 
125
136
  OUTPUT FLAGS
@@ -136,6 +147,33 @@ EXAMPLES
136
147
  $ proca action add -i <widget_id> --firstname=John --email=john@example.org target=715a9580-cfe6-4005-9e23-61a62ddecfea --subject='MTT subject' --body='message MTT'
137
148
  ```
138
149
 
150
+ ## `proca action confirm`
151
+
152
+ 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
153
+
154
+ ```
155
+ USAGE
156
+ $ proca action confirm [--json | --human | --csv] [--env <value>] [--simplify] [--org
157
+ <value>] [--campaign <value>] [--confirm] [--template <value>]
158
+
159
+ FLAGS
160
+ --campaign=<value> campaign collecting the action
161
+ --[no-]confirm should the supporters confirm each action
162
+ --env=<value> [default: default] allow to switch between configurations (server or users)
163
+ --org=<value> organisation collecting the action
164
+ --template=<value> template for sending the message
165
+
166
+ OUTPUT FLAGS
167
+ --csv Format output as csv
168
+ --human Format output to be read on screen by a human [default]
169
+ --json Format output as json
170
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
171
+
172
+ DESCRIPTION
173
+ Should the supporter confirm the action? it can be set either for all the widgets or an organisation or all the
174
+ widgets of a campaign
175
+ ```
176
+
139
177
  ## `proca action count`
140
178
 
141
179
  counter of actions
@@ -222,6 +260,34 @@ EXAMPLES
222
260
  $ proca action replay %pizza%
223
261
  ```
224
262
 
263
+ ## `proca action requeue`
264
+
265
+ requeue an action
266
+
267
+ ```
268
+ USAGE
269
+ $ proca action requeue --id <value> -o <org name> -q <user email> [--json | --human |
270
+ --csv] [--env <value>] [--simplify]
271
+
272
+ FLAGS
273
+ -o, --org=<org name> (required) name of the org
274
+ -q, --queue=<user email> (required) queue to redeliver to
275
+ --env=<value> [default: default] allow to switch between configurations (server or users)
276
+ --id=<value> (required) action id
277
+
278
+ OUTPUT FLAGS
279
+ --csv Format output as csv
280
+ --human Format output to be read on screen by a human [default]
281
+ --json Format output as json
282
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
283
+
284
+ DESCRIPTION
285
+ requeue an action
286
+
287
+ EXAMPLES
288
+ $ proca action requeue
289
+ ```
290
+
225
291
  ## `proca campaign add [TITLE]`
226
292
 
227
293
  ```
@@ -650,6 +716,7 @@ DESCRIPTION
650
716
 
651
717
  ALIASES
652
718
  $ proca user whoami
719
+ $ proca user me
653
720
 
654
721
  EXAMPLES
655
722
  $ proca config user
@@ -811,22 +878,25 @@ EXAMPLES
811
878
  $ proca org delete <organisation_name>
812
879
  ```
813
880
 
814
- ## `proca org get`
881
+ ## `proca org email`
815
882
 
816
- view a org
883
+ Set service, usually email backend for an org
817
884
 
818
885
  ```
819
886
  USAGE
820
- $ proca org get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
821
- [--simplify] [-n <org name>] [--config] [--keys] [--campaigns] [--users]
887
+ $ proca org email [ID_NAME_DXID] --org <value> --mailer mailjet ses stripe
888
+ test_stripe system preview webhook supabase smtp [--json | --human | --csv] [--env <value>] [--simplify] [--from
889
+ <value>]
822
890
 
823
891
  FLAGS
824
- -n, --name=<org name> name of the org
825
- --[no-]campaigns
826
- --[no-]config display the config
827
- --env=<value> [default: default] allow to switch between configurations (server or users)
828
- --[no-]keys
829
- --[no-]users
892
+ --env=<value> [default: default] allow to switch
893
+ between configurations (server or users)
894
+ --from=<value> Email address to send from (default:
895
+ <org>@proca.app)
896
+ --mailer=mailjet ses stripe test_stripe system preview webhook supabase smtp (required) [default: MAILJET] service to
897
+ send emails
898
+ --org=<value> (required) organisation running the
899
+ service
830
900
 
831
901
  OUTPUT FLAGS
832
902
  --csv Format output as csv
@@ -835,27 +905,25 @@ OUTPUT FLAGS
835
905
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
836
906
 
837
907
  DESCRIPTION
838
- view a org
839
-
840
- EXAMPLES
841
- $ proca org get <name of the ngo>
908
+ Set service, usually email backend for an org
842
909
  ```
843
910
 
844
- ## `proca org join`
911
+ ## `proca org get`
845
912
 
846
- let a user join an organisation with a role
913
+ view a org
847
914
 
848
915
  ```
849
916
  USAGE
850
- $ proca org join -o <org name> [--json | --human | --csv] [--env <value>]
851
- [--simplify] [--user <value>] [--role owner|campaigner|coordinator|translator]
917
+ $ proca org get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
918
+ [--simplify] [-n <org name>] [--config] [--keys] [--campaigns] [--users]
852
919
 
853
920
  FLAGS
854
- -o, --org=<org name> (required) name of the org
855
- --env=<value> [default: default] allow to switch between configurations (server or users)
856
- --role=<option> [default: campaigner] permission level in that org
857
- <options: owner|campaigner|coordinator|translator>
858
- --user=<value> user email
921
+ -n, --name=<org name> name of the org
922
+ --[no-]campaigns
923
+ --[no-]config display the config
924
+ --env=<value> [default: default] allow to switch between configurations (server or users)
925
+ --[no-]keys
926
+ --[no-]users
859
927
 
860
928
  OUTPUT FLAGS
861
929
  --csv Format output as csv
@@ -864,10 +932,10 @@ OUTPUT FLAGS
864
932
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
865
933
 
866
934
  DESCRIPTION
867
- let a user join an organisation with a role
935
+ view a org
868
936
 
869
937
  EXAMPLES
870
- $ proca org join
938
+ $ proca org get <name of the ngo>
871
939
  ```
872
940
 
873
941
  ## `proca plugins`
@@ -1160,6 +1228,59 @@ DESCRIPTION
1160
1228
 
1161
1229
  _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/update.ts)_
1162
1230
 
1231
+ ## `proca service add`
1232
+
1233
+ Set service, usually email backend for an org, the specific meaning of each param is dependant on the service
1234
+
1235
+ ```
1236
+ USAGE
1237
+ $ proca service add -o <value> --type
1238
+ mailjet|ses|stripe|test_stripe|preview|webhook|supabase|smtp [--json | --human | --csv] [--env <value>] [--simplify]
1239
+ [--user <value>] [--password <value>] [--host <value>] [--path <value>]
1240
+
1241
+ FLAGS
1242
+ -o, --org=<value> (required) organisation running the service
1243
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1244
+ --host=<value> server of the service
1245
+ --password=<value> credential of the account on the service
1246
+ --path=<value> path on the service
1247
+ --type=<option> (required) [default: system] type of the service
1248
+ <options: mailjet|ses|stripe|test_stripe|preview|webhook|supabase|smtp>
1249
+ --user=<value> credential of the account on the service
1250
+
1251
+ OUTPUT FLAGS
1252
+ --csv Format output as csv
1253
+ --human Format output to be read on screen by a human [default]
1254
+ --json Format output as json
1255
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1256
+
1257
+ DESCRIPTION
1258
+ Set service, usually email backend for an org, the specific meaning of each param is dependant on the service
1259
+ ```
1260
+
1261
+ ## `proca service list`
1262
+
1263
+ list services set for an organisation
1264
+
1265
+ ```
1266
+ USAGE
1267
+ $ proca service list -o <value> [--json | --human | --csv] [--env <value>]
1268
+ [--simplify]
1269
+
1270
+ FLAGS
1271
+ -o, --org=<value> (required) organisation running the service
1272
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1273
+
1274
+ OUTPUT FLAGS
1275
+ --csv Format output as csv
1276
+ --human Format output to be read on screen by a human [default]
1277
+ --json Format output as json
1278
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1279
+
1280
+ DESCRIPTION
1281
+ list services set for an organisation
1282
+ ```
1283
+
1163
1284
  ## `proca target add`
1164
1285
 
1165
1286
  ```
@@ -1181,6 +1302,53 @@ OUTPUT FLAGS
1181
1302
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1182
1303
  ```
1183
1304
 
1305
+ ## `proca template add`
1306
+
1307
+ ```
1308
+ USAGE
1309
+ $ proca template add -o <value> [--json | --human | --csv] [--env <value>] [--simplify]
1310
+ [--type thankyou|doi|confirm|doi_thankyou|doi_confirm] [-l <locale>] [-n by default type@language] [-s 'template:'
1311
+ + type]
1312
+
1313
+ FLAGS
1314
+ -l, --lang=<locale> [default: en] language
1315
+ -n, --name=by default type@language name
1316
+ -o, --org=<value> (required) organisation
1317
+ -s, --subject='template:' + type subject
1318
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1319
+ --type=<option> [default: thankyou]
1320
+ <options: thankyou|doi|confirm|doi_thankyou|doi_confirm>
1321
+
1322
+ OUTPUT FLAGS
1323
+ --csv Format output as csv
1324
+ --human Format output to be read on screen by a human [default]
1325
+ --json Format output as json
1326
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1327
+ ```
1328
+
1329
+ ## `proca template list`
1330
+
1331
+ list services set for an organisation
1332
+
1333
+ ```
1334
+ USAGE
1335
+ $ proca template list -o <value> [--json | --human | --csv] [--env <value>]
1336
+ [--simplify]
1337
+
1338
+ FLAGS
1339
+ -o, --org=<value> (required) organisation having the templates
1340
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1341
+
1342
+ OUTPUT FLAGS
1343
+ --csv Format output as csv
1344
+ --human Format output to be read on screen by a human [default]
1345
+ --json Format output as json
1346
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1347
+
1348
+ DESCRIPTION
1349
+ list services set for an organisation
1350
+ ```
1351
+
1184
1352
  ## `proca user get`
1185
1353
 
1186
1354
  fetch the information about a user
@@ -1209,19 +1377,77 @@ EXAMPLES
1209
1377
  $ proca user get
1210
1378
  ```
1211
1379
 
1380
+ ## `proca user invite`
1381
+
1382
+ invite a user to join an organisation with a role
1383
+
1384
+ ```
1385
+ USAGE
1386
+ $ proca user invite -o <org name> -u <user email> [--json | --human | --csv] [--env
1387
+ <value>] [--simplify] [--role owner|campaigner|coordinator|translator]
1388
+
1389
+ FLAGS
1390
+ -o, --org=<org name> (required) name of the org
1391
+ -u, --user=<user email> (required) email
1392
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1393
+ --role=<option> [default: campaigner] permission level in that org
1394
+ <options: owner|campaigner|coordinator|translator>
1395
+
1396
+ OUTPUT FLAGS
1397
+ --csv Format output as csv
1398
+ --human Format output to be read on screen by a human [default]
1399
+ --json Format output as json
1400
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1401
+
1402
+ DESCRIPTION
1403
+ invite a user to join an organisation with a role
1404
+
1405
+ EXAMPLES
1406
+ $ proca user invite
1407
+ ```
1408
+
1409
+ ## `proca user join`
1410
+
1411
+ let a user join an organisation with a role
1412
+
1413
+ ```
1414
+ USAGE
1415
+ $ proca user join -o <org name> [--json | --human | --csv] [--env <value>]
1416
+ [--simplify] [--role owner|campaigner|coordinator|translator] [-u <user email>]
1417
+
1418
+ FLAGS
1419
+ -o, --org=<org name> (required) name of the org
1420
+ -u, --user=<user email> email
1421
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1422
+ --role=<option> [default: campaigner] permission level in that org
1423
+ <options: owner|campaigner|coordinator|translator>
1424
+
1425
+ OUTPUT FLAGS
1426
+ --csv Format output as csv
1427
+ --human Format output to be read on screen by a human [default]
1428
+ --json Format output as json
1429
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1430
+
1431
+ DESCRIPTION
1432
+ let a user join an organisation with a role
1433
+
1434
+ EXAMPLES
1435
+ $ proca user join
1436
+ ```
1437
+
1212
1438
  ## `proca user leave`
1213
1439
 
1214
1440
  leave a org
1215
1441
 
1216
1442
  ```
1217
1443
  USAGE
1218
- $ proca user leave --email <user email> -o <org name> [--json | --human | --csv]
1219
- [--env <value>] [--simplify]
1444
+ $ proca user leave -o <org name> [--json | --human | --csv] [--env <value>]
1445
+ [--simplify] [-u <user email>]
1220
1446
 
1221
1447
  FLAGS
1222
- -o, --org=<org name> (required) name of the org
1223
- --email=<user email> (required) email
1224
- --env=<value> [default: default] allow to switch between configurations (server or users)
1448
+ -o, --org=<org name> (required) name of the org
1449
+ -u, --user=<user email> email
1450
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1225
1451
 
1226
1452
  OUTPUT FLAGS
1227
1453
  --csv Format output as csv
@@ -1262,6 +1488,34 @@ EXAMPLES
1262
1488
  $ proca user list %pizza%
1263
1489
  ```
1264
1490
 
1491
+ ## `proca user me`
1492
+
1493
+ fetch the information about the current user (based on the token)
1494
+
1495
+ ```
1496
+ USAGE
1497
+ $ proca user me [--json | --human | --csv] [--env <value>] [--simplify]
1498
+
1499
+ FLAGS
1500
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1501
+
1502
+ OUTPUT FLAGS
1503
+ --csv Format output as csv
1504
+ --human Format output to be read on screen by a human [default]
1505
+ --json Format output as json
1506
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1507
+
1508
+ DESCRIPTION
1509
+ fetch the information about the current user (based on the token)
1510
+
1511
+ ALIASES
1512
+ $ proca user whoami
1513
+ $ proca user me
1514
+
1515
+ EXAMPLES
1516
+ $ proca user me
1517
+ ```
1518
+
1265
1519
  ## `proca user reset [USER]`
1266
1520
 
1267
1521
  Reset user API token
@@ -1311,6 +1565,7 @@ DESCRIPTION
1311
1565
 
1312
1566
  ALIASES
1313
1567
  $ proca user whoami
1568
+ $ proca user me
1314
1569
 
1315
1570
  EXAMPLES
1316
1571
  $ proca user whoami
@@ -1338,6 +1593,31 @@ OUTPUT FLAGS
1338
1593
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1339
1594
  ```
1340
1595
 
1596
+ ## `proca widget delete`
1597
+
1598
+ Delete a widget
1599
+
1600
+ ```
1601
+ USAGE
1602
+ $ proca widget delete [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
1603
+ [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
1604
+
1605
+ FLAGS
1606
+ -i, --id=<value>
1607
+ -n, --name=<the_short_name> name
1608
+ -x, --dxid=<value> dxid
1609
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1610
+
1611
+ OUTPUT FLAGS
1612
+ --csv Format output as csv
1613
+ --human Format output to be read on screen by a human [default]
1614
+ --json Format output as json
1615
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1616
+
1617
+ DESCRIPTION
1618
+ Delete a widget
1619
+ ```
1620
+
1341
1621
  ## `proca widget get`
1342
1622
 
1343
1623
  view a widget
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proca",
3
3
  "description": "Access the proca api",
4
- "version": "1.7.0",
4
+ "version": "1.7.3",
5
5
  "author": "Xavier",
6
6
  "bin": {
7
7
  "proca": "proca-cli"
@@ -1,6 +1,5 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
- import OrgGet from "#src/commands/org/get.mjs";
4
3
  import Command from "#src/procaCommand.mjs";
5
4
  import { gql, mutation } from "#src/urql.mjs";
6
5
  import { getTwitter } from "#src/util/twitter.mjs";
@@ -22,8 +21,18 @@ export default class ActionAdd extends Command {
22
21
  description: "widget's id",
23
22
  required: true,
24
23
  }),
25
- testing: Flags.boolean({ default: true }),
26
- optin: Flags.boolean({ default: false }),
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
+ }),
27
36
  action_type: Flags.string({
28
37
  default: "register",
29
38
  }),
@@ -0,0 +1,93 @@
1
+ import { Flags } from "@oclif/core";
2
+ import Command from "#src/procaCommand.mjs";
3
+ import { gql, mutation, query } from "#src/urql.mjs";
4
+
5
+ export default class Actionconfirm extends Command {
6
+ static description =
7
+ "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";
8
+
9
+ static flags = {
10
+ ...super.globalFlags,
11
+ org: Flags.string({
12
+ aliases: ["name", "o"],
13
+ description: "organisation collecting the action",
14
+ exactlyOne: ["org", "campaign"],
15
+ }),
16
+ campaign: Flags.string({
17
+ aliases: ["c"],
18
+ description: "campaign collecting the action",
19
+ }),
20
+ confirm: Flags.boolean({
21
+ description: "should the supporters confirm each action",
22
+ default: true,
23
+ allowNo: true,
24
+ }),
25
+ template: Flags.string({
26
+ description: "template for sending the message",
27
+ }),
28
+ };
29
+
30
+ async mutate(flags) {
31
+ const DocumentOrg = gql`
32
+ mutation UpdateOrgProcessing(
33
+ $name: String!
34
+ $confirm: Boolean!
35
+ $template: String
36
+ ) {
37
+ updateOrgProcessing(
38
+ name: $name
39
+ supporterConfirmTemplate: $template
40
+ supporterConfirm: $confirm
41
+ ) {
42
+ id
43
+ name
44
+ processing {
45
+ supporterConfirm
46
+ supporterConfirmTemplate
47
+ }
48
+ }
49
+ }
50
+ `;
51
+ const DocumentCampaign = gql`
52
+ mutation UpdateCampaignProcessing(
53
+ $name: String!
54
+ $confirm: Boolean!
55
+ $template: String
56
+ ) {
57
+ updateCampaignProcessing(
58
+ name: $name
59
+ supporterConfirmTemplate: $template
60
+ supporterConfirm: $confirm
61
+ ) {
62
+ id
63
+ name
64
+ campaignProcessing {
65
+ supporterConfirm
66
+ supporterConfirmTemplate
67
+ }
68
+ }
69
+ }
70
+ `;
71
+ const Document = flags.org ? DocumentOrg : DocumentCampaign;
72
+
73
+ const result = await mutation(Document, {
74
+ name: flags.org || flags.campaign,
75
+ confirm: flags.confirm,
76
+ template: flags.template,
77
+ });
78
+ return result.updateOrgProcessing || result.updateCommandProcessing;
79
+ }
80
+
81
+ simplify = (d) => ({
82
+ id: d.id,
83
+ name: d.name,
84
+ template: d.processing.supporterConfirmTemplate,
85
+ confirm: d.processing.supporterConfirm,
86
+ });
87
+ async run() {
88
+ const { flags } = await this.parse();
89
+ const result = await this.mutate(flags);
90
+
91
+ this.output(result);
92
+ }
93
+ }
@@ -0,0 +1,60 @@
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
+
6
+ export default class ActionRequeue extends Command {
7
+ static description = "requeue an action";
8
+
9
+ static examples = ["<%= config.bin %> <%= command.id %>"];
10
+
11
+ static flags = {
12
+ ...super.globalFlags,
13
+ id: Flags.string({
14
+ description: "action id",
15
+ parse: (input) => Number.parseInt(input, 10),
16
+ required: true,
17
+ }),
18
+ org: Flags.string({
19
+ char: "o",
20
+ required: true,
21
+ description: "name of the org",
22
+ helpValue: "<org name>",
23
+ }),
24
+ queue: Flags.string({
25
+ char: "q",
26
+ required: true,
27
+ description: "queue to redeliver to",
28
+ helpValue: "<user email>",
29
+ }),
30
+ };
31
+
32
+ mutate = async (org) => {
33
+ const Document = gql`
34
+ mutation ($user: String!, $role: String!, $org: String!, message: String) {
35
+ inviteOrgUser(orgName: $org, message: $message, input :{ email: $user, role: $role}) {
36
+ objectId
37
+ code
38
+ }
39
+ }
40
+ `;
41
+ const result = await mutation(Document, {
42
+ org,
43
+ role,
44
+ user,
45
+ });
46
+ //return result.users.map (d => {d.config = JSON.parse(d.config); return d});
47
+ return result.inviteOrg;
48
+ };
49
+
50
+ table = (r) => {
51
+ super.table(r, null, null);
52
+ };
53
+
54
+ async run() {
55
+ throw new Error("NOT IMPLEMENTED");
56
+ const { args, flags } = await this.parse();
57
+ const data = await this.mutate(flag);
58
+ this.output(data);
59
+ }
60
+ }
@@ -4,7 +4,7 @@ import Command from "#src/procaCommand.mjs";
4
4
  import { gql, query } from "#src/urql.mjs";
5
5
 
6
6
  export default class UserList extends Command {
7
- static aliases = ["user:whoami"];
7
+ static aliases = ["user:whoami", "user:me"];
8
8
  static description =
9
9
  "fetch the information about the current user (based on the token)";
10
10
 
@@ -14,7 +14,7 @@ export default class UserList extends Command {
14
14
  ...super.globalFlags,
15
15
  };
16
16
 
17
- fetch = async (params) => {
17
+ fetch = async () => {
18
18
  const Document = gql`
19
19
  query {
20
20
  currentUser {
@@ -13,7 +13,6 @@ export default class OrgAdd extends Command {
13
13
  ];
14
14
 
15
15
  static flags = {
16
- // flag with no value (-f, --force)
17
16
  ...super.globalFlags,
18
17
  twitter: Flags.string({
19
18
  description: "twitter account",
@@ -0,0 +1,83 @@
1
+ import { Flags } from "@oclif/core";
2
+ import Command from "#src/procaCommand.mjs";
3
+ import { gql, mutation, query } from "#src/urql.mjs";
4
+
5
+ const SERVICE_NAMES = [
6
+ "MAILJET",
7
+ "SES",
8
+ "STRIPE",
9
+ "TEST_STRIPE",
10
+ "SYSTEM",
11
+ "PREVIEW",
12
+ "WEBHOOK",
13
+ "SUPABASE",
14
+ "SMTP",
15
+ ].map((d) => d.toLowerCase());
16
+
17
+ export default class OrgEmail extends Command {
18
+ static description = "Set service, usually email backend for an org";
19
+
20
+ static args = this.multiid();
21
+ static flags = {
22
+ ...super.globalFlags,
23
+ org: Flags.string({
24
+ aliases: ["name", "o"],
25
+ description: "organisation running the service",
26
+ required: true,
27
+ }),
28
+ mailer: Flags.string({
29
+ description: "service to send emails",
30
+ options: SERVICE_NAMES,
31
+ helpValue: SERVICE_NAMES,
32
+ required: true,
33
+ default: "MAILJET",
34
+ }),
35
+ from: Flags.string({
36
+ description: "Email address to send from (default: <org>@proca.app)",
37
+ }),
38
+ };
39
+
40
+ async mutate(flags) {
41
+ flags.from = flags.from || `${flags.org}@proca.app`;
42
+
43
+ const Document = gql`
44
+ mutation UpdateOrgProcessing(
45
+ $name: String!
46
+ $emailBackend: ServiceName!
47
+ $emailFrom: String!
48
+ ) {
49
+ updateOrgProcessing(
50
+ name: $name
51
+ emailBackend: $emailBackend
52
+ emailFrom: $emailFrom
53
+ ) {
54
+ id
55
+ name
56
+ processing {
57
+ emailBackend
58
+ emailFrom
59
+ }
60
+ }
61
+ }
62
+ `;
63
+ const result = await mutation(Document, {
64
+ name: flags.org,
65
+ emailBackend: flags.mailer.toUpperCase(),
66
+ emailFrom: flags.from,
67
+ });
68
+ return result.updateOrgProcessing;
69
+ }
70
+
71
+ simplify = (d) => ({
72
+ id: d.id,
73
+ name: d.name,
74
+ mailer: d.processing.emailBackend,
75
+ from: d.processing.emailFrom,
76
+ });
77
+ async run() {
78
+ const { flags } = await this.parse();
79
+ const result = await this.mutate(flags);
80
+
81
+ this.output(result);
82
+ }
83
+ }
@@ -90,7 +90,6 @@ export default class OrgGet extends Command {
90
90
  withKeys: params.keys || true,
91
91
  });
92
92
  // result.org.config = JSON.parse (result.org.config);
93
- console.log(result.org);
94
93
  return result.org;
95
94
  };
96
95
 
@@ -0,0 +1,78 @@
1
+ import { Flags } from "@oclif/core";
2
+ import Command from "#src/procaCommand.mjs";
3
+ import { gql, mutation, query } from "#src/urql.mjs";
4
+
5
+ const SERVICE_NAMES = [
6
+ "MAILJET",
7
+ "SES",
8
+ "STRIPE",
9
+ "TEST_STRIPE",
10
+ "PREVIEW",
11
+ // "SYSTEM", not an external service type, just an alias
12
+ "WEBHOOK",
13
+ "SUPABASE",
14
+ "SMTP",
15
+ ].map((d) => d.toLowerCase());
16
+
17
+ export default class OrgEmail extends Command {
18
+ static description =
19
+ "Set service, usually email backend for an org, the specific meaning of each param is dependant on the service";
20
+
21
+ static flags = {
22
+ ...super.globalFlags,
23
+ org: Flags.string({
24
+ char: "o",
25
+ description: "organisation running the service",
26
+ required: true,
27
+ }),
28
+ type: Flags.string({
29
+ description: "type of the service",
30
+ options: SERVICE_NAMES,
31
+ required: true,
32
+ default: "system",
33
+ }),
34
+ user: Flags.string({
35
+ description: "credential of the account on the service",
36
+ }),
37
+ password: Flags.string({
38
+ description: "credential of the account on the service",
39
+ }),
40
+ host: Flags.string({
41
+ description: "server of the service",
42
+ }),
43
+ path: Flags.string({
44
+ description: "path on the service",
45
+ }),
46
+ };
47
+
48
+ async mutate(flags) {
49
+ const Document = gql`
50
+ mutation ($id: Int, $input: ServiceInput!, $orgName: String!) {
51
+ upsertService(id: $id, input: $input, orgName: $orgName) { host id name path user }
52
+ }
53
+ `;
54
+
55
+ const variables = {
56
+ // id: flags.id || null
57
+ orgName: flags.org,
58
+ input: {
59
+ name: flags.type.toUpperCase(),
60
+ host: flags.host || "",
61
+ path: flags.path || "",
62
+ user: flags.user || "",
63
+ password: flags.password || "",
64
+ },
65
+ };
66
+
67
+ const result = await mutation(Document, variables);
68
+ return result.upsertService;
69
+ }
70
+
71
+ table = (r) => super.table(r, null, null);
72
+
73
+ async run() {
74
+ const { flags } = await this.parse();
75
+ const result = await this.mutate(flags);
76
+ this.output(result);
77
+ }
78
+ }
@@ -0,0 +1,24 @@
1
+ import { Flags } from "@oclif/core";
2
+ import Org from "#src/commands/org/get.mjs";
3
+ import Command from "#src/procaCommand.mjs";
4
+ import { gql, mutation, query } from "#src/urql.mjs";
5
+
6
+ export default class OrgServices extends Command {
7
+ static description = "list services set for an organisation";
8
+
9
+ static flags = {
10
+ ...super.globalFlags,
11
+ org: Flags.string({
12
+ char: "o",
13
+ description: "organisation running the service",
14
+ required: true,
15
+ }),
16
+ };
17
+
18
+ async run() {
19
+ const { flags } = await this.parse();
20
+ const orgCmd = new Org({}, this.config);
21
+ const org = await orgCmd.fetch({ name: flags.org });
22
+ this.output(org.services);
23
+ }
24
+ }
@@ -0,0 +1,97 @@
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
+
6
+ export default class TemplateAdd extends Command {
7
+ //static args = { path: { description: "" } };
8
+
9
+ static flags = {
10
+ // flag with no value (-f, --force)
11
+ ...super.globalFlags,
12
+ org: Flags.string({
13
+ char: "o",
14
+ description: "organisation",
15
+ required: true,
16
+ }),
17
+ type: Flags.string({
18
+ options: ["thankyou", "doi", "confirm", "doi_thankyou", "doi_confirm"],
19
+ default: "thankyou",
20
+ }),
21
+ lang: Flags.string({
22
+ char: "l",
23
+ description: "language",
24
+ default: "en",
25
+ helpValue: "<locale>",
26
+ }),
27
+ name: Flags.string({
28
+ char: "n",
29
+ description: "name",
30
+ helpValue: "by default type@language",
31
+ }),
32
+ subject: Flags.string({
33
+ char: "s",
34
+ description: "subject",
35
+ helpValue: "'template:' + type",
36
+ }),
37
+ };
38
+
39
+ create = async (flag) => {
40
+ const orgName = flag.org;
41
+
42
+ const addTemplateDocument = gql`
43
+ mutation (
44
+ $org: String!
45
+ $name: String!
46
+ $lang: String!
47
+ $subject: String!
48
+ $text: String
49
+ $html: String
50
+ ) {
51
+ upsertTemplate(
52
+ orgName: $org
53
+ input: { name: $name, locale: $lang, subject:$subject,text: $text, html: $html }
54
+ )
55
+ }
56
+ `;
57
+
58
+ if (!flag.name) {
59
+ flag.name = flag.type; // +'@'+flag.lang;
60
+ }
61
+
62
+ if (!flag.subject) {
63
+ flag.subject = `template ${flag.type} in ${flag.lang}`;
64
+ }
65
+
66
+ if (!flag.text) {
67
+ flag.text = "This is the email body";
68
+ }
69
+ if (!flag.html) {
70
+ flag.html = "This is the email html body";
71
+ }
72
+ try {
73
+ const r = await mutation(addTemplateDocument, flag);
74
+ } catch (e) {
75
+ const errors = e.graphQLErrors;
76
+ console.log(JSON.stringify(e.graphQLErrors, null, 2));
77
+ if (errors[0].path[1] === "name") {
78
+ this.error(`invalid name (already taken?): ${flag.name}`);
79
+ throw new Error(errors[0].message);
80
+ }
81
+ if (errors[0].extensions?.code === "permission_denied") {
82
+ console.error("permission denied to create", flag.name, flag.org);
83
+ throw new Error(errors[0].message);
84
+ }
85
+ throw new Error(errors[0].message);
86
+ }
87
+ };
88
+
89
+ async run() {
90
+ const { args, flags } = await this.parse();
91
+
92
+ // const org = { name: flags.twitter || flags.name, config: {} };
93
+
94
+ const data = await this.create(flags);
95
+ return this.output(data);
96
+ }
97
+ }
@@ -0,0 +1,61 @@
1
+ import { Flags } from "@oclif/core";
2
+ import Org from "#src/commands/org/get.mjs";
3
+ import Command from "#src/procaCommand.mjs";
4
+ import { gql, mutation, query } from "#src/urql.mjs";
5
+
6
+ export default class OrgTemplate extends Command {
7
+ static description = "list services set for an organisation";
8
+
9
+ static flags = {
10
+ ...super.globalFlags,
11
+ org: Flags.string({
12
+ char: "o",
13
+ description: "organisation having the templates",
14
+ required: true,
15
+ }),
16
+ };
17
+
18
+ fetch = async (org) => {
19
+ const GetOrgDocument = gql`
20
+ query GetOrg($name: String!) {
21
+ org (name: $name) {
22
+ id name title
23
+ personalData {
24
+ supporterConfirm
25
+ supporterConfirmTemplate
26
+ }
27
+ processing {
28
+ emailFrom
29
+ emailTemplates
30
+ supporterConfirm
31
+ supporterConfirmTemplate
32
+ }
33
+
34
+ }
35
+ }
36
+ `;
37
+
38
+ const result = await query(GetOrgDocument, {
39
+ name: org,
40
+ });
41
+ const supporterConfirm = (tplName) => {
42
+ if (
43
+ tplName.split("@")[0] === result.org.processing.supporterConfirmTemplate
44
+ ) {
45
+ return result.org.processing.supporterConfirm ? "enabled" : "disabled";
46
+ }
47
+ return "";
48
+ };
49
+ const tpl = result.org.processing?.emailTemplates?.map((d) => ({
50
+ name: d,
51
+ actionConfirm: supporterConfirm(d),
52
+ }));
53
+ return tpl;
54
+ };
55
+
56
+ async run() {
57
+ const { flags } = await this.parse();
58
+ const tpl = await this.fetch(flags.org);
59
+ this.output(tpl);
60
+ }
61
+ }
@@ -0,0 +1,56 @@
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
+
6
+ export default class UserInviteOrg extends Command {
7
+ static description = "invite a user to join an organisation with a role";
8
+
9
+ static examples = ["<%= config.bin %> <%= command.id %>"];
10
+
11
+ static flags = {
12
+ ...super.globalFlags,
13
+ role: Flags.string({
14
+ description: "permission level in that org",
15
+ default: "campaigner",
16
+ options: ["owner", "campaigner", "coordinator", "translator"],
17
+ }),
18
+ org: Flags.string({
19
+ char: "o",
20
+ required: true,
21
+ description: "name of the org",
22
+ helpValue: "<org name>",
23
+ }),
24
+ user: Flags.string({
25
+ char: "u",
26
+ required: true,
27
+ description: "email",
28
+ helpValue: "<user email>",
29
+ }),
30
+ };
31
+
32
+ invite = async (params) => {
33
+ const Document = gql`
34
+ mutation ($user: String!, $role: String!, $org: String!, $message: String) {
35
+ inviteOrgUser(orgName: $org, message: $message, input: { email: $user, role: $role}) {
36
+ objectId
37
+ code
38
+ }
39
+ }
40
+ `;
41
+ const result = await mutation(Document, params);
42
+ //return result.users.map (d => {d.config = JSON.parse(d.config); return d});
43
+ console.log(result);
44
+ return result.inviteOrgUser;
45
+ };
46
+
47
+ table = (r) => {
48
+ super.table(r, null, null);
49
+ };
50
+
51
+ async run() {
52
+ const { args, flags } = await this.parse();
53
+ const data = await this.invite(flags);
54
+ this.output(data);
55
+ }
56
+ }
@@ -10,7 +10,6 @@ export default class UserJoinOrg extends Command {
10
10
 
11
11
  static flags = {
12
12
  ...super.globalFlags,
13
- user: Flags.string({ description: "user email" }),
14
13
  role: Flags.string({
15
14
  description: "permission level in that org",
16
15
  default: "campaigner",
@@ -22,6 +21,11 @@ export default class UserJoinOrg extends Command {
22
21
  description: "name of the org",
23
22
  helpValue: "<org name>",
24
23
  }),
24
+ user: Flags.string({
25
+ char: "u",
26
+ description: "email",
27
+ helpValue: "<user email>",
28
+ }),
25
29
  };
26
30
 
27
31
  join = async (org) => {
@@ -40,9 +44,8 @@ mutation ($name: String!) {
40
44
  const result = await mutation(Document, {
41
45
  name: org,
42
46
  });
43
- console.log(result);
44
- return result.status;
45
47
  //return result.users.map (d => {d.config = JSON.parse(d.config); return d});
48
+ return { ...result.joinOrg.org, status: result.joinOrg.status };
46
49
  };
47
50
 
48
51
  mutate = async (params) => {
@@ -58,20 +61,21 @@ mutation ($org: String!, $user: String!, $role: String = "campaigner") {
58
61
  org: params.org,
59
62
  role: params.role,
60
63
  });
61
- console.log(result);
62
- return result.status;
63
- //return result.users.map (d => {d.config = JSON.parse(d.config); return d});
64
+ return result.addOrgUser;
65
+ };
66
+
67
+ table = (r) => {
68
+ super.table(r, null, null);
64
69
  };
65
70
 
66
71
  async run() {
67
- console.log("WIP, probably not working");
68
72
  const { args, flags } = await this.parse();
69
-
73
+ let data = undefined;
70
74
  if (!flags.user) {
71
75
  data = await this.join(flags.org);
72
76
  } else {
73
77
  data = await this.mutate(flags);
74
78
  }
75
- console.log(data);
79
+ this.output(data);
76
80
  }
77
81
  }
@@ -1,5 +1,6 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
+ import getCurrentUser from "#src/commands/config/user.mjs";
3
4
  import Command from "#src/procaCommand.mjs";
4
5
  import { gql, mutation } from "#src/urql.mjs";
5
6
 
@@ -15,9 +16,9 @@ export default class OrgLeave extends Command {
15
16
  static flags = {
16
17
  // flag with no value (-f, --force)
17
18
  ...super.globalFlags,
18
- email: Flags.string({
19
+ user: Flags.string({
20
+ char: "u",
19
21
  description: "email",
20
- required: true,
21
22
  helpValue: "<user email>",
22
23
  }),
23
24
  org: Flags.string({
@@ -28,16 +29,16 @@ export default class OrgLeave extends Command {
28
29
  }),
29
30
  };
30
31
 
31
- mutate = async ({ email, org }) => {
32
+ mutate = async ({ user, org }) => {
32
33
  const Document = gql`
33
34
  mutation ($email: String!, $org: String!) {
34
35
  deleteOrgUser(email: $email, orgName: $org) { status }
35
36
  }`;
36
37
  const result = await mutation(Document, {
37
- email: email,
38
+ email: user,
38
39
  org: org,
39
40
  });
40
- return result.deleteOrgUser.status;
41
+ return result.deleteOrgUser;
41
42
  };
42
43
 
43
44
  table = (r) => {
@@ -46,7 +47,11 @@ mutation ($email: String!, $org: String!) {
46
47
 
47
48
  async run() {
48
49
  const { args, flags } = await this.parse();
50
+ if (!flags.user) {
51
+ const me = await this.getCurrentUser();
52
+ flags.user = me.email;
53
+ }
49
54
  const data = await this.mutate(flags);
50
- return data;
55
+ this.output(data);
51
56
  }
52
57
  }
@@ -0,0 +1,45 @@
1
+ import { createInterface } from "node:readline";
2
+ import { Flags } from "@oclif/core";
3
+ import WidgetGet from "#src/commands/widget/get.mjs";
4
+ import Command from "#src/procaCommand.mjs";
5
+ import { gql, mutation } from "#src/urql.mjs";
6
+
7
+ export default class WidgetDelete extends Command {
8
+ static description = "Delete a widget";
9
+
10
+ static args = this.multiid();
11
+
12
+ static flags = {
13
+ ...this.flagify({ multiid: true }),
14
+ };
15
+
16
+ delete = async (flags) => {
17
+ const deletePageDocument = gql`
18
+ mutation delete( $name:String!) {
19
+ deleteActionPage(name: $name)
20
+ }
21
+ `;
22
+
23
+ const r = await mutation(deletePageDocument, { name: flags.name });
24
+ return { deleted: r.deleteActionPage };
25
+ };
26
+
27
+ table = (r) => {
28
+ super.table(r, null, null);
29
+ };
30
+
31
+ async run() {
32
+ const { flags } = await this.parse(WidgetDelete);
33
+ const wg = new WidgetGet([], this.config);
34
+ const widget = await wg.fetch(flags);
35
+ try {
36
+ const data = await this.delete({ name: widget.name });
37
+ widget.status = data.deleted;
38
+ } catch (e) {
39
+ widget.status = "can't delete widgets with actions";
40
+ this.output(widget);
41
+ this.error("a widget with actions can't be deleted");
42
+ }
43
+ return this.output(widget);
44
+ }
45
+ }
@@ -1,7 +1,7 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
3
  import Command from "#src/procaCommand.mjs";
4
- import { FragmentSummary } from "#src/queries/widget.mjs";
4
+ import { FragmentSummary, FragmentSummaryOrg } from "#src/queries/widget.mjs";
5
5
  import { gql, query } from "#src/urql.mjs";
6
6
 
7
7
  export default class WidgetList extends Command {
@@ -68,7 +68,7 @@ query SearchWidgets($org: String!, $withConfig: Boolean!) {
68
68
  }
69
69
  }
70
70
  }
71
- ${FragmentSummary}
71
+ ${FragmentSummaryOrg}
72
72
  }`;
73
73
  const result = await query(Document, {
74
74
  org: name,
@@ -95,8 +95,14 @@ ${FragmentSummary}
95
95
  if (d.extraSupporters > 0) {
96
96
  result.extra = d.extraSupporters;
97
97
  }
98
- if (d.journey) result.journey = d.journey.join(" → ");
99
-
98
+ // if (d.journey) result.journey = d.journey.join(" → ");
99
+ if (d.org) {
100
+ result.org = d.org.name;
101
+ result.org_id = d.org.id;
102
+ }
103
+ if (d.campaign) {
104
+ result.campaign = d.campaign.name;
105
+ }
100
106
  if (this.flags.config) {
101
107
  }
102
108
  return result;
@@ -6,7 +6,20 @@ locale
6
6
  name
7
7
  journey
8
8
  extraSupporters
9
- status,
9
+ status
10
10
  location
11
+ org {name, ... on PrivateOrg {id} }
12
+ }
13
+ `;
14
+
15
+ export const FragmentSummaryOrg = gql`fragment Summary on PrivateActionPage {
16
+ id
17
+ locale
18
+ name
19
+ journey
20
+ extraSupporters
21
+ status
22
+ location
23
+ campaign {name }
11
24
  }
12
25
  `;