proca 2.1.1 → 2.2.0
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 +32 -30
- package/package.json +1 -1
- package/src/commands/contact/count.mjs +39 -5
- package/src/procaCommand.mjs +27 -13
package/README.md
CHANGED
|
@@ -119,13 +119,13 @@ you should also use the local proca-api in your [widget generator](https://githu
|
|
|
119
119
|
```
|
|
120
120
|
USAGE
|
|
121
121
|
$ proca action add [ID_NAME_DXID...] -i <value> --firstname <value> --email <value>
|
|
122
|
-
[--json | --csv | --markdown] [--env <value>] [--simplify] [-
|
|
122
|
+
[--json | --csv | --markdown] [--env <value>] [--simplify] [-n <the_short_name>] [-x <value>] [--testing] [--optin]
|
|
123
123
|
[--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>] [--country
|
|
124
124
|
<value>] [--utm <value>] [--target <value>] [--subject <value>] [--body <value>]
|
|
125
125
|
|
|
126
126
|
FLAGS
|
|
127
127
|
-i, --id=<value> (required) widget's id
|
|
128
|
-
-n, --name=<the_short_name> name
|
|
128
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
129
129
|
-x, --dxid=<value> dxid
|
|
130
130
|
--action_type=<value> [default: register]
|
|
131
131
|
--body=<value> [mtt] body of the email
|
|
@@ -196,7 +196,7 @@ USAGE
|
|
|
196
196
|
|
|
197
197
|
FLAGS
|
|
198
198
|
-i, --id=<value>
|
|
199
|
-
-n, --name=<the_short_name> name
|
|
199
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
200
200
|
-x, --dxid=<value> dxid
|
|
201
201
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
202
202
|
|
|
@@ -371,7 +371,7 @@ USAGE
|
|
|
371
371
|
|
|
372
372
|
FLAGS
|
|
373
373
|
-i, --id=<value>
|
|
374
|
-
-n, --name=<the_short_name> name
|
|
374
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
375
375
|
-o, --org=<org name> organization for the new campaign (defaults to source campaign org)
|
|
376
376
|
-t, --to=<campaign name> (required) new campaign name
|
|
377
377
|
-x, --dxid=<value> dxid
|
|
@@ -405,7 +405,7 @@ USAGE
|
|
|
405
405
|
|
|
406
406
|
FLAGS
|
|
407
407
|
-i, --id=<value>
|
|
408
|
-
-n, --name=<the_short_name> name
|
|
408
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
409
409
|
-x, --dxid=<value> dxid
|
|
410
410
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
411
411
|
|
|
@@ -439,7 +439,7 @@ USAGE
|
|
|
439
439
|
|
|
440
440
|
FLAGS
|
|
441
441
|
-i, --id=<value>
|
|
442
|
-
-n, --name=<the_short_name> name
|
|
442
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
443
443
|
-x, --dxid=<value> dxid
|
|
444
444
|
--[no-]config display the config
|
|
445
445
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
@@ -466,13 +466,13 @@ list all the campaigns
|
|
|
466
466
|
```
|
|
467
467
|
USAGE
|
|
468
468
|
$ proca campaign list [--json | --csv | --markdown] [--env <value>] [--simplify] [-n
|
|
469
|
-
<
|
|
469
|
+
<name of the organisation>] [-t <campaign title>...] [--stats]
|
|
470
470
|
|
|
471
471
|
FLAGS
|
|
472
|
-
-n, --name=<
|
|
473
|
-
-t, --title=<campaign title>...
|
|
474
|
-
--env=<value>
|
|
475
|
-
--[no-]stats
|
|
472
|
+
-n, --name=<name of the organisation> name (technical short name, also called slug)
|
|
473
|
+
-t, --title=<campaign title>... name of the campaign
|
|
474
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
475
|
+
--[no-]stats display the stats
|
|
476
476
|
|
|
477
477
|
OUTPUT FLAGS
|
|
478
478
|
--csv Format output as csv
|
|
@@ -496,7 +496,7 @@ USAGE
|
|
|
496
496
|
|
|
497
497
|
FLAGS
|
|
498
498
|
-i, --id=<value>
|
|
499
|
-
-n, --name=<the_short_name> name
|
|
499
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
500
500
|
-x, --dxid=<value> dxid
|
|
501
501
|
--cc=<value> comma-separated list of CC email addresses
|
|
502
502
|
--drip drip delivery or deliver as fast as possible
|
|
@@ -559,7 +559,7 @@ USAGE
|
|
|
559
559
|
|
|
560
560
|
FLAGS
|
|
561
561
|
-i, --id=<value>
|
|
562
|
-
-n, --name=<the_short_name> name
|
|
562
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
563
563
|
-s, --suffix=<suffix> [default: _archive] custom suffix to append (default: _archive)
|
|
564
564
|
-x, --dxid=<value> dxid
|
|
565
565
|
--dry-run preview changes without executing
|
|
@@ -593,7 +593,7 @@ USAGE
|
|
|
593
593
|
|
|
594
594
|
FLAGS
|
|
595
595
|
-i, --id=<value>
|
|
596
|
-
-n, --name=<the_short_name> name
|
|
596
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
597
597
|
-s, --suffix=<suffix> [default: _archive] suffix to remove from widget names (e.g., _archive, -v1)
|
|
598
598
|
-t, --to=<campaign name> (required) destination campaign name
|
|
599
599
|
-x, --dxid=<value> dxid
|
|
@@ -630,7 +630,7 @@ USAGE
|
|
|
630
630
|
|
|
631
631
|
FLAGS
|
|
632
632
|
-i, --id=<value>
|
|
633
|
-
-n, --name=<the_short_name> name
|
|
633
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
634
634
|
-x, --dxid=<value> dxid
|
|
635
635
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
636
636
|
|
|
@@ -655,7 +655,7 @@ USAGE
|
|
|
655
655
|
|
|
656
656
|
FLAGS
|
|
657
657
|
-i, --id=<value>
|
|
658
|
-
-n, --name=<the_short_name> name
|
|
658
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
659
659
|
-x, --dxid=<value> dxid
|
|
660
660
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
661
661
|
|
|
@@ -915,7 +915,7 @@ USAGE
|
|
|
915
915
|
|
|
916
916
|
FLAGS
|
|
917
917
|
-i, --id=<value>
|
|
918
|
-
-n, --name=<the_short_name> name
|
|
918
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
919
919
|
-x, --dxid=<value> dxid
|
|
920
920
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
921
921
|
|
|
@@ -934,18 +934,19 @@ EXAMPLES
|
|
|
934
934
|
|
|
935
935
|
## `proca contact count`
|
|
936
936
|
|
|
937
|
-
counter of supporters
|
|
937
|
+
counter of supporters of a campaign
|
|
938
938
|
|
|
939
939
|
```
|
|
940
940
|
USAGE
|
|
941
941
|
$ proca contact count [ID_NAME_DXID] [--json | --csv | --markdown] [--env <value>]
|
|
942
|
-
[--simplify] [-i <value> | -n <
|
|
942
|
+
[--simplify] [-i <value> | -n <campaign> | -x <value>] [--query]
|
|
943
943
|
|
|
944
944
|
FLAGS
|
|
945
945
|
-i, --id=<value>
|
|
946
|
-
-n, --name=<
|
|
947
|
-
-x, --dxid=<value>
|
|
948
|
-
--env=<value>
|
|
946
|
+
-n, --name=<campaign> name (technical short name, also called slug)
|
|
947
|
+
-x, --dxid=<value> dxid
|
|
948
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
949
|
+
--query display the REST api query
|
|
949
950
|
|
|
950
951
|
OUTPUT FLAGS
|
|
951
952
|
--csv Format output as csv
|
|
@@ -954,7 +955,7 @@ OUTPUT FLAGS
|
|
|
954
955
|
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
955
956
|
|
|
956
957
|
DESCRIPTION
|
|
957
|
-
counter of supporters
|
|
958
|
+
counter of supporters of a campaign
|
|
958
959
|
|
|
959
960
|
EXAMPLES
|
|
960
961
|
$ proca contact count --name <name of the campaign>
|
|
@@ -1095,7 +1096,8 @@ USAGE
|
|
|
1095
1096
|
|
|
1096
1097
|
FLAGS
|
|
1097
1098
|
-i, --id=<value>
|
|
1098
|
-
-n, --name=<the_short_name> name
|
|
1099
|
+
-n, --name=<the_short_name> name (technical short name, also
|
|
1100
|
+
called slug)
|
|
1099
1101
|
-x, --dxid=<value> dxid
|
|
1100
1102
|
--env=<value> [default: default] allow to switch
|
|
1101
1103
|
between configurations (server or
|
|
@@ -1847,7 +1849,7 @@ USAGE
|
|
|
1847
1849
|
|
|
1848
1850
|
FLAGS
|
|
1849
1851
|
-i, --id=<value>
|
|
1850
|
-
-n, --name=<the_short_name> name
|
|
1852
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
1851
1853
|
-x, --dxid=<value> dxid
|
|
1852
1854
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
1853
1855
|
|
|
@@ -1872,7 +1874,7 @@ USAGE
|
|
|
1872
1874
|
|
|
1873
1875
|
FLAGS
|
|
1874
1876
|
-i, --id=<value>
|
|
1875
|
-
-n, --name=<the_short_name> name
|
|
1877
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
1876
1878
|
-x, --dxid=<value> dxid
|
|
1877
1879
|
--[no-]config display the config
|
|
1878
1880
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
@@ -1926,7 +1928,7 @@ USAGE
|
|
|
1926
1928
|
|
|
1927
1929
|
FLAGS
|
|
1928
1930
|
-i, --id=<value>
|
|
1929
|
-
-n, --name=<the_short_name> name
|
|
1931
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
1930
1932
|
-x, --dxid=<value> dxid
|
|
1931
1933
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
1932
1934
|
|
|
@@ -1962,7 +1964,7 @@ USAGE
|
|
|
1962
1964
|
FLAGS
|
|
1963
1965
|
-i, --id=<value>
|
|
1964
1966
|
-l, --locale=<locale> change the locale
|
|
1965
|
-
-n, --name=<the_short_name> name
|
|
1967
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
1966
1968
|
-x, --dxid=<value> dxid
|
|
1967
1969
|
--color=<hex code> update color (not yet implemented)
|
|
1968
1970
|
--confirm-action add actionConfirm (check email snack) to consent.email component
|
|
@@ -1998,7 +2000,7 @@ USAGE
|
|
|
1998
2000
|
|
|
1999
2001
|
FLAGS
|
|
2000
2002
|
-i, --id=<value>
|
|
2001
|
-
-n, --name=<the_short_name> name
|
|
2003
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
2002
2004
|
-t, --total=<value> (required) new total to include
|
|
2003
2005
|
-x, --dxid=<value> dxid
|
|
2004
2006
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
@@ -2027,7 +2029,7 @@ USAGE
|
|
|
2027
2029
|
|
|
2028
2030
|
FLAGS
|
|
2029
2031
|
-i, --id=<value>
|
|
2030
|
-
-n, --name=<the_short_name> name
|
|
2032
|
+
-n, --name=<the_short_name> name (technical short name, also called slug)
|
|
2031
2033
|
-x, --dxid=<value> dxid
|
|
2032
2034
|
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
2033
2035
|
--rename=<widget name> new name for the widget
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import { getCampaign } from "#src/commands/campaign/get.mjs";
|
|
2
3
|
import Command from "#src/procaCommand.mjs";
|
|
4
|
+
|
|
3
5
|
import { gql, query } from "#src/urql.mjs";
|
|
4
6
|
|
|
5
7
|
export default class CounterGet extends Command {
|
|
6
|
-
static description = "counter of supporters";
|
|
8
|
+
static description = "counter of supporters of a campaign";
|
|
7
9
|
|
|
8
10
|
static examples = [
|
|
9
11
|
"<%= config.bin %> <%= command.id %> --name <name of the campaign>",
|
|
@@ -12,10 +14,28 @@ export default class CounterGet extends Command {
|
|
|
12
14
|
static args = this.multiid();
|
|
13
15
|
static flags = {
|
|
14
16
|
// flag with no value (-f, --force)
|
|
15
|
-
...this.flagify({ multiid: true }),
|
|
17
|
+
...this.flagify({ multiid: true, name: "campaign" }),
|
|
18
|
+
query: Flags.boolean({
|
|
19
|
+
description: "display the REST api query",
|
|
20
|
+
default: false,
|
|
21
|
+
}),
|
|
16
22
|
};
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
getMinifiedDoc = (id) => {
|
|
25
|
+
const query = `{
|
|
26
|
+
campaign(id: ${id}) {
|
|
27
|
+
stats {
|
|
28
|
+
supporterCount
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}`;
|
|
32
|
+
return query
|
|
33
|
+
.replace(/\s*([{}():,])\s*/g, "$1")
|
|
34
|
+
.replace(/\s+/g, " ")
|
|
35
|
+
.trim();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
getDoc = () => {
|
|
19
39
|
const GetCounterDocument = gql`
|
|
20
40
|
query GetCounter($name: String, $id: Int) {
|
|
21
41
|
campaign(name: $name, id: $id) {
|
|
@@ -25,6 +45,11 @@ export default class CounterGet extends Command {
|
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
47
|
`;
|
|
48
|
+
return GetCounterDocument;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
fetch = async (params) => {
|
|
52
|
+
const GetCounterDocument = this.getDoc();
|
|
28
53
|
const result = await query(GetCounterDocument, params);
|
|
29
54
|
return result.campaign.stats;
|
|
30
55
|
};
|
|
@@ -34,7 +59,16 @@ export default class CounterGet extends Command {
|
|
|
34
59
|
};
|
|
35
60
|
|
|
36
61
|
async run() {
|
|
37
|
-
const {
|
|
62
|
+
const { flags } = await this.parse();
|
|
63
|
+
if (flags.query) {
|
|
64
|
+
const camp = await getCampaign(flags);
|
|
65
|
+
const query = this.getMinifiedDoc(camp.id);
|
|
66
|
+
return this.output({
|
|
67
|
+
api: query,
|
|
68
|
+
url: `${this.procaConfig.url}?query=${encodeURIComponent(query)}`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
38
72
|
const data = await this.fetch(flags);
|
|
39
73
|
return this.output(data);
|
|
40
74
|
}
|
package/src/procaCommand.mjs
CHANGED
|
@@ -44,23 +44,23 @@ class ProcaCommand extends Command {
|
|
|
44
44
|
ignoreStdin: true,
|
|
45
45
|
hidden: true,
|
|
46
46
|
description:
|
|
47
|
-
"
|
|
47
|
+
"convenience, but try to use -i <id> or -x <dxid> or -n <name> instead",
|
|
48
48
|
}),
|
|
49
49
|
};
|
|
50
50
|
return args;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
static flagify(
|
|
53
|
+
static flagify({ multiid = false, name = false } = {}) {
|
|
54
54
|
const flags = Object.assign({}, ProcaCommand.baseFlags);
|
|
55
|
-
if (
|
|
55
|
+
if (name || multiid) {
|
|
56
56
|
flags.name = Flags.string({
|
|
57
57
|
char: "n",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
description: "name (technical short name, also called slug)",
|
|
59
|
+
helpValue: typeof name === "string" ? `<${name}>` : "<the_short_name>",
|
|
60
|
+
parse: (input) => ProcaCommand.safeName(input),
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
if (
|
|
63
|
+
if (multiid) {
|
|
64
64
|
flags.id = Flags.string({
|
|
65
65
|
char: "i",
|
|
66
66
|
parse: (input) => Number.parseInt(input, 10),
|
|
@@ -70,15 +70,18 @@ class ProcaCommand extends Command {
|
|
|
70
70
|
char: "x",
|
|
71
71
|
description: "dxid",
|
|
72
72
|
});
|
|
73
|
-
flags.name = Flags.string({
|
|
74
|
-
char: "n",
|
|
75
|
-
description: "name",
|
|
76
|
-
helpValue: "<the_short_name>",
|
|
77
|
-
});
|
|
78
73
|
}
|
|
79
74
|
return flags;
|
|
80
75
|
}
|
|
81
76
|
|
|
77
|
+
static safeName = (input) => {
|
|
78
|
+
const pattern = /^[a-zA-Z0-9\-_]+$/;
|
|
79
|
+
if (!pattern.test(input)) {
|
|
80
|
+
throw new Error(`Invalid characters in: ${input}`);
|
|
81
|
+
}
|
|
82
|
+
return input;
|
|
83
|
+
};
|
|
84
|
+
|
|
82
85
|
async parse() {
|
|
83
86
|
const parsed = await super.parse();
|
|
84
87
|
if (this.ctor.args.id_name_dxid === undefined) {
|
|
@@ -86,9 +89,20 @@ class ProcaCommand extends Command {
|
|
|
86
89
|
}
|
|
87
90
|
const maybe = parsed.args.id_name_dxid;
|
|
88
91
|
if (maybe) {
|
|
92
|
+
const identified = [
|
|
93
|
+
parsed.flags.name,
|
|
94
|
+
parsed.flags.id,
|
|
95
|
+
parsed.flags.dxid,
|
|
96
|
+
].filter(Boolean).length;
|
|
97
|
+
|
|
98
|
+
if (identified > 0) {
|
|
99
|
+
super.error("can't have --name, --id, or --dxid and an unamed arg", {
|
|
100
|
+
code: 1,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
89
103
|
const d = dxid(maybe, false);
|
|
90
104
|
if (d) parsed.flags.id = d;
|
|
91
|
-
else parsed.flags.name = maybe;
|
|
105
|
+
else parsed.flags.name = ProcaCommand.safeName(maybe);
|
|
92
106
|
}
|
|
93
107
|
if (parsed.flags.dxid) {
|
|
94
108
|
parsed.flags.id = dxid(parsed.flags.dxid);
|