proca 0.4.1 → 0.5.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
@@ -18,7 +18,7 @@ $ npm install -g proca
18
18
  $ proca COMMAND
19
19
  running command...
20
20
  $ proca (--version)
21
- proca/0.4.1 linux-x64 node-v20.12.2
21
+ proca/0.5.2 linux-x64 node-v20.12.2
22
22
  $ proca --help [COMMAND]
23
23
  USAGE
24
24
  $ proca COMMAND
@@ -50,6 +50,7 @@ USAGE
50
50
 
51
51
  # Commands
52
52
  <!-- commands -->
53
+ * [`proca action count`](#proca-action-count)
53
54
  * [`proca action list [TITLE]`](#proca-action-list-title)
54
55
  * [`proca action replay`](#proca-action-replay)
55
56
  * [`proca campaign add [TITLE]`](#proca-campaign-add-title)
@@ -58,7 +59,9 @@ USAGE
58
59
  * [`proca campaign list [TITLE]`](#proca-campaign-list-title)
59
60
  * [`proca config add [ENVIRONMENT]`](#proca-config-add-environment)
60
61
  * [`proca config get`](#proca-config-get)
62
+ * [`proca config set [ENVIRONMENT]`](#proca-config-set-environment)
61
63
  * [`proca config setup [ENVIRONMENT]`](#proca-config-setup-environment)
64
+ * [`proca config token`](#proca-config-token)
62
65
  * [`proca config user`](#proca-config-user)
63
66
  * [`proca help [COMMAND]`](#proca-help-command)
64
67
  * [`proca org add`](#proca-org-add)
@@ -75,6 +78,7 @@ USAGE
75
78
  * [`proca plugins uninstall [PLUGIN]`](#proca-plugins-uninstall-plugin)
76
79
  * [`proca plugins unlink [PLUGIN]`](#proca-plugins-unlink-plugin)
77
80
  * [`proca plugins update`](#proca-plugins-update)
81
+ * [`proca supporter count`](#proca-supporter-count)
78
82
  * [`proca user get`](#proca-user-get)
79
83
  * [`proca user leave`](#proca-user-leave)
80
84
  * [`proca user list`](#proca-user-list)
@@ -82,22 +86,48 @@ USAGE
82
86
  * [`proca widget get`](#proca-widget-get)
83
87
  * [`proca widget list`](#proca-widget-list)
84
88
 
89
+ ## `proca action count`
90
+
91
+ counter of actions
92
+
93
+ ```
94
+ USAGE
95
+ $ proca action count [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-i <value>
96
+ | -n <the_short_name> | -x <value>]
97
+
98
+ FLAGS
99
+ -i, --id=<value>
100
+ -n, --name=<the_short_name> name
101
+ -x, --dxid=<value> dxid
102
+
103
+ OUTPUT FLAGS
104
+ --csv Format output as csv
105
+ --human Format output to be read on screen by a human [default]
106
+ --json Format output as json
107
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
108
+
109
+ DESCRIPTION
110
+ counter of actions
111
+
112
+ EXAMPLES
113
+ $ proca action count --id <id of the campaign>
114
+
115
+ $ proca action count --name <name of the campaign>
116
+ ```
117
+
85
118
  ## `proca action list [TITLE]`
86
119
 
87
120
  ```
88
121
  USAGE
89
- $ proca action list [TITLE] -o <organisation name> [--csv] [--simplify []] [-i <value>
90
- | -n <the_short_name> | -x <value>] [-c <campaign title>] [--limit <value>] [--optin] [--testing] [--doi] [--utm]
122
+ $ proca action list [TITLE] -o <organisation name> [--simplify [--json | --human |
123
+ --csv]] [-c <campaign title>] [--limit <value>] [--optin] [--testing] [--doi] [--utm]
91
124
 
92
125
  ARGUMENTS
93
126
  TITLE name of the campaign, % for wildchar
94
127
 
95
128
  FLAGS
96
129
  -c, --campaign=<campaign title> name of the campaign, % for wildchar
97
- -i, --id=<value>
98
- -n, --name=<the_short_name> name
99
130
  -o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
100
- -x, --dxid=<value> dxid
101
131
  --doi only export the double optin actions
102
132
  --limit=<value> max number of actions
103
133
  --optin only export the optin actions
@@ -118,15 +148,12 @@ EXAMPLES
118
148
 
119
149
  ```
120
150
  USAGE
121
- $ proca action replay -o <organisation name> [--csv] [--simplify []] [-i <value> | -n
122
- <the_short_name> | -x <value>] [-c <campaign title>]
151
+ $ proca action replay -o <organisation name> [--simplify [--json | --human | --csv]] [-c
152
+ <campaign title>]
123
153
 
124
154
  FLAGS
125
155
  -c, --campaign=<campaign title> name of the campaign, % for wildchar
126
- -i, --id=<value>
127
- -n, --name=<the_short_name> name
128
156
  -o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
129
- -x, --dxid=<value> dxid
130
157
 
131
158
  OUTPUT FLAGS
132
159
  --csv Format output as csv
@@ -142,17 +169,15 @@ EXAMPLES
142
169
 
143
170
  ```
144
171
  USAGE
145
- $ proca campaign add [TITLE] [--csv] [--simplify []] [-i <value> | -n <campaign name> |
146
- -x <value>] [-o <org name>]
172
+ $ proca campaign add [TITLE] [--simplify [--json | --human | --csv]] [-n <campaign
173
+ name>] [-o <org name>]
147
174
 
148
175
  ARGUMENTS
149
176
  TITLE title of the campaign
150
177
 
151
178
  FLAGS
152
- -i, --id=<value>
153
179
  -n, --name=<campaign name> name of the campaign
154
180
  -o, --org=<org name> name of the coordinator
155
- -x, --dxid=<value> dxid
156
181
 
157
182
  OUTPUT FLAGS
158
183
  --csv Format output as csv
@@ -170,13 +195,12 @@ delete a campaign
170
195
 
171
196
  ```
172
197
  USAGE
173
- $ proca campaign delete [--csv] [--simplify []] [-i <organisation name>] [-x <value>] [-n
174
- <campaign name>]
198
+ $ proca campaign delete [--simplify [--json | --human | --csv]] [-i <organisation name>]
199
+ [-n <campaign name>]
175
200
 
176
201
  FLAGS
177
202
  -i, --id=<organisation name> id of the campaign
178
203
  -n, --name=<campaign name> name of the campaign
179
- -x, --dxid=<value> dxid
180
204
 
181
205
  OUTPUT FLAGS
182
206
  --csv Format output as csv
@@ -197,8 +221,8 @@ view a campaign
197
221
 
198
222
  ```
199
223
  USAGE
200
- $ proca campaign get [ID_NAME_DXID] [--csv] [--simplify []] [-i <value> | -n
201
- <the_short_name> | -x <value>] [--config] [--stats] [--locale <value>]
224
+ $ proca campaign get [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-i <value>
225
+ | -n <the_short_name> | -x <value>] [--config] [--stats] [--locale <value>]
202
226
 
203
227
  FLAGS
204
228
  -i, --id=<value>
@@ -227,18 +251,15 @@ list all the campaigns
227
251
 
228
252
  ```
229
253
  USAGE
230
- $ proca campaign list [TITLE] [--csv] [--simplify []] [-i <value> | -n <the_short_name>
231
- | -x <value>] [-o <organisation name>] [-t <campaign title>] [--stats]
254
+ $ proca campaign list [TITLE] [--simplify [--json | --human | --csv]] [-o <organisation
255
+ name>] [-t <campaign title>] [--stats]
232
256
 
233
257
  ARGUMENTS
234
258
  TITLE name of the campaign, % for wildchar
235
259
 
236
260
  FLAGS
237
- -i, --id=<value>
238
- -n, --name=<the_short_name> name
239
261
  -o, --org=<organisation name> campaigns of the organisation (coordinator or partner)
240
262
  -t, --title=<campaign title> name of the campaign, % for wildchar
241
- -x, --dxid=<value> dxid
242
263
  --[no-]stats display the stats
243
264
 
244
265
  OUTPUT FLAGS
@@ -260,24 +281,21 @@ create setting to access the server authentication
260
281
 
261
282
  ```
262
283
  USAGE
263
- $ proca config add [ENVIRONMENT] --token <API-token> [--csv] [--simplify []] [-i
264
- <value> | -n <the_short_name> | -x <value>] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>]
265
- [--supabase-anon-key <value>] [--supabase-secrey-key <value>]
284
+ $ proca config add [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
285
+ --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
286
+ [--supabase-secrey-key <value>]
266
287
 
267
288
  ARGUMENTS
268
289
  ENVIRONMENT [default: default] environment
269
290
 
270
291
  FLAGS
271
- -i, --id=<value>
272
- -n, --name=<the_short_name> name
273
- -x, --dxid=<value> dxid
274
- --force write over an existing configuration
275
- --n8n=<n8n api> api access on the n8n server
276
- --supabase=<url> url of the supabase
277
- --supabase-anon-key=<value> anonymous key
278
- --supabase-secrey-key=<value> secret service key
279
- --token=<API-token> (required) user token on proca server
280
- --url=<url> [default: https://api.proca.app/api] url of the proca server api
292
+ --force write over an existing configuration
293
+ --n8n=<n8n api> api access on the n8n server
294
+ --supabase=<url> url of the supabase
295
+ --supabase-anon-key=<value> anonymous key
296
+ --supabase-secrey-key=<value> secret service key
297
+ --token=<API-token> (required) user token on proca server
298
+ --url=<url> [default: https://api.proca.app/api] url of the proca server api
281
299
 
282
300
  OUTPUT FLAGS
283
301
  --csv Format output as csv
@@ -301,13 +319,39 @@ get the server config
301
319
 
302
320
  ```
303
321
  USAGE
304
- $ proca config get [--csv] [--simplify []] [-i <value> | -n <the_short_name> | -x
305
- <value>]
322
+ $ proca config get [--simplify [--json | --human | --csv]]
323
+
324
+ OUTPUT FLAGS
325
+ --csv Format output as csv
326
+ --human Format output to be read on screen by a human [default]
327
+ --json Format output as json
328
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
329
+
330
+ DESCRIPTION
331
+ get the server config
332
+ ```
333
+
334
+ ## `proca config set [ENVIRONMENT]`
335
+
336
+ create setting to access the server authentication
337
+
338
+ ```
339
+ USAGE
340
+ $ proca config set [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
341
+ --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
342
+ [--supabase-secrey-key <value>]
343
+
344
+ ARGUMENTS
345
+ ENVIRONMENT [default: default] environment
306
346
 
307
347
  FLAGS
308
- -i, --id=<value>
309
- -n, --name=<the_short_name> name
310
- -x, --dxid=<value> dxid
348
+ --force write over an existing configuration
349
+ --n8n=<n8n api> api access on the n8n server
350
+ --supabase=<url> url of the supabase
351
+ --supabase-anon-key=<value> anonymous key
352
+ --supabase-secrey-key=<value> secret service key
353
+ --token=<API-token> (required) user token on proca server
354
+ --url=<url> [default: https://api.proca.app/api] url of the proca server api
311
355
 
312
356
  OUTPUT FLAGS
313
357
  --csv Format output as csv
@@ -316,7 +360,13 @@ OUTPUT FLAGS
316
360
  --simplify flatten and filter to output only the most important attributes, mostly relevant for json
317
361
 
318
362
  DESCRIPTION
319
- get the server config
363
+ create setting to access the server authentication
364
+
365
+ ALIASES
366
+ $ proca config setup
367
+
368
+ EXAMPLES
369
+ $ proca config set --user=xavier@example.org --token=API-12345789
320
370
  ```
321
371
 
322
372
  ## `proca config setup [ENVIRONMENT]`
@@ -325,24 +375,21 @@ create setting to access the server authentication
325
375
 
326
376
  ```
327
377
  USAGE
328
- $ proca config setup [ENVIRONMENT] --token <API-token> [--csv] [--simplify []] [-i
329
- <value> | -n <the_short_name> | -x <value>] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>]
330
- [--supabase-anon-key <value>] [--supabase-secrey-key <value>]
378
+ $ proca config setup [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
379
+ --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
380
+ [--supabase-secrey-key <value>]
331
381
 
332
382
  ARGUMENTS
333
383
  ENVIRONMENT [default: default] environment
334
384
 
335
385
  FLAGS
336
- -i, --id=<value>
337
- -n, --name=<the_short_name> name
338
- -x, --dxid=<value> dxid
339
- --force write over an existing configuration
340
- --n8n=<n8n api> api access on the n8n server
341
- --supabase=<url> url of the supabase
342
- --supabase-anon-key=<value> anonymous key
343
- --supabase-secrey-key=<value> secret service key
344
- --token=<API-token> (required) user token on proca server
345
- --url=<url> [default: https://api.proca.app/api] url of the proca server api
386
+ --force write over an existing configuration
387
+ --n8n=<n8n api> api access on the n8n server
388
+ --supabase=<url> url of the supabase
389
+ --supabase-anon-key=<value> anonymous key
390
+ --supabase-secrey-key=<value> secret service key
391
+ --token=<API-token> (required) user token on proca server
392
+ --url=<url> [default: https://api.proca.app/api] url of the proca server api
346
393
 
347
394
  OUTPUT FLAGS
348
395
  --csv Format output as csv
@@ -360,19 +407,34 @@ EXAMPLES
360
407
  $ proca config setup --user=xavier@example.org --token=API-12345789
361
408
  ```
362
409
 
363
- ## `proca config user`
410
+ ## `proca config token`
364
411
 
365
- fetch the information about the current user (based on the token)
412
+ convert between token and sql value
366
413
 
367
414
  ```
368
415
  USAGE
369
- $ proca config user [--csv] [--simplify []] [-i <value> | -n <the_short_name> | -x
370
- <value>]
416
+ $ proca config token [--simplify [--json | --human | --csv]] [--token API-xxx]
371
417
 
372
418
  FLAGS
373
- -i, --id=<value>
374
- -n, --name=<the_short_name> name
375
- -x, --dxid=<value> dxid
419
+ --token=API-xxx the token in your config
420
+
421
+ OUTPUT FLAGS
422
+ --csv Format output as csv
423
+ --human Format output to be read on screen by a human [default]
424
+ --json Format output as json
425
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
426
+
427
+ DESCRIPTION
428
+ convert between token and sql value
429
+ ```
430
+
431
+ ## `proca config user`
432
+
433
+ fetch the information about the current user (based on the token)
434
+
435
+ ```
436
+ USAGE
437
+ $ proca config user [--simplify [--json | --human | --csv]]
376
438
 
377
439
  OUTPUT FLAGS
378
440
  --csv Format output as csv
@@ -411,13 +473,11 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.1
411
473
 
412
474
  ```
413
475
  USAGE
414
- $ proca org add [--csv] [--simplify []] [-i <value> | -n <org name> | -x <value>]
415
- [--twitter <screen name>]
476
+ $ proca org add [--simplify [--json | --human | --csv]] [--twitter <screen name>]
477
+ [-n <org name>]
416
478
 
417
479
  FLAGS
418
- -i, --id=<value>
419
480
  -n, --name=<org name> name of the org
420
- -x, --dxid=<value> dxid
421
481
  --twitter=<screen name> twitter account
422
482
 
423
483
  OUTPUT FLAGS
@@ -436,13 +496,11 @@ view a org crm synchroniser
436
496
 
437
497
  ```
438
498
  USAGE
439
- $ proca org crm [--csv] [--simplify []] (-i <value> | -n <org name> | -x <value>)
499
+ $ proca org crm -n <org name> [--simplify [--json | --human | --csv]]
440
500
  [--synchronize]
441
501
 
442
502
  FLAGS
443
- -i, --id=<value>
444
503
  -n, --name=<org name> (required) name of the org
445
- -x, --dxid=<value> dxid
446
504
  --[no-]synchronize enable or disable the synchronisation queue
447
505
 
448
506
  OUTPUT FLAGS
@@ -461,13 +519,11 @@ view a org
461
519
 
462
520
  ```
463
521
  USAGE
464
- $ proca org get [--csv] [--simplify []] [-i <value> | -n <org name> | -x <value>]
465
- [--config] [--keys] [--campaigns] [--widgets] [--users]
522
+ $ proca org get [--simplify [--json | --human | --csv]] [-n <org name>] [--config]
523
+ [--keys] [--campaigns] [--widgets] [--users]
466
524
 
467
525
  FLAGS
468
- -i, --id=<value>
469
526
  -n, --name=<org name> name of the org
470
- -x, --dxid=<value> dxid
471
527
  --[no-]campaigns
472
528
  --[no-]config display the config
473
529
  --[no-]keys
@@ -493,17 +549,14 @@ let a user join an organisation with a role
493
549
 
494
550
  ```
495
551
  USAGE
496
- $ proca org join -o <org name> [--csv] [--simplify []] [-i <value> | -n
497
- <the_short_name> | -x <value>] [--user <value>] [--role owner|campaigner|coordinator|translator]
552
+ $ proca org join -o <org name> [--simplify [--json | --human | --csv]] [--user
553
+ <value>] [--role owner|campaigner|coordinator|translator]
498
554
 
499
555
  FLAGS
500
- -i, --id=<value>
501
- -n, --name=<the_short_name> name
502
- -o, --org=<org name> (required) name of the org
503
- -x, --dxid=<value> dxid
504
- --role=<option> [default: campaigner] permission level in that org
505
- <options: owner|campaigner|coordinator|translator>
506
- --user=<value> user email
556
+ -o, --org=<org name> (required) name of the org
557
+ --role=<option> [default: campaigner] permission level in that org
558
+ <options: owner|campaigner|coordinator|translator>
559
+ --user=<value> user email
507
560
 
508
561
  OUTPUT FLAGS
509
562
  --csv Format output as csv
@@ -808,21 +861,52 @@ DESCRIPTION
808
861
 
809
862
  _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/update.ts)_
810
863
 
811
- ## `proca user get`
864
+ ## `proca supporter count`
812
865
 
813
- fetch the information about a user
866
+ counter of supporters
814
867
 
815
868
  ```
816
869
  USAGE
817
- $ proca user get [--csv] [--simplify []] [-i <value>] [-x <value>] [-n
818
- <the_short_name>] [--email <value>] [-o <org name>]
870
+ $ proca supporter count [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-i <value>
871
+ | -n <the_short_name> | -x <value>] [--org] [--area] [--number --without <value>]
819
872
 
820
873
  FLAGS
821
- -i, --id=<value> id of the user
874
+ -i, --id=<value>
822
875
  -n, --name=<the_short_name> name
823
- -o, --org=<org name> name of the org
824
876
  -x, --dxid=<value> dxid
825
- --email=<value> user email
877
+ --area segment by area
878
+ --number just return the number to add to the partner's counter
879
+ --org segment by partner
880
+ --without=<value> total to add to the partner's counter
881
+
882
+ OUTPUT FLAGS
883
+ --csv Format output as csv
884
+ --human Format output to be read on screen by a human [default]
885
+ --json Format output as json
886
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
887
+
888
+ DESCRIPTION
889
+ counter of supporters
890
+
891
+ EXAMPLES
892
+ $ proca supporter count --id <id of the campaign>
893
+
894
+ $ proca supporter count --name <name of the campaign>
895
+ ```
896
+
897
+ ## `proca user get`
898
+
899
+ fetch the information about a user
900
+
901
+ ```
902
+ USAGE
903
+ $ proca user get [--simplify [--json | --human | --csv]] [--email <value>] [-o <org
904
+ name>] [-i <value>]
905
+
906
+ FLAGS
907
+ -i, --id=<value> id of the user
908
+ -o, --org=<org name> name of the org
909
+ --email=<value> user email
826
910
 
827
911
  OUTPUT FLAGS
828
912
  --csv Format output as csv
@@ -843,15 +927,12 @@ leave a org
843
927
 
844
928
  ```
845
929
  USAGE
846
- $ proca user leave --email <user email> -o <org name> [--csv] [--simplify []] [-i
847
- <value> | -n <the_short_name> | -x <value>]
930
+ $ proca user leave --email <user email> -o <org name> [--simplify [--json | --human |
931
+ --csv]]
848
932
 
849
933
  FLAGS
850
- -i, --id=<value>
851
- -n, --name=<the_short_name> name
852
- -o, --org=<org name> (required) name of the org
853
- -x, --dxid=<value> dxid
854
- --email=<user email> (required) email
934
+ -o, --org=<org name> (required) name of the org
935
+ --email=<user email> (required) email
855
936
 
856
937
  OUTPUT FLAGS
857
938
  --csv Format output as csv
@@ -872,14 +953,10 @@ list all the users
872
953
 
873
954
  ```
874
955
  USAGE
875
- $ proca user list -o <value> [--csv] [--simplify []] [-i <value> | -n
876
- <the_short_name> | -x <value>]
956
+ $ proca user list -o <value> [--simplify [--json | --human | --csv]]
877
957
 
878
958
  FLAGS
879
- -i, --id=<value>
880
- -n, --name=<the_short_name> name
881
- -o, --org=<value> (required) organisation
882
- -x, --dxid=<value> dxid
959
+ -o, --org=<value> (required) organisation
883
960
 
884
961
  OUTPUT FLAGS
885
962
  --csv Format output as csv
@@ -898,16 +975,14 @@ EXAMPLES
898
975
 
899
976
  ```
900
977
  USAGE
901
- $ proca widget add -c <campaign name> [--csv] [--simplify []] [-i <value> | -n by
902
- default <campaign>/<org>/<lang> | -x <value>] [-o <en>] [-l <en>]
978
+ $ proca widget add -c <campaign name> [--simplify [--json | --human | --csv]] [-o
979
+ <en>] [-l <en>] [-n by default <campaign>/<org>/<lang>]
903
980
 
904
981
  FLAGS
905
982
  -c, --campaign=<campaign name> (required) name of the campaign
906
- -i, --id=<value>
907
983
  -l, --lang=<en> [default: en] language
908
984
  -n, --name=by default <campaign>/<org>/<lang> url slug
909
985
  -o, --org=<en> organisation
910
- -x, --dxid=<value> dxid
911
986
 
912
987
  OUTPUT FLAGS
913
988
  --csv Format output as csv
@@ -922,8 +997,8 @@ view a widget
922
997
 
923
998
  ```
924
999
  USAGE
925
- $ proca widget get [ID_NAME_DXID] [--csv] [--simplify []] [-i <value> | -n
926
- <the_short_name> | -x <value>] [--config]
1000
+ $ proca widget get [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-i <value>
1001
+ | -n <the_short_name> | -x <value>] [--config]
927
1002
 
928
1003
  FLAGS
929
1004
  -i, --id=<value>
@@ -950,15 +1025,12 @@ list all the widgets of an org or campaign
950
1025
 
951
1026
  ```
952
1027
  USAGE
953
- $ proca widget list [--csv] [--simplify []] [-i <value> | -n <the_short_name> | -x
954
- <value>] [-o <organisation name>] [-c <campaign name>] [--config]
1028
+ $ proca widget list [--simplify [--json | --human | --csv]] [-o <organisation name>]
1029
+ [-c <campaign name>] [--config]
955
1030
 
956
1031
  FLAGS
957
1032
  -c, --campaign=<campaign name> widgets of the campaign (coordinator or partner)
958
- -i, --id=<value>
959
- -n, --name=<the_short_name> name
960
1033
  -o, --org=<organisation name> widgets of the organisation (coordinator or partner)
961
- -x, --dxid=<value> dxid
962
1034
  --[no-]config get the config
963
1035
 
964
1036
  OUTPUT FLAGS
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proca",
3
3
  "description": "Access the proca api",
4
- "version": "0.4.1",
4
+ "version": "0.5.2",
5
5
  "author": "Xavier",
6
6
  "bin": {
7
7
  "proca": "./proca-cli"
@@ -0,0 +1,61 @@
1
+ import { Args, Flags } from "@oclif/core";
2
+ import Command from "#src/procaCommand.mjs";
3
+ import { gql, query } from "#src/urql.mjs";
4
+
5
+ export default class CounterGet extends Command {
6
+ ignored = ["share_confirmed"];
7
+ secondary = ["share"];
8
+
9
+ static description = "counter of actions";
10
+
11
+ static examples = [
12
+ "<%= config.bin %> <%= command.id %> --id <id of the campaign>",
13
+ "<%= config.bin %> <%= command.id %> --name <name of the campaign>",
14
+ ];
15
+
16
+ static args = this.multiid();
17
+ static flags = {
18
+ // flag with no value (-f, --force)
19
+ ...this.flagify({ multiid: true }),
20
+ };
21
+
22
+ fetch = async (params) => {
23
+ const GetCounterDocument = gql`
24
+ query GetCounter($name: String, $id: Int) {
25
+ campaign(name: $name, id: $id) {
26
+ stats {
27
+ actionCount {actionType, count}
28
+ }
29
+ }
30
+ }
31
+ `;
32
+ const result = await query(GetCounterDocument, params);
33
+ return result.campaign.stats;
34
+ };
35
+
36
+ simplify = (d) => {
37
+ const result = { sharer: undefined };
38
+ let primary = 0;
39
+ let secondary = 0;
40
+ d.actionCount.forEach((type) => {
41
+ if (this.ignored.includes(type.actionType)) return;
42
+ if (this.secondary.includes(type.actionType)) {
43
+ secondary += type.count;
44
+ } else {
45
+ primary += type.count;
46
+ }
47
+ result[type.actionType] = type.count;
48
+ });
49
+ if (primary) result.sharer = `${Math.round((100 * secondary) / primary)}%`;
50
+ return result;
51
+ };
52
+ table = (r) => {
53
+ super.table(r, null, null);
54
+ };
55
+
56
+ async run() {
57
+ const { args, flags } = await this.parse();
58
+ const data = await this.fetch(flags);
59
+ return this.output(data);
60
+ }
61
+ }
@@ -0,0 +1,101 @@
1
+ import { Args, Flags } from "@oclif/core";
2
+ import { error, stdout, ux } from "@oclif/core/ux";
3
+ import { get as getConfig, getFilename, write } from "#src/config.mjs";
4
+ import Command from "#src/procaCommand.mjs";
5
+
6
+ export default class CampaignList extends Command {
7
+ static enableJsonFlag = true;
8
+ static aliases = ["config:setup"];
9
+ static deprecateAliases = true;
10
+
11
+ static args = {
12
+ environment: Args.string({
13
+ description: "environment",
14
+ default: "default",
15
+ }),
16
+ };
17
+
18
+ static description = "create setting to access the server authentication";
19
+
20
+ static examples = [
21
+ "<%= config.bin %> <%= command.id %> --user=xavier@example.org --token=API-12345789",
22
+ ];
23
+
24
+ static flags = {
25
+ // flag with no value (-f, --force)
26
+ ...super.globalFlags,
27
+ force: Flags.boolean({
28
+ description: "write over an existing configuration",
29
+ default: false,
30
+ helpValue: "(default false)",
31
+ }),
32
+ url: Flags.string({
33
+ description: "url of the proca server api",
34
+ default: "https://api.proca.app/api",
35
+ helpValue: "<url>",
36
+ }),
37
+ token: Flags.string({
38
+ description: "user token on proca server",
39
+ helpValue: "<API-token>",
40
+ required: true,
41
+ }),
42
+ n8n: Flags.string({
43
+ description: "api access on the n8n server",
44
+ helpValue: "<n8n api>",
45
+ }),
46
+ supabase: Flags.string({
47
+ description: "url of the supabase",
48
+ helpValue: "<url>",
49
+ }),
50
+ "supabase-anon-key": Flags.string({
51
+ description: "anonymous key",
52
+ }),
53
+ "supabase-secrey-key": Flags.string({
54
+ description: "secret service key",
55
+ }),
56
+ };
57
+
58
+ format = (obj) => {
59
+ const content = ["# generated by proca-api"];
60
+ for (const [key, value] of Object.entries(obj)) {
61
+ if (value) {
62
+ content.push(`${key}='${value.replace(/'/g, "''")}'`);
63
+ } else {
64
+ content.push(`#${key}= `);
65
+ }
66
+ }
67
+ return content.join("\n");
68
+ };
69
+
70
+ generate = function () {
71
+ const mapping = {
72
+ REACT_APP_NAME: "proca",
73
+ REACT_APP_API_URL: this.flags.url,
74
+ PROCA_TOKEN: this.flags.token,
75
+ N8N_TOKEN: this.flags.n8n,
76
+ REACT_APP_SUPABASE_URL: this.flags.supabase,
77
+ REACT_APP_SUPABASE_ANON_KEY: this.flags.supabase_anon_key,
78
+ SUPABASE_SECRET_KEY: this.flags.supabase_secret_key,
79
+ };
80
+
81
+ return this.format(mapping);
82
+ };
83
+
84
+ async run() {
85
+ const { args, flags } = await this.parse();
86
+ const file = getFilename(this.config.configDir);
87
+
88
+ const userConfig = getConfig(file);
89
+ if (userConfig && !this.flags.force) {
90
+ this.error("config file exists already", {
91
+ code: "CONFIG_ERR",
92
+ _ref: "README.md#",
93
+ suggestions: [
94
+ `edit ${file}`,
95
+ "add --force flag\nWARNING, it will delete the existing file",
96
+ ],
97
+ });
98
+ }
99
+ write(file, this.generate());
100
+ }
101
+ }
@@ -0,0 +1,33 @@
1
+ import crypto from 'crypto';
2
+ import { Args, Flags } from "@oclif/core";
3
+ import { error, stdout, ux } from "@oclif/core/ux";
4
+ import Command from "#src/procaCommand.mjs";
5
+
6
+ export default class UserList extends Command {
7
+ static description =
8
+ "convert between token and sql value";
9
+
10
+
11
+ static flags = {
12
+ token: Flags.string({
13
+ exactlyOne: ["token"],
14
+ description: "the token in your config",
15
+ helpValue: "API-xxx",
16
+ }),
17
+ };
18
+
19
+ async run() {
20
+ const { args, flags } = await this.parse();
21
+ if (flags.token) {
22
+ const token = flags.token.replace("API-","").replace(/-/g, '+').replace(/_/g, '/');
23
+ const decoded = Buffer.from(token, 'base64').toString('utf-8');
24
+ const hexa = crypto.createHash('sha256').update(decoded).digest('hex')
25
+ console.log(token, decoded, hexa);
26
+
27
+ return this.output({hexa:'\\x'+hexa});
28
+ }
29
+ const data = flags;
30
+
31
+ return this.output(data);
32
+ }
33
+ }
@@ -38,13 +38,12 @@ query {
38
38
  };
39
39
 
40
40
  simplify = (d) => {
41
- console.log(d);
42
41
  const result = {
43
42
  id: d.id,
44
43
  email: d.email,
45
44
  };
46
45
  if (d.apiToken) {
47
- result.tokenExpire = "2024-11-09T11:22:22";
46
+ result.tokenExpire = d.apiToken.expiresAt;
48
47
  }
49
48
  if (d.isAdmin) {
50
49
  result.admin = true;
@@ -41,8 +41,11 @@ mutation ($org: OrgInput!) {
41
41
  const result = await mutation(AddOrgDocument, {
42
42
  org,
43
43
  });
44
- console.log(result);
45
- return result.org;
44
+ if (!result.addOrg) {
45
+ console.log(result);
46
+ return result;
47
+ }
48
+ return result?.addOrg;
46
49
  };
47
50
 
48
51
  async run() {
@@ -5,14 +5,15 @@ import Command from "#src/procaCommand.mjs";
5
5
  import { gql, query } from "#src/urql.mjs";
6
6
 
7
7
  export default class OrgGet extends Command {
8
- static args = {};
9
-
10
8
  static description = "view a org";
11
9
 
12
10
  static examples = ["<%= config.bin %> <%= command.id %> <name of the ngo>"];
13
11
 
12
+ static args = {}; //this.multiid();
13
+
14
14
  static flags = {
15
15
  // flag with no value (-f, --force)
16
+ // ...this.flagify({multiid: false}),
16
17
  ...super.globalFlags,
17
18
  name: Flags.string({
18
19
  char: "n",
@@ -0,0 +1,96 @@
1
+ import { Args, Flags } from "@oclif/core";
2
+ import Command from "#src/procaCommand.mjs";
3
+ import { gql, query } from "#src/urql.mjs";
4
+
5
+ export default class CounterGet extends Command {
6
+ static description = "counter of supporters";
7
+
8
+ static examples = [
9
+ "<%= config.bin %> <%= command.id %> --id <id of the campaign>",
10
+ "<%= config.bin %> <%= command.id %> --name <name of the campaign>",
11
+ ];
12
+
13
+ static args = this.multiid();
14
+ static flags = {
15
+ // flag with no value (-f, --force)
16
+ ...this.flagify({ multiid: true }),
17
+ org: Flags.boolean({
18
+ description: "segment by partner",
19
+ default: false,
20
+ }),
21
+ area: Flags.boolean({
22
+ description: "segment by area",
23
+ default: false,
24
+ }),
25
+ without: Flags.string({
26
+ description: "total to add to the partner's counter",
27
+ }),
28
+ number: Flags.boolean({
29
+ description: "just return the number to add to the partner's counter",
30
+ dependsOn: ["without"],
31
+ }),
32
+ };
33
+
34
+ fetchExcluding = async (params) => {
35
+ const GetCounterDocument = gql`
36
+ query GetCounter($name: String, $id: Int, $without: String!) {
37
+ campaign(name: $name, id: $id) {
38
+ stats {
39
+ supporterCount
40
+ supporterCountByOthers (orgName: $without)
41
+ }
42
+ }
43
+ }`;
44
+
45
+ const result = await query(GetCounterDocument, params);
46
+ return result.campaign.stats;
47
+ };
48
+
49
+ fetch = async (params) => {
50
+ const GetCounterDocument = gql`
51
+ query GetCounter($name: String, $id: Int, $org: Boolean = false, $area: Boolean = false) {
52
+ campaign(name: $name, id: $id) {
53
+ stats {
54
+ supporterCount
55
+ supporterCountByOrg @include(if: $org) { org { name } count }
56
+ supporterCountByArea @include(if: $area) { area count }
57
+ }
58
+ }
59
+ }`;
60
+
61
+ const result = await query(GetCounterDocument, params);
62
+ return result.campaign.stats;
63
+ };
64
+
65
+ simplify = (d) => {
66
+ const result = { total: d.supporterCount };
67
+ d.supporterCountByOrg
68
+ ?.sort((a, b) => b.count - a.count)
69
+ .forEach((org) => {
70
+ result[org.org.name] = org.count;
71
+ });
72
+ d.supporterCountByArea
73
+ ?.sort((a, b) => b.count - a.count)
74
+ .forEach((area) => {
75
+ result[area.area] = area.count;
76
+ });
77
+ if (d.supporterCountByOthers) {
78
+ result[`without ${this.flags.without}`] = d.supporterCountByOthers;
79
+ }
80
+ return result;
81
+ };
82
+ table = (r) => {
83
+ super.table(r, null, null);
84
+ };
85
+
86
+ async run() {
87
+ const { args, flags } = await this.parse();
88
+ if (flags.without) {
89
+ const data = await this.fetchExcluding(flags);
90
+ if (flags.number) return console.log(data.supporterCountByOthers);
91
+ return this.output(data);
92
+ }
93
+ const data = await this.fetch(flags);
94
+ return this.output(data);
95
+ }
96
+ }
@@ -1,7 +1,7 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
- import { gql, mutation } from "#src/urql.mjs";
4
3
  import Command from "#src/procaCommand.mjs";
4
+ import { gql, mutation } from "#src/urql.mjs";
5
5
 
6
6
  export default class WidgetAdd extends Command {
7
7
  //static args = { path: { description: "" } };
package/src/config.mjs CHANGED
@@ -11,6 +11,7 @@ export const load = (folder, env = "default") => {
11
11
  return {
12
12
  token: config.parsed.PROCA_TOKEN,
13
13
  url: config.parsed.REACT_APP_API_URL,
14
+ folder: process.env.PROCA_CONFIG_FOLDER,
14
15
  };
15
16
  };
16
17
 
@@ -1,9 +1,17 @@
1
1
  import oclif from "@oclif/core";
2
+ import { config as dotenv } from "dotenv";
3
+ import { getFilename, load } from "#src/config.mjs";
2
4
  import CustomHelp from "./help.mjs";
3
5
 
4
- //console.log("hook init");
5
-
6
6
  const hook = async (opts) => {
7
+ const config = load(opts.config.configDir);
8
+ if (config) {
9
+ opts.config.procaConfig = config;
10
+ } else {
11
+ const file = getFilename(opts.config.configDir);
12
+ this.warn("missing config", file);
13
+ }
14
+
7
15
  //console.log(opts);
8
16
  //console.log(opts.config.helpClass, CustomHelp);
9
17
  // opts.config.helpClass = CustomHelp;
@@ -4,10 +4,9 @@ import { parse as dxid, id } from "dxid";
4
4
  import Table from "easy-table";
5
5
  import fastcsv from "fast-csv";
6
6
 
7
- import { getFilename as fileConfig, load as loadConfig } from "#src/config.mjs";
8
7
  import { createClient } from "#src/urql.mjs";
9
8
 
10
- export class ProcaCommand extends Command {
9
+ class ProcaCommand extends Command {
11
10
  static enableJsonFlag = true;
12
11
  procaConfig = { url: "https://api.proca.app/api" };
13
12
  format = "human"; // the default formatting
@@ -22,7 +21,7 @@ export class ProcaCommand extends Command {
22
21
  json: Flags.boolean({
23
22
  helpGroup: "OUTPUT", // Optional, groups it under a specific help section if desired
24
23
  description: "Format output as json",
25
- exclusive: ["human", "json"],
24
+ exclusive: ["human", "csv"],
26
25
  }),
27
26
  csv: Flags.boolean({
28
27
  description: "Format output as csv",
@@ -49,7 +48,7 @@ export class ProcaCommand extends Command {
49
48
  }
50
49
 
51
50
  static flagify(params = {}) {
52
- const flags = ProcaCommand.baseFlags;
51
+ const flags = Object.assign({}, ProcaCommand.baseFlags);
53
52
  if (params.multiid) {
54
53
  flags.id = Flags.string({
55
54
  char: "i",
@@ -91,36 +90,16 @@ export class ProcaCommand extends Command {
91
90
  if (flags.csv) this.format = "csv";
92
91
 
93
92
  this.debug = debug("proca");
94
- const userConfig = loadConfig(this.config.configDir);
95
- if (userConfig) {
96
- this.procaConfig = userConfig;
97
- } else {
98
- const file = fileConfig(this.config.configDir);
99
- this.warn("missing config", file);
100
- }
101
- createClient(userConfig);
93
+ this.procaConfig = this.config.procaConfig; // set up from the hooks/init
94
+ createClient(this.procaConfig);
102
95
  }
103
96
 
104
97
  async catch(err) {
105
98
  // Check if the error was caused by a missing flag or wrong argument format
106
-
107
- if (
108
- err.message.includes("Unexpected argument") ||
109
- err.message.includes("flag")
110
- ) {
111
- // Try to adjust the argument as a flag
112
- const argv = process.argv;
113
- console.log(argv);
114
- if (argv.includes("param")) {
115
- // Adjusting the argument 'param' to be a flag `-id`
116
- const paramIndex = argv.indexOf("param");
117
- argv.splice(paramIndex, 0, "-id"); // Insert the flag `-id` before 'param'
118
- }
119
-
120
- // Re-run the command with modified arguments
121
- await this.parse();
122
- } else {
123
- throw err;
99
+ try {
100
+ this.error(err.toString());
101
+ } catch (e) {
102
+ console.log(e);
124
103
  }
125
104
  }
126
105
 
@@ -214,7 +193,9 @@ export class ProcaCommand extends Command {
214
193
 
215
194
  async output(data) {
216
195
  if (this.format === "json") {
217
- if (this.flags.simplify) return data.map(this.simplify);
196
+ console.log("json", data);
197
+ if (this.flags.simplify)
198
+ return data?.map(this.simplify) || this.simplify(data);
218
199
  return data;
219
200
  }
220
201
  if (this.format === "csv") {
package/src/urql.mjs CHANGED
@@ -40,7 +40,7 @@ export const createClient = (config) => {
40
40
  export const query = async (query, payload) => {
41
41
  const result = await client.query(query, payload).toPromise();
42
42
  if (result.error) {
43
- console.log(formatError(result.error));
43
+ //console.log(result.error);
44
44
  throw result.error;
45
45
  }
46
46
  return result.data;