proca 1.2.0 → 1.2.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 +34 -4
- package/package.json +2 -1
- package/src/commands/contact/count.mjs +42 -0
- package/src/commands/contact/list.mjs +7 -4
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/1.2.
|
|
21
|
+
proca/1.2.2 linux-x64 node-v20.12.2
|
|
22
22
|
$ proca --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ proca COMMAND
|
|
@@ -58,6 +58,7 @@ USAGE
|
|
|
58
58
|
* [`proca config setup [ENVIRONMENT]`](#proca-config-setup-environment)
|
|
59
59
|
* [`proca config token`](#proca-config-token)
|
|
60
60
|
* [`proca config user`](#proca-config-user)
|
|
61
|
+
* [`proca contact count`](#proca-contact-count)
|
|
61
62
|
* [`proca contact list [TITLE]`](#proca-contact-list-title)
|
|
62
63
|
* [`proca help [COMMAND]`](#proca-help-command)
|
|
63
64
|
* [`proca org add`](#proca-org-add)
|
|
@@ -448,24 +449,53 @@ EXAMPLES
|
|
|
448
449
|
$ proca config user
|
|
449
450
|
```
|
|
450
451
|
|
|
452
|
+
## `proca contact count`
|
|
453
|
+
|
|
454
|
+
counter of supporters
|
|
455
|
+
|
|
456
|
+
```
|
|
457
|
+
USAGE
|
|
458
|
+
$ proca contact count [ID_NAME_DXID] [--json | --human | --csv] [--simplify] [-i <value>
|
|
459
|
+
| -n <the_short_name> | -x <value>]
|
|
460
|
+
|
|
461
|
+
FLAGS
|
|
462
|
+
-i, --id=<value>
|
|
463
|
+
-n, --name=<the_short_name> name
|
|
464
|
+
-x, --dxid=<value> dxid
|
|
465
|
+
|
|
466
|
+
OUTPUT FLAGS
|
|
467
|
+
--csv Format output as csv
|
|
468
|
+
--human Format output to be read on screen by a human [default]
|
|
469
|
+
--json Format output as json
|
|
470
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
471
|
+
|
|
472
|
+
DESCRIPTION
|
|
473
|
+
counter of supporters
|
|
474
|
+
|
|
475
|
+
EXAMPLES
|
|
476
|
+
$ proca contact count --id <id of the campaign>
|
|
477
|
+
|
|
478
|
+
$ proca contact count --name <name of the campaign>
|
|
479
|
+
```
|
|
480
|
+
|
|
451
481
|
## `proca contact list [TITLE]`
|
|
452
482
|
|
|
453
483
|
```
|
|
454
484
|
USAGE
|
|
455
485
|
$ proca contact list [TITLE] -o <organisation name> [--json | --human | --csv] [-c
|
|
456
|
-
<campaign title>] [
|
|
457
|
-
|
|
486
|
+
<campaign title>] [-n <value>] [--today | --after 2025-04-09] [--optin] [--testing] [--doi] [--utm | --simplify]
|
|
487
|
+
[--comment | ]
|
|
458
488
|
|
|
459
489
|
ARGUMENTS
|
|
460
490
|
TITLE name of the campaign, % for wildchar
|
|
461
491
|
|
|
462
492
|
FLAGS
|
|
463
493
|
-c, --campaign=<campaign title> name of the campaign, % for wildchar
|
|
494
|
+
-n, --limit=<value> max number of actions
|
|
464
495
|
-o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
|
|
465
496
|
--after=2025-04-09 only actions after a date
|
|
466
497
|
--[no-]comment display the comment
|
|
467
498
|
--doi only export the double optin actions
|
|
468
|
-
--limit=<value> max number of actions
|
|
469
499
|
--optin only export the optin actions
|
|
470
500
|
--testing also export the test actions
|
|
471
501
|
--today only actions today
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proca",
|
|
3
3
|
"description": "Access the proca api",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"author": "Xavier",
|
|
6
6
|
"bin": {
|
|
7
7
|
"proca": "proca-cli"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@oclif/plugin-help": "^6",
|
|
13
13
|
"@oclif/plugin-plugins": "^5",
|
|
14
14
|
"@urql/exchange-auth": "^2.2.0",
|
|
15
|
+
"date-fns": "^4.1.0",
|
|
15
16
|
"dotenv": "^16.4.5",
|
|
16
17
|
"dxid": "^2.2.1",
|
|
17
18
|
"easy-table": "^1.2.0",
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
};
|
|
18
|
+
|
|
19
|
+
fetch = async (params) => {
|
|
20
|
+
const GetCounterDocument = gql`
|
|
21
|
+
query GetCounter($name: String, $id: Int) {
|
|
22
|
+
campaign(name: $name, id: $id) {
|
|
23
|
+
stats {
|
|
24
|
+
supporterCount
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const result = await query(GetCounterDocument, params);
|
|
30
|
+
return result.campaign.stats;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
table = (r) => {
|
|
34
|
+
super.table(r, null, null);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
async run() {
|
|
38
|
+
const { args, flags } = await this.parse();
|
|
39
|
+
const data = await this.fetch(flags);
|
|
40
|
+
return this.output(data);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import { formatDistanceToNowStrict } from "date-fns";
|
|
3
4
|
import Command from "#src/procaCommand.mjs";
|
|
4
5
|
import {
|
|
5
6
|
FragmentOrg,
|
|
@@ -33,6 +34,7 @@ export default class List extends Command {
|
|
|
33
34
|
helpValue: "<campaign title>",
|
|
34
35
|
}),
|
|
35
36
|
limit: Flags.string({
|
|
37
|
+
char: "n",
|
|
36
38
|
description: "max number of actions",
|
|
37
39
|
parse: (input) => Number.parseInt(input, 10),
|
|
38
40
|
}),
|
|
@@ -98,6 +100,7 @@ export default class List extends Command {
|
|
|
98
100
|
) {
|
|
99
101
|
actionId
|
|
100
102
|
actionPage {
|
|
103
|
+
id
|
|
101
104
|
locale
|
|
102
105
|
name
|
|
103
106
|
}
|
|
@@ -165,16 +168,14 @@ export default class List extends Command {
|
|
|
165
168
|
country: d.contact.country,
|
|
166
169
|
email: d.contact.email,
|
|
167
170
|
type: d.actionType,
|
|
168
|
-
date: d.createdAt,
|
|
169
|
-
campaign: d.campaign.name,
|
|
171
|
+
date: formatDistanceToNowStrict(d.createdAt),
|
|
172
|
+
campaign: !this.flags.campaign && d.campaign.name,
|
|
170
173
|
widget_id: d.actionPage.id,
|
|
171
174
|
widget: d.actionPage.name,
|
|
172
175
|
// customFields
|
|
173
176
|
};
|
|
174
177
|
if (this.flags.comment && d.customFields?.comment)
|
|
175
178
|
result.comment = d.customFields.comment;
|
|
176
|
-
if (d.customFields?.emailProvider)
|
|
177
|
-
result.provider = d.customFields.emailProvider;
|
|
178
179
|
if (this.flags.utm && d.tracking) {
|
|
179
180
|
result.utm_medium =
|
|
180
181
|
d.tracking.medium === "unknown" ? undefined : d.tracking.medium;
|
|
@@ -186,6 +187,8 @@ export default class List extends Command {
|
|
|
186
187
|
result.utm_content =
|
|
187
188
|
d.tracking.content === "unknown" ? undefined : d.tracking.content;
|
|
188
189
|
}
|
|
190
|
+
if (d.customFields?.emailProvider)
|
|
191
|
+
result.provider = d.customFields.emailProvider;
|
|
189
192
|
return result;
|
|
190
193
|
};
|
|
191
194
|
|