proca 1.8.2 → 1.8.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 +190 -25
- package/package.json +2 -1
- package/proca-cli +2 -2
- package/src/commands/action/add.mjs +131 -131
- package/src/commands/action/confirm.mjs +44 -44
- package/src/commands/action/count.mjs +41 -41
- package/src/commands/action/list.mjs +130 -130
- package/src/commands/action/replay.mjs +30 -30
- package/src/commands/action/requeue.mjs +110 -110
- package/src/commands/campaign/add.mjs +95 -83
- package/src/commands/campaign/copy.mjs +91 -0
- package/src/commands/campaign/delete.mjs +36 -56
- package/src/commands/campaign/get.mjs +5 -0
- package/src/commands/campaign/list.mjs +128 -123
- package/src/commands/campaign/queries.graphql +14 -14
- package/src/commands/campaign/status.mjs +39 -39
- package/src/commands/campaign/widget/archive.mjs +124 -0
- package/src/commands/campaign/widget/copy.mjs +175 -0
- package/src/commands/config/add.mjs +78 -78
- package/src/commands/config/folder.mjs +30 -30
- package/src/commands/config/server.mjs +15 -15
- package/src/commands/config/set.mjs +84 -84
- package/src/commands/config/user.mjs +50 -48
- package/src/commands/contact/count.mjs +0 -1
- package/src/commands/contact/list.mjs +131 -131
- package/src/commands/org/add.mjs +51 -51
- package/src/commands/org/crm.mjs +61 -61
- package/src/commands/org/delete.mjs +31 -31
- package/src/commands/org/email.mjs +94 -66
- package/src/commands/org/get.mjs +9 -1
- package/src/commands/service/add.mjs +59 -59
- package/src/commands/service/list.mjs +15 -15
- package/src/commands/target/add.mjs +52 -52
- package/src/commands/template/add.mjs +67 -67
- package/src/commands/template/list.mjs +33 -33
- package/src/commands/user/get.mjs +60 -60
- package/src/commands/user/invite.mjs +37 -37
- package/src/commands/user/join.mjs +51 -51
- package/src/commands/user/leave.mjs +47 -47
- package/src/commands/user/reset.mjs +72 -72
- package/src/commands/widget/add.mjs +61 -70
- package/src/commands/widget/delete.mjs +27 -27
- package/src/commands/widget/get.mjs +5 -0
- package/src/commands/widget/list.mjs +7 -5
- package/src/commands/widget/update.mjs +174 -0
- package/src/config.mjs +31 -31
- package/src/generated/schema.json +10675 -10675
- package/src/hooks/help.mjs +9 -9
- package/src/hooks/init.mjs +26 -26
- package/src/procaCommand.mjs +22 -1
- package/src/urql.mjs +39 -39
- package/src/util/twitter.mjs +19 -19
- package/theme.json +27 -27
package/README.md
CHANGED
|
@@ -22,12 +22,12 @@ $# if you don't have your API token, generate one
|
|
|
22
22
|
$ proca user reset --email <your_email> --passowrd <your password>
|
|
23
23
|
$ proca config init --token=<API-token>
|
|
24
24
|
```
|
|
25
|
-
you can set up the config folder the widget builder will use to store the caches. skip unless you want a different one than the default (your/widget/folder/config).
|
|
26
25
|
|
|
26
|
+
you can set up the config folder the widget builder will use to store the caches. skip unless you want a different one than the default (your/widget/folder/config).
|
|
27
27
|
|
|
28
28
|
### local development
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
```sh-session
|
|
31
31
|
$ git clone https://github.com/fixthestatusquo/proca-cli.git
|
|
32
32
|
$ cd proca-cli
|
|
33
33
|
$ npm install
|
|
@@ -35,14 +35,14 @@ you can set up the config folder the widget builder will use to store the caches
|
|
|
35
35
|
$./proca-cli config add --env=local --url=http://localhost:4000/api
|
|
36
36
|
$./proca-cli config server --env=local #check if the config is working
|
|
37
37
|
$./proca-cli config user #check if the config is working
|
|
38
|
-
|
|
38
|
+
```
|
|
39
39
|
|
|
40
40
|
you should also use the local proca-api in your [widget generator](https://github.com/fixthestatusquo/proca)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
```sh-session
|
|
43
43
|
$ cd /your/path/to/proca
|
|
44
44
|
$ npm link proca # use the local proca-cli repo
|
|
45
|
-
|
|
45
|
+
```
|
|
46
46
|
|
|
47
47
|
# Commands
|
|
48
48
|
|
|
@@ -55,11 +55,14 @@ you should also use the local proca-api in your [widget generator](https://githu
|
|
|
55
55
|
* [`proca action requeue`](#proca-action-requeue)
|
|
56
56
|
* [`proca campaign add [TITLE]`](#proca-campaign-add-title)
|
|
57
57
|
* [`proca campaign close`](#proca-campaign-close)
|
|
58
|
+
* [`proca campaign copy`](#proca-campaign-copy)
|
|
58
59
|
* [`proca campaign delete`](#proca-campaign-delete)
|
|
59
60
|
* [`proca campaign get`](#proca-campaign-get)
|
|
60
61
|
* [`proca campaign list [TITLE]`](#proca-campaign-list-title)
|
|
61
62
|
* [`proca campaign mtt`](#proca-campaign-mtt)
|
|
62
63
|
* [`proca campaign status`](#proca-campaign-status)
|
|
64
|
+
* [`proca campaign widget archive`](#proca-campaign-widget-archive)
|
|
65
|
+
* [`proca campaign widget copy`](#proca-campaign-widget-copy)
|
|
63
66
|
* [`proca campaign widget get`](#proca-campaign-widget-get)
|
|
64
67
|
* [`proca campaign widget rebuild`](#proca-campaign-widget-rebuild)
|
|
65
68
|
* [`proca config add [ENV] [HUMAN] [JSON] [CSV] [MARKDOWN] [SIMPLIFY]`](#proca-config-add-env-human-json-csv-markdown-simplify)
|
|
@@ -106,6 +109,7 @@ you should also use the local proca-api in your [widget generator](https://githu
|
|
|
106
109
|
* [`proca widget get`](#proca-widget-get)
|
|
107
110
|
* [`proca widget list`](#proca-widget-list)
|
|
108
111
|
* [`proca widget rebuild`](#proca-widget-rebuild)
|
|
112
|
+
* [`proca widget update`](#proca-widget-update)
|
|
109
113
|
|
|
110
114
|
## `proca action add`
|
|
111
115
|
|
|
@@ -362,19 +366,56 @@ EXAMPLES
|
|
|
362
366
|
$ proca campaign close -i <campaign_id>
|
|
363
367
|
```
|
|
364
368
|
|
|
369
|
+
## `proca campaign copy`
|
|
370
|
+
|
|
371
|
+
Copy campaign settings to a new campaign
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
USAGE
|
|
375
|
+
$ proca campaign copy [ID_NAME_DXID] -t <campaign name> [--json | --human | --csv |
|
|
376
|
+
--markdown] [--env <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [-o <org name>] [--title
|
|
377
|
+
<campaign title>] [--dry-run]
|
|
378
|
+
|
|
379
|
+
FLAGS
|
|
380
|
+
-i, --id=<value>
|
|
381
|
+
-n, --name=<the_short_name> name
|
|
382
|
+
-o, --org=<org name> organization for the new campaign (defaults to source campaign org)
|
|
383
|
+
-t, --to=<campaign name> (required) new campaign name
|
|
384
|
+
-x, --dxid=<value> dxid
|
|
385
|
+
--dry-run preview changes without executing
|
|
386
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
387
|
+
--title=<campaign title> title for the new campaign (defaults to source campaign title)
|
|
388
|
+
|
|
389
|
+
OUTPUT FLAGS
|
|
390
|
+
--csv Format output as csv
|
|
391
|
+
--human Format output to be read on screen by a human [default]
|
|
392
|
+
--json Format output as json
|
|
393
|
+
--markdown Format output as markdown table
|
|
394
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
395
|
+
|
|
396
|
+
DESCRIPTION
|
|
397
|
+
Copy campaign settings to a new campaign
|
|
398
|
+
|
|
399
|
+
EXAMPLES
|
|
400
|
+
$ proca campaign copy test_2025 --to test_2026
|
|
401
|
+
|
|
402
|
+
$ proca campaign copy -n old_campaign --to new_campaign -o different_org
|
|
403
|
+
```
|
|
404
|
+
|
|
365
405
|
## `proca campaign delete`
|
|
366
406
|
|
|
367
407
|
delete a campaign
|
|
368
408
|
|
|
369
409
|
```
|
|
370
410
|
USAGE
|
|
371
|
-
$ proca campaign delete [--json | --human | --csv | --markdown] [--env
|
|
372
|
-
[--simplify] [-i <
|
|
411
|
+
$ proca campaign delete [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
|
|
412
|
+
<value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
|
|
373
413
|
|
|
374
414
|
FLAGS
|
|
375
|
-
-i, --id=<
|
|
376
|
-
-n, --name=<
|
|
377
|
-
|
|
415
|
+
-i, --id=<value>
|
|
416
|
+
-n, --name=<the_short_name> name
|
|
417
|
+
-x, --dxid=<value> dxid
|
|
418
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
378
419
|
|
|
379
420
|
OUTPUT FLAGS
|
|
380
421
|
--csv Format output as csv
|
|
@@ -387,7 +428,13 @@ DESCRIPTION
|
|
|
387
428
|
delete a campaign
|
|
388
429
|
|
|
389
430
|
EXAMPLES
|
|
431
|
+
$ proca campaign delete 42
|
|
432
|
+
|
|
390
433
|
$ proca campaign delete -i 42
|
|
434
|
+
|
|
435
|
+
$ proca campaign delete my_campaign
|
|
436
|
+
|
|
437
|
+
$ proca campaign delete -n my_campaign
|
|
391
438
|
```
|
|
392
439
|
|
|
393
440
|
## `proca campaign get`
|
|
@@ -520,6 +567,79 @@ EXAMPLES
|
|
|
520
567
|
$ proca campaign status -i <campaign_id>
|
|
521
568
|
```
|
|
522
569
|
|
|
570
|
+
## `proca campaign widget archive`
|
|
571
|
+
|
|
572
|
+
Archive all widgets in the campaign by adding suffix
|
|
573
|
+
|
|
574
|
+
```
|
|
575
|
+
USAGE
|
|
576
|
+
$ proca campaign widget archive [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
|
|
577
|
+
<value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [-s <suffix>] [--dry-run]
|
|
578
|
+
|
|
579
|
+
FLAGS
|
|
580
|
+
-i, --id=<value>
|
|
581
|
+
-n, --name=<the_short_name> name
|
|
582
|
+
-s, --suffix=<suffix> [default: _archive] custom suffix to append (default: _archive)
|
|
583
|
+
-x, --dxid=<value> dxid
|
|
584
|
+
--dry-run preview changes without executing
|
|
585
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
586
|
+
|
|
587
|
+
OUTPUT FLAGS
|
|
588
|
+
--csv Format output as csv
|
|
589
|
+
--human Format output to be read on screen by a human [default]
|
|
590
|
+
--json Format output as json
|
|
591
|
+
--markdown Format output as markdown table
|
|
592
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
593
|
+
|
|
594
|
+
DESCRIPTION
|
|
595
|
+
Archive all widgets in the campaign by adding suffix
|
|
596
|
+
|
|
597
|
+
EXAMPLES
|
|
598
|
+
$ proca campaign widget archive old_campaign
|
|
599
|
+
|
|
600
|
+
$ proca campaign widget archive -n old_campaign --suffix _backup
|
|
601
|
+
|
|
602
|
+
$ proca campaign widget archive old_campaign --dry-run
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
## `proca campaign widget copy`
|
|
606
|
+
|
|
607
|
+
Copy widgets from one campaign to another
|
|
608
|
+
|
|
609
|
+
```
|
|
610
|
+
USAGE
|
|
611
|
+
$ proca campaign widget copy [ID_NAME_DXID] -t <campaign name> [--json | --human | --csv |
|
|
612
|
+
--markdown] [--env <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [-s <suffix>] [--dry-run]
|
|
613
|
+
|
|
614
|
+
FLAGS
|
|
615
|
+
-i, --id=<value>
|
|
616
|
+
-n, --name=<the_short_name> name
|
|
617
|
+
-s, --suffix=<suffix> [default: _archive] suffix to remove from widget names (e.g., _archive, -v1)
|
|
618
|
+
-t, --to=<campaign name> (required) destination campaign name
|
|
619
|
+
-x, --dxid=<value> dxid
|
|
620
|
+
--dry-run preview changes without executing
|
|
621
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
622
|
+
|
|
623
|
+
OUTPUT FLAGS
|
|
624
|
+
--csv Format output as csv
|
|
625
|
+
--human Format output to be read on screen by a human [default]
|
|
626
|
+
--json Format output as json
|
|
627
|
+
--markdown Format output as markdown table
|
|
628
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
629
|
+
|
|
630
|
+
DESCRIPTION
|
|
631
|
+
Copy widgets from one campaign to another
|
|
632
|
+
|
|
633
|
+
EXAMPLES
|
|
634
|
+
$ proca campaign widget copy old_campaign --to new_campaign
|
|
635
|
+
|
|
636
|
+
$ proca campaign widget copy -n old_campaign --to new_campaign
|
|
637
|
+
|
|
638
|
+
$ proca campaign widget copy old_campaign --to new_campaign --suffix _archive
|
|
639
|
+
|
|
640
|
+
$ proca campaign widget copy old_campaign --to new_campaign --dry-run
|
|
641
|
+
```
|
|
642
|
+
|
|
523
643
|
## `proca campaign widget get`
|
|
524
644
|
|
|
525
645
|
List widgets in a campaign
|
|
@@ -846,8 +966,6 @@ DESCRIPTION
|
|
|
846
966
|
counter of supporters
|
|
847
967
|
|
|
848
968
|
EXAMPLES
|
|
849
|
-
$ proca contact count --id <id of the campaign>
|
|
850
|
-
|
|
851
969
|
$ proca contact count --name <name of the campaign>
|
|
852
970
|
```
|
|
853
971
|
|
|
@@ -983,23 +1101,28 @@ EXAMPLES
|
|
|
983
1101
|
|
|
984
1102
|
## `proca org email`
|
|
985
1103
|
|
|
986
|
-
Set service
|
|
1104
|
+
Set email service and supporter confirmation for an org
|
|
987
1105
|
|
|
988
1106
|
```
|
|
989
1107
|
USAGE
|
|
990
|
-
$ proca org email [ID_NAME_DXID] --
|
|
991
|
-
|
|
992
|
-
|
|
1108
|
+
$ proca org email [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
|
|
1109
|
+
<value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--mailer mailjet ses stripe test_stripe
|
|
1110
|
+
system preview webhook supabase smtp] [--from default <org>@proca.app] [--supporter-confirm]
|
|
1111
|
+
[--supporter-confirm-template <value>]
|
|
993
1112
|
|
|
994
1113
|
FLAGS
|
|
995
|
-
--
|
|
996
|
-
|
|
997
|
-
--
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1114
|
+
-i, --id=<value>
|
|
1115
|
+
-n, --name=<the_short_name> name
|
|
1116
|
+
-x, --dxid=<value> dxid
|
|
1117
|
+
--env=<value> [default: default] allow to switch
|
|
1118
|
+
between configurations (server or
|
|
1119
|
+
users)
|
|
1120
|
+
--from=default <org>@proca.app Email address to send from
|
|
1121
|
+
--mailer=mailjet ses stripe test_stripe system preview webhook supabase smtp [default: system] service to send
|
|
1122
|
+
emails
|
|
1123
|
+
--[no-]supporter-confirm enable/disable action confirmation
|
|
1124
|
+
emails
|
|
1125
|
+
--supporter-confirm-template=<value> add confirmation template
|
|
1003
1126
|
|
|
1004
1127
|
OUTPUT FLAGS
|
|
1005
1128
|
--csv Format output as csv
|
|
@@ -1009,7 +1132,7 @@ OUTPUT FLAGS
|
|
|
1009
1132
|
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
1010
1133
|
|
|
1011
1134
|
DESCRIPTION
|
|
1012
|
-
Set service
|
|
1135
|
+
Set email service and supporter confirmation for an org
|
|
1013
1136
|
```
|
|
1014
1137
|
|
|
1015
1138
|
## `proca org get`
|
|
@@ -1865,4 +1988,46 @@ EXAMPLES
|
|
|
1865
1988
|
|
|
1866
1989
|
$ proca campaign widget rebuild Rebuild all the widgets of a campaign
|
|
1867
1990
|
```
|
|
1991
|
+
|
|
1992
|
+
## `proca widget update`
|
|
1993
|
+
|
|
1994
|
+
Update a widget's properties
|
|
1995
|
+
|
|
1996
|
+
```
|
|
1997
|
+
USAGE
|
|
1998
|
+
$ proca widget update [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
|
|
1999
|
+
<value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [-n <widget name>] [-l <locale>] [--color <hex
|
|
2000
|
+
code>] [--confirm-optin] [--confirm-action] [--dry-run]
|
|
2001
|
+
|
|
2002
|
+
FLAGS
|
|
2003
|
+
-i, --id=<value>
|
|
2004
|
+
-l, --locale=<locale> change the locale
|
|
2005
|
+
-n, --name=<the_short_name> name
|
|
2006
|
+
-n, --rename=<widget name> new name for the widget
|
|
2007
|
+
-x, --dxid=<value> dxid
|
|
2008
|
+
--color=<hex code> update color (not yet implemented)
|
|
2009
|
+
--confirm-action add actionConfirm (check email snack) to consent.email component
|
|
2010
|
+
--confirm-optin add confirmOptIn (check email snack) to consent.email component
|
|
2011
|
+
--dry-run Show changes without updating the widget
|
|
2012
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
2013
|
+
|
|
2014
|
+
OUTPUT FLAGS
|
|
2015
|
+
--csv Format output as csv
|
|
2016
|
+
--human Format output to be read on screen by a human [default]
|
|
2017
|
+
--json Format output as json
|
|
2018
|
+
--markdown Format output as markdown table
|
|
2019
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
2020
|
+
|
|
2021
|
+
DESCRIPTION
|
|
2022
|
+
Update a widget's properties
|
|
2023
|
+
|
|
2024
|
+
EXAMPLES
|
|
2025
|
+
$ proca widget update 4454 --name new_widget_name
|
|
2026
|
+
|
|
2027
|
+
$ proca widget update 4454 --locale fr
|
|
2028
|
+
|
|
2029
|
+
$ proca widget update 4454 --confirm-optin
|
|
2030
|
+
|
|
2031
|
+
$ proca widget update 4454 --confirm-optin --dry-run
|
|
2032
|
+
```
|
|
1868
2033
|
<!-- commandsstop -->
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proca",
|
|
3
3
|
"description": "Access the proca api",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.3",
|
|
5
5
|
"author": "Xavier",
|
|
6
6
|
"bin": {
|
|
7
7
|
"proca": "proca-cli"
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"format": "npx @biomejs/biome format --write",
|
|
95
95
|
"lint": "npx @biomejs/biome lint --write",
|
|
96
96
|
"prepack": "oclif manifest && oclif readme",
|
|
97
|
+
"oclif": "oclif manifest && oclif readme",
|
|
97
98
|
"version": "oclif readme && git add README.md"
|
|
98
99
|
}
|
|
99
100
|
}
|
package/proca-cli
CHANGED
|
@@ -5,72 +5,72 @@ import { gql, mutation } from "#src/urql.mjs";
|
|
|
5
5
|
import { getTwitter } from "#src/util/twitter.mjs";
|
|
6
6
|
|
|
7
7
|
export default class ActionAdd extends Command {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
static examples = [
|
|
9
|
+
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org",
|
|
10
|
+
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org --country=FR custom1=A custom2=B",
|
|
11
|
+
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org target=715a9580-cfe6-4005-9e23-61a62ddecfea --subject='MTT subject' --body='message MTT'",
|
|
12
|
+
];
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
static args = this.multiid();
|
|
15
|
+
static strict = false; //THIS DOES NOT WORK
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
17
|
+
static flags = {
|
|
18
|
+
...this.flagify({ multiid: true }),
|
|
19
|
+
id: Flags.integer({
|
|
20
|
+
char: "i",
|
|
21
|
+
description: "widget's id",
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
testing: Flags.boolean({
|
|
25
|
+
default: true,
|
|
26
|
+
allowNo: true, // ✅ enables --no-testing
|
|
27
|
+
description:
|
|
28
|
+
"Run action in testing mode (default: true). Use --no-testing to disable.",
|
|
29
|
+
}),
|
|
30
|
+
optin: Flags.boolean({
|
|
31
|
+
default: false,
|
|
32
|
+
allowNo: true, // ✅ enables --no-optin
|
|
33
|
+
description:
|
|
34
|
+
"Whether the user opts in (default: false). Use --optin to enable or --no-optin to explicitly disable.",
|
|
35
|
+
}),
|
|
36
|
+
action_type: Flags.string({
|
|
37
|
+
default: "register",
|
|
38
|
+
}),
|
|
39
|
+
firstname: Flags.string({
|
|
40
|
+
description: "supporter's firstname",
|
|
41
|
+
required: true,
|
|
42
|
+
}),
|
|
43
|
+
lastname: Flags.string(),
|
|
44
|
+
street: Flags.string(),
|
|
45
|
+
locality: Flags.string(),
|
|
46
|
+
region: Flags.string(),
|
|
47
|
+
country: Flags.string({
|
|
48
|
+
description: "2-letter country iso code",
|
|
49
|
+
parse: async (input) => {
|
|
50
|
+
if (input && !/^[A-Za-z]{2}$/.test(input)) {
|
|
51
|
+
throw new Error("Country code must be exactly 2 letters");
|
|
52
|
+
}
|
|
53
|
+
return input?.toUpperCase(); // optional: normalize to uppercase
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
utm: Flags.string({
|
|
57
|
+
description: "utm=campaign.source.medium",
|
|
58
|
+
}),
|
|
59
|
+
email: Flags.string({
|
|
60
|
+
description: "email",
|
|
61
|
+
required: true,
|
|
62
|
+
}),
|
|
63
|
+
target: Flags.string({ description: "[mtt] uid of the target" }),
|
|
64
|
+
subject: Flags.string({ description: "[mtt] subject of the email" }),
|
|
65
|
+
body: Flags.string({ description: "[mtt] body of the email" }),
|
|
66
|
+
};
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
create = async (flags) => {
|
|
69
|
+
const values = {
|
|
70
|
+
action: {
|
|
71
|
+
actionType: flags.action_type,
|
|
72
|
+
customFields: flags.customFields,
|
|
73
|
+
/* "mtt": {
|
|
74
74
|
"body": "body",
|
|
75
75
|
"files": [
|
|
76
76
|
"files"
|
|
@@ -81,44 +81,44 @@ export default class ActionAdd extends Command {
|
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
84
|
+
testing: flags.testing,
|
|
85
|
+
},
|
|
86
|
+
actionPageId: flags.id,
|
|
87
|
+
contact: {
|
|
88
|
+
address: {
|
|
89
|
+
country: flags.country,
|
|
90
|
+
locality: flags.locality,
|
|
91
|
+
postcode: flags.postcode,
|
|
92
|
+
region: flags.region,
|
|
93
|
+
street: flags.street,
|
|
94
|
+
// "streetNumber": "streetNumber"
|
|
95
|
+
},
|
|
96
|
+
email: flags.email,
|
|
97
|
+
firstName: flags.firstname,
|
|
98
|
+
lastName: flags.lastname,
|
|
99
|
+
phone: flags.phone,
|
|
100
|
+
},
|
|
101
|
+
privacy: {
|
|
102
|
+
// "leadOptIn": true,
|
|
103
|
+
optIn: flags.optin,
|
|
104
|
+
},
|
|
105
|
+
tracking: {
|
|
106
|
+
...flags.tracking,
|
|
107
|
+
location: "proca-cli/action/add",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
if (flags.target) {
|
|
112
|
+
values.action.mtt = {
|
|
113
|
+
targets: [flags.target],
|
|
114
|
+
subject: flags.subject || "Test MTT",
|
|
115
|
+
body: flags.body || "Please ignore, this is a test",
|
|
116
|
+
};
|
|
117
|
+
values.action.actionType = "mail2target";
|
|
118
|
+
}
|
|
119
|
+
console.log(values.action.mtt);
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
const query = gql`
|
|
122
122
|
mutation (
|
|
123
123
|
$action: ActionInput!
|
|
124
124
|
$actionPageId: Int!
|
|
@@ -140,18 +140,18 @@ export default class ActionAdd extends Command {
|
|
|
140
140
|
}
|
|
141
141
|
}`;
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
const result = await mutation(query, values);
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
console.log("result", result);
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
parseUnknownFlags = (argv) => {
|
|
150
|
+
const knownFlags = Object.entries(ActionAdd.flags).flatMap(([key, def]) => {
|
|
151
|
+
const chars = def.char ? [def.char] : [];
|
|
152
|
+
return [key, ...chars];
|
|
153
|
+
});
|
|
154
|
+
/* doesn't work static=false has no effect const unknownFlags = Object.fromEntries(
|
|
155
155
|
argv
|
|
156
156
|
.filter(arg =>
|
|
157
157
|
(/^--?\w+=/.test(arg)) // --key=val or -x=val
|
|
@@ -164,29 +164,29 @@ export default class ActionAdd extends Command {
|
|
|
164
164
|
)
|
|
165
165
|
*/
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
// Extract key=val style positional args (e.g. foo=bar)
|
|
168
|
+
const kvArgs = Object.fromEntries(
|
|
169
|
+
argv
|
|
170
|
+
.filter((arg) => !arg.startsWith("-") && arg.includes("="))
|
|
171
|
+
.map((arg) => arg.split("=")),
|
|
172
|
+
);
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
if (!Object.keys(kvArgs).length) return undefined;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
return kvArgs;
|
|
177
|
+
};
|
|
178
|
+
async run() {
|
|
179
|
+
const { args, flags } = await this.parse(ActionAdd, {
|
|
180
|
+
context: { strict: false /* this does not work*/ },
|
|
181
|
+
});
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
183
|
+
const customFields = this.parseUnknownFlags(this.argv);
|
|
184
|
+
if (customFields) flags.customFields = JSON.stringify(customFields);
|
|
185
|
+
if (flags.utm) {
|
|
186
|
+
const [campaign, source, medium] = flags.utm.split(".");
|
|
187
|
+
flags.tracking = { source, medium, campaign };
|
|
188
|
+
} else flags.tracking = {};
|
|
189
|
+
const data = await this.create(flags);
|
|
190
|
+
return this.output(data);
|
|
191
|
+
}
|
|
192
192
|
}
|