proca 1.7.0 → 1.7.2

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,6 +48,7 @@ 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)
@@ -71,8 +72,8 @@ you should also use the local proca-api in your [widget generator](https://githu
71
72
  * [`proca org add`](#proca-org-add)
72
73
  * [`proca org crm`](#proca-org-crm)
73
74
  * [`proca org delete`](#proca-org-delete)
75
+ * [`proca org email`](#proca-org-email)
74
76
  * [`proca org get`](#proca-org-get)
75
- * [`proca org join`](#proca-org-join)
76
77
  * [`proca plugins`](#proca-plugins)
77
78
  * [`proca plugins add PLUGIN`](#proca-plugins-add-plugin)
78
79
  * [`proca plugins:inspect PLUGIN...`](#proca-pluginsinspect-plugin)
@@ -83,10 +84,16 @@ you should also use the local proca-api in your [widget generator](https://githu
83
84
  * [`proca plugins uninstall [PLUGIN]`](#proca-plugins-uninstall-plugin)
84
85
  * [`proca plugins unlink [PLUGIN]`](#proca-plugins-unlink-plugin)
85
86
  * [`proca plugins update`](#proca-plugins-update)
87
+ * [`proca service add`](#proca-service-add)
88
+ * [`proca service list`](#proca-service-list)
86
89
  * [`proca target add`](#proca-target-add)
90
+ * [`proca template add`](#proca-template-add)
91
+ * [`proca template list`](#proca-template-list)
87
92
  * [`proca user get`](#proca-user-get)
93
+ * [`proca user join`](#proca-user-join)
88
94
  * [`proca user leave`](#proca-user-leave)
89
95
  * [`proca user list`](#proca-user-list)
96
+ * [`proca user me`](#proca-user-me)
90
97
  * [`proca user reset [USER]`](#proca-user-reset-user)
91
98
  * [`proca user whoami`](#proca-user-whoami)
92
99
  * [`proca widget add`](#proca-widget-add)
@@ -114,12 +121,13 @@ FLAGS
114
121
  --firstname=<value> (required) supporter's firstname
115
122
  --lastname=<value>
116
123
  --locality=<value>
117
- --optin
124
+ --[no-]optin Whether the user opts in (default: false). Use --optin to enable or --no-optin to
125
+ explicitly disable.
118
126
  --region=<value>
119
127
  --street=<value>
120
128
  --subject=<value> [mtt] subject of the email
121
129
  --target=<value> [mtt] uid of the target
122
- --testing
130
+ --[no-]testing Run action in testing mode (default: true). Use --no-testing to disable.
123
131
  --utm=<value> utm=campaign.source.medium
124
132
 
125
133
  OUTPUT FLAGS
@@ -136,6 +144,33 @@ EXAMPLES
136
144
  $ 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
145
  ```
138
146
 
147
+ ## `proca action confirm`
148
+
149
+ 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
150
+
151
+ ```
152
+ USAGE
153
+ $ proca action confirm [--json | --human | --csv] [--env <value>] [--simplify] [--org
154
+ <value>] [--campaign <value>] [--confirm] [--template <value>]
155
+
156
+ FLAGS
157
+ --campaign=<value> campaign collecting the action
158
+ --[no-]confirm should the supporters confirm each action
159
+ --env=<value> [default: default] allow to switch between configurations (server or users)
160
+ --org=<value> organisation collecting the action
161
+ --template=<value> template for sending the message
162
+
163
+ OUTPUT FLAGS
164
+ --csv Format output as csv
165
+ --human Format output to be read on screen by a human [default]
166
+ --json Format output as json
167
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
168
+
169
+ DESCRIPTION
170
+ Should the supporter confirm the action? it can be set either for all the widgets or an organisation or all the
171
+ widgets of a campaign
172
+ ```
173
+
139
174
  ## `proca action count`
140
175
 
141
176
  counter of actions
@@ -650,6 +685,7 @@ DESCRIPTION
650
685
 
651
686
  ALIASES
652
687
  $ proca user whoami
688
+ $ proca user me
653
689
 
654
690
  EXAMPLES
655
691
  $ proca config user
@@ -811,22 +847,25 @@ EXAMPLES
811
847
  $ proca org delete <organisation_name>
812
848
  ```
813
849
 
814
- ## `proca org get`
850
+ ## `proca org email`
815
851
 
816
- view a org
852
+ Set service, usually email backend for an org
817
853
 
818
854
  ```
819
855
  USAGE
820
- $ proca org get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
821
- [--simplify] [-n <org name>] [--config] [--keys] [--campaigns] [--users]
856
+ $ proca org email [ID_NAME_DXID] --org <value> --mailer mailjet ses stripe
857
+ test_stripe system preview webhook supabase smtp [--json | --human | --csv] [--env <value>] [--simplify] [--from
858
+ <value>]
822
859
 
823
860
  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
861
+ --env=<value> [default: default] allow to switch
862
+ between configurations (server or users)
863
+ --from=<value> Email address to send from (default:
864
+ <org>@proca.app)
865
+ --mailer=mailjet ses stripe test_stripe system preview webhook supabase smtp (required) [default: MAILJET] service to
866
+ send emails
867
+ --org=<value> (required) organisation running the
868
+ service
830
869
 
831
870
  OUTPUT FLAGS
832
871
  --csv Format output as csv
@@ -835,27 +874,25 @@ OUTPUT FLAGS
835
874
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
836
875
 
837
876
  DESCRIPTION
838
- view a org
839
-
840
- EXAMPLES
841
- $ proca org get <name of the ngo>
877
+ Set service, usually email backend for an org
842
878
  ```
843
879
 
844
- ## `proca org join`
880
+ ## `proca org get`
845
881
 
846
- let a user join an organisation with a role
882
+ view a org
847
883
 
848
884
  ```
849
885
  USAGE
850
- $ proca org join -o <org name> [--json | --human | --csv] [--env <value>]
851
- [--simplify] [--user <value>] [--role owner|campaigner|coordinator|translator]
886
+ $ proca org get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
887
+ [--simplify] [-n <org name>] [--config] [--keys] [--campaigns] [--users]
852
888
 
853
889
  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
890
+ -n, --name=<org name> name of the org
891
+ --[no-]campaigns
892
+ --[no-]config display the config
893
+ --env=<value> [default: default] allow to switch between configurations (server or users)
894
+ --[no-]keys
895
+ --[no-]users
859
896
 
860
897
  OUTPUT FLAGS
861
898
  --csv Format output as csv
@@ -864,10 +901,10 @@ OUTPUT FLAGS
864
901
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
865
902
 
866
903
  DESCRIPTION
867
- let a user join an organisation with a role
904
+ view a org
868
905
 
869
906
  EXAMPLES
870
- $ proca org join
907
+ $ proca org get <name of the ngo>
871
908
  ```
872
909
 
873
910
  ## `proca plugins`
@@ -1160,6 +1197,59 @@ DESCRIPTION
1160
1197
 
1161
1198
  _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/update.ts)_
1162
1199
 
1200
+ ## `proca service add`
1201
+
1202
+ Set service, usually email backend for an org, the specific meaning of each param is dependant on the service
1203
+
1204
+ ```
1205
+ USAGE
1206
+ $ proca service add -o <value> --type
1207
+ mailjet|ses|stripe|test_stripe|preview|webhook|supabase|smtp [--json | --human | --csv] [--env <value>] [--simplify]
1208
+ [--user <value>] [--password <value>] [--host <value>] [--path <value>]
1209
+
1210
+ FLAGS
1211
+ -o, --org=<value> (required) organisation running the service
1212
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1213
+ --host=<value> server of the service
1214
+ --password=<value> credential of the account on the service
1215
+ --path=<value> path on the service
1216
+ --type=<option> (required) [default: system] type of the service
1217
+ <options: mailjet|ses|stripe|test_stripe|preview|webhook|supabase|smtp>
1218
+ --user=<value> credential of the account on the service
1219
+
1220
+ OUTPUT FLAGS
1221
+ --csv Format output as csv
1222
+ --human Format output to be read on screen by a human [default]
1223
+ --json Format output as json
1224
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1225
+
1226
+ DESCRIPTION
1227
+ Set service, usually email backend for an org, the specific meaning of each param is dependant on the service
1228
+ ```
1229
+
1230
+ ## `proca service list`
1231
+
1232
+ list services set for an organisation
1233
+
1234
+ ```
1235
+ USAGE
1236
+ $ proca service list -o <value> [--json | --human | --csv] [--env <value>]
1237
+ [--simplify]
1238
+
1239
+ FLAGS
1240
+ -o, --org=<value> (required) organisation running the service
1241
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1242
+
1243
+ OUTPUT FLAGS
1244
+ --csv Format output as csv
1245
+ --human Format output to be read on screen by a human [default]
1246
+ --json Format output as json
1247
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1248
+
1249
+ DESCRIPTION
1250
+ list services set for an organisation
1251
+ ```
1252
+
1163
1253
  ## `proca target add`
1164
1254
 
1165
1255
  ```
@@ -1181,6 +1271,53 @@ OUTPUT FLAGS
1181
1271
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1182
1272
  ```
1183
1273
 
1274
+ ## `proca template add`
1275
+
1276
+ ```
1277
+ USAGE
1278
+ $ proca template add -o <value> [--json | --human | --csv] [--env <value>] [--simplify]
1279
+ [--type thankyou|doi|confirm|doi_thankyou|doi_confirm] [-l <locale>] [-n by default type@language] [-s 'template:'
1280
+ + type]
1281
+
1282
+ FLAGS
1283
+ -l, --lang=<locale> [default: en] language
1284
+ -n, --name=by default type@language name
1285
+ -o, --org=<value> (required) organisation
1286
+ -s, --subject='template:' + type subject
1287
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1288
+ --type=<option> [default: thankyou]
1289
+ <options: thankyou|doi|confirm|doi_thankyou|doi_confirm>
1290
+
1291
+ OUTPUT FLAGS
1292
+ --csv Format output as csv
1293
+ --human Format output to be read on screen by a human [default]
1294
+ --json Format output as json
1295
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1296
+ ```
1297
+
1298
+ ## `proca template list`
1299
+
1300
+ list services set for an organisation
1301
+
1302
+ ```
1303
+ USAGE
1304
+ $ proca template list -o <value> [--json | --human | --csv] [--env <value>]
1305
+ [--simplify]
1306
+
1307
+ FLAGS
1308
+ -o, --org=<value> (required) organisation having the templates
1309
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1310
+
1311
+ OUTPUT FLAGS
1312
+ --csv Format output as csv
1313
+ --human Format output to be read on screen by a human [default]
1314
+ --json Format output as json
1315
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1316
+
1317
+ DESCRIPTION
1318
+ list services set for an organisation
1319
+ ```
1320
+
1184
1321
  ## `proca user get`
1185
1322
 
1186
1323
  fetch the information about a user
@@ -1209,19 +1346,48 @@ EXAMPLES
1209
1346
  $ proca user get
1210
1347
  ```
1211
1348
 
1349
+ ## `proca user join`
1350
+
1351
+ let a user join an organisation with a role
1352
+
1353
+ ```
1354
+ USAGE
1355
+ $ proca user join -o <org name> [--json | --human | --csv] [--env <value>]
1356
+ [--simplify] [--role owner|campaigner|coordinator|translator] [-u <user email>]
1357
+
1358
+ FLAGS
1359
+ -o, --org=<org name> (required) name of the org
1360
+ -u, --user=<user email> email
1361
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1362
+ --role=<option> [default: campaigner] permission level in that org
1363
+ <options: owner|campaigner|coordinator|translator>
1364
+
1365
+ OUTPUT FLAGS
1366
+ --csv Format output as csv
1367
+ --human Format output to be read on screen by a human [default]
1368
+ --json Format output as json
1369
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1370
+
1371
+ DESCRIPTION
1372
+ let a user join an organisation with a role
1373
+
1374
+ EXAMPLES
1375
+ $ proca user join
1376
+ ```
1377
+
1212
1378
  ## `proca user leave`
1213
1379
 
1214
1380
  leave a org
1215
1381
 
1216
1382
  ```
1217
1383
  USAGE
1218
- $ proca user leave --email <user email> -o <org name> [--json | --human | --csv]
1219
- [--env <value>] [--simplify]
1384
+ $ proca user leave -o <org name> [--json | --human | --csv] [--env <value>]
1385
+ [--simplify] [-u <user email>]
1220
1386
 
1221
1387
  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)
1388
+ -o, --org=<org name> (required) name of the org
1389
+ -u, --user=<user email> email
1390
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1225
1391
 
1226
1392
  OUTPUT FLAGS
1227
1393
  --csv Format output as csv
@@ -1262,6 +1428,34 @@ EXAMPLES
1262
1428
  $ proca user list %pizza%
1263
1429
  ```
1264
1430
 
1431
+ ## `proca user me`
1432
+
1433
+ fetch the information about the current user (based on the token)
1434
+
1435
+ ```
1436
+ USAGE
1437
+ $ proca user me [--json | --human | --csv] [--env <value>] [--simplify]
1438
+
1439
+ FLAGS
1440
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1441
+
1442
+ OUTPUT FLAGS
1443
+ --csv Format output as csv
1444
+ --human Format output to be read on screen by a human [default]
1445
+ --json Format output as json
1446
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1447
+
1448
+ DESCRIPTION
1449
+ fetch the information about the current user (based on the token)
1450
+
1451
+ ALIASES
1452
+ $ proca user whoami
1453
+ $ proca user me
1454
+
1455
+ EXAMPLES
1456
+ $ proca user me
1457
+ ```
1458
+
1265
1459
  ## `proca user reset [USER]`
1266
1460
 
1267
1461
  Reset user API token
@@ -1311,6 +1505,7 @@ DESCRIPTION
1311
1505
 
1312
1506
  ALIASES
1313
1507
  $ proca user whoami
1508
+ $ proca user me
1314
1509
 
1315
1510
  EXAMPLES
1316
1511
  $ proca user whoami
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.2",
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
+ }
@@ -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
+ }
@@ -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
  }
@@ -95,8 +95,9 @@ ${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
+ result.org = d.org.name;
100
+ result.org_id = d.org.id;
100
101
  if (this.flags.config) {
101
102
  }
102
103
  return result;
@@ -6,7 +6,8 @@ locale
6
6
  name
7
7
  journey
8
8
  extraSupporters
9
- status,
9
+ status
10
10
  location
11
+ org {name, ... on PrivateOrg {id} }
11
12
  }
12
13
  `;