proca 0.8.1 → 1.1.5
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 +1079 -28
- package/package.json +94 -101
- package/proca-cli +8 -0
- package/src/commands/action/count.mjs +61 -0
- package/src/commands/action/list.mjs +204 -0
- package/src/commands/action/replay.mjs +54 -0
- package/src/commands/campaign/add.mjs +101 -0
- package/src/commands/campaign/delete.mjs +61 -0
- package/src/commands/campaign/get.mjs +107 -0
- package/src/commands/campaign/list.mjs +156 -0
- package/src/commands/campaign/queries.graphql +19 -0
- package/src/commands/config/add.mjs +101 -0
- package/src/commands/config/get.mjs +33 -0
- package/src/commands/config/set.mjs +103 -0
- package/src/commands/config/token.mjs +34 -0
- package/src/commands/config/user.mjs +76 -0
- package/src/commands/org/add.mjs +66 -0
- package/src/commands/org/crm.mjs +88 -0
- package/src/commands/org/delete.mjs +48 -0
- package/src/commands/org/get.mjs +97 -0
- package/src/commands/org/join.mjs +77 -0
- package/src/commands/supporter/count.mjs +96 -0
- package/src/commands/user/get.mjs +91 -0
- package/src/commands/user/leave.mjs +52 -0
- package/src/commands/user/list.mjs +71 -0
- package/src/commands/widget/add.mjs +101 -0
- package/src/commands/widget/cache.mjs +29 -0
- package/src/commands/widget/get.mjs +59 -0
- package/src/commands/widget/list.mjs +116 -0
- package/src/config.mjs +36 -0
- package/src/generated/schema.json +10677 -0
- package/src/hooks/help.mjs +14 -0
- package/src/hooks/init.mjs +20 -0
- package/src/index.mjs +1 -0
- package/src/procaCommand.mjs +242 -0
- package/src/queries/campaign.mjs +21 -0
- package/src/queries/widget.mjs +12 -0
- package/src/urql.mjs +60 -0
- package/src/util/twitter.mjs +23 -0
- package/theme.json +29 -0
- package/LICENSE +0 -661
- package/dist/App.css +0 -22
- package/dist/App.js +0 -25
- package/dist/App.test.js +0 -8
- package/dist/Wizard.js +0 -32
- package/dist/components/Alert.js +0 -49
- package/dist/components/Clickify.js +0 -26
- package/dist/components/Consent.js +0 -120
- package/dist/components/Country.js +0 -94
- package/dist/components/Dialog.js +0 -84
- package/dist/components/Disabled.js +0 -3
- package/dist/components/Emoji.js +0 -12
- package/dist/components/FAB.js +0 -70
- package/dist/components/Html.js +0 -56
- package/dist/components/Loader.js +0 -14
- package/dist/components/Openletter.js +0 -443
- package/dist/components/Organisation.js +0 -181
- package/dist/components/Petition.js +0 -16
- package/dist/components/ProcaRoot.js +0 -23
- package/dist/components/ProcaStyle.js +0 -94
- package/dist/components/ProgressCounter.js +0 -64
- package/dist/components/Register.js +0 -345
- package/dist/components/Share.js +0 -177
- package/dist/components/TextField.js +0 -58
- package/dist/components/Twitter.js +0 -127
- package/dist/components/TwitterAction.js +0 -111
- package/dist/components/TwitterList.js +0 -25
- package/dist/components/TwitterText.js +0 -42
- package/dist/components/Widget.js +0 -266
- package/dist/components/bespoke/Download.js +0 -49
- package/dist/components/bespoke/Register-CH.js +0 -505
- package/dist/data/countries.json +0 -114
- package/dist/hooks/useConfig.js +0 -217
- package/dist/hooks/useCount.js +0 -95
- package/dist/hooks/useData.js +0 -59
- package/dist/hooks/useElementWidth.js +0 -46
- package/dist/hooks/useGeoLocation.js +0 -45
- package/dist/hooks/useLayout.js +0 -63
- package/dist/images/Twitter.js +0 -16
- package/dist/images/Twitter.svg +0 -1
- package/dist/index.css +0 -13
- package/dist/index.js +0 -114
- package/dist/lib/domparser.js +0 -12
- package/dist/lib/i18n.js +0 -40
- package/dist/lib/init.js +0 -7
- package/dist/lib/server.js +0 -331
- package/dist/lib/urlparser.js +0 -65
- package/dist/lib/uuid.js +0 -30
- package/dist/locales/README.md +0 -37
- package/dist/locales/common.json +0 -189
- package/dist/locales/de/common.json +0 -46
- package/dist/locales/de/index.js +0 -0
- package/dist/locales/en/common.json +0 -45
- package/dist/locales/fr/common.json +0 -51
- package/dist/locales/index.js +0 -27
- package/dist/locales/it/common.json +0 -46
- package/dist/logo.svg +0 -1
- package/dist/module.js +0 -14
- package/dist/slingshot.xcf +0 -0
- package/dist/tmp.config/0.json +0 -21
- package/dist/tmp.config/2.json +0 -11
- package/dist/tmp.config/20.json +0 -29
- package/dist/tmp.config/28.json +0 -14
- package/dist/tmp.config/32.json +0 -34
- package/dist/tmp.config/35.json +0 -14
- package/dist/tmp.config/null.json +0 -1
package/package.json
CHANGED
|
@@ -1,103 +1,96 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
],
|
|
97
|
-
"development": [
|
|
98
|
-
"last 1 chrome version",
|
|
99
|
-
"last 1 firefox version",
|
|
100
|
-
"last 1 safari version"
|
|
101
|
-
]
|
|
102
|
-
}
|
|
2
|
+
"name": "proca",
|
|
3
|
+
"description": "Access the proca api",
|
|
4
|
+
"version": "1.1.5",
|
|
5
|
+
"author": "Xavier",
|
|
6
|
+
"bin": {
|
|
7
|
+
"proca": "proca-cli"
|
|
8
|
+
},
|
|
9
|
+
"bugs": "https://github.com/fixthestatusquo/git@github.com:fixthestatusquo/proca-cli.git/issues",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@oclif/core": "^4.2.10",
|
|
12
|
+
"@oclif/plugin-help": "^6",
|
|
13
|
+
"@oclif/plugin-plugins": "^5",
|
|
14
|
+
"@urql/exchange-auth": "^2.2.0",
|
|
15
|
+
"dotenv": "^16.4.5",
|
|
16
|
+
"dxid": "^2.2.1",
|
|
17
|
+
"easy-table": "^1.2.0",
|
|
18
|
+
"fast-csv": "^5.0.1",
|
|
19
|
+
"graphql": "^16.10.0",
|
|
20
|
+
"typescript": "^5.7.3",
|
|
21
|
+
"urql": "^4.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@biomejs/biome": "^1.9.3",
|
|
25
|
+
"@graphql-codegen/cli": "^2.x.x",
|
|
26
|
+
"@graphql-codegen/introspection": "^2.x.x",
|
|
27
|
+
"@graphql-codegen/typescript-operations": "^4.2.3",
|
|
28
|
+
"@graphql-codegen/typescript-urql": "^4.0.0",
|
|
29
|
+
"@oclif/plugin-autocomplete": "^3.2.5",
|
|
30
|
+
"@oclif/plugin-commands": "^4.1.3",
|
|
31
|
+
"@oclif/plugin-not-found": "^3.2.22",
|
|
32
|
+
"lefthook": "^1.7.18",
|
|
33
|
+
"oclif": "^4.17.46"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"files": ["/proca-cli", "/src", "/theme.json"],
|
|
39
|
+
"homepage": "https://github.com/fixthestatusquo/git@github.com:fixthestatusquo/proca-cli.git",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"cli",
|
|
42
|
+
"petition",
|
|
43
|
+
"proca",
|
|
44
|
+
"campaigning",
|
|
45
|
+
"digital-engagement",
|
|
46
|
+
"social-change",
|
|
47
|
+
"nonprofit",
|
|
48
|
+
"civic-tech",
|
|
49
|
+
"mobilisation",
|
|
50
|
+
"advocacy",
|
|
51
|
+
"activism",
|
|
52
|
+
"email-campaign",
|
|
53
|
+
"grassroots",
|
|
54
|
+
"gdpr"
|
|
55
|
+
],
|
|
56
|
+
"imports": {
|
|
57
|
+
"#src/*": "./src/*"
|
|
58
|
+
},
|
|
59
|
+
"license": "aGPL3",
|
|
60
|
+
"main": "./proca-cli",
|
|
61
|
+
"oclif": {
|
|
62
|
+
"repository": "github:fixthestatusquo/proca-cli",
|
|
63
|
+
"bin": "proca",
|
|
64
|
+
"theme": "theme.json",
|
|
65
|
+
"topicSeparator": " ",
|
|
66
|
+
"commands": "./src/commands",
|
|
67
|
+
"helpClass": "./src/hooks/help.mjs",
|
|
68
|
+
"topics": {
|
|
69
|
+
"widget": {
|
|
70
|
+
"description": "widgets (actionPages in the API)"
|
|
71
|
+
},
|
|
72
|
+
"campaign": {
|
|
73
|
+
"description": "campaigns"
|
|
74
|
+
},
|
|
75
|
+
"user": {
|
|
76
|
+
"description": "campaigners and other users"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"plugins": [
|
|
80
|
+
"@oclif/plugin-plugins",
|
|
81
|
+
"@oclif/plugin-help",
|
|
82
|
+
"@oclif/plugin-commands"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "git+ssh://git@github.com/fixthestatusquo/proca-cli.git"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"check": "npx @biomejs/biome check --write",
|
|
91
|
+
"format": "npx @biomejs/biome format --write",
|
|
92
|
+
"lint": "npx @biomejs/biome lint --write",
|
|
93
|
+
"prepack": "oclif manifest && oclif readme",
|
|
94
|
+
"version": "oclif readme && git add README.md"
|
|
95
|
+
}
|
|
103
96
|
}
|
package/proca-cli
ADDED
|
@@ -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,204 @@
|
|
|
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 {
|
|
5
|
+
FragmentOrg,
|
|
6
|
+
FragmentStats,
|
|
7
|
+
FragmentSummary,
|
|
8
|
+
} from "#src/queries/campaign.mjs";
|
|
9
|
+
import { gql, query } from "#src/urql.mjs";
|
|
10
|
+
|
|
11
|
+
export default class CampaignList extends Command {
|
|
12
|
+
actionTypes = new Set();
|
|
13
|
+
|
|
14
|
+
static args = {
|
|
15
|
+
title: Args.string({ description: "name of the campaign, % for wildchar" }),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static examples = ["<%= config.bin %> <%= command.id %> %pizza%"];
|
|
19
|
+
|
|
20
|
+
static flags = {
|
|
21
|
+
// flag with no value (-f, --force)
|
|
22
|
+
...super.globalFlags,
|
|
23
|
+
org: Flags.string({
|
|
24
|
+
char: "o",
|
|
25
|
+
description: "campaigns of the organisation (coordinator or partner)",
|
|
26
|
+
required: true,
|
|
27
|
+
// exactlyOne: ["org", "title"],
|
|
28
|
+
helpValue: "<organisation name>",
|
|
29
|
+
}),
|
|
30
|
+
campaign: Flags.string({
|
|
31
|
+
char: "c",
|
|
32
|
+
description: "name of the campaign, % for wildchar",
|
|
33
|
+
helpValue: "<campaign title>",
|
|
34
|
+
}),
|
|
35
|
+
limit: Flags.string({
|
|
36
|
+
description: "max number of actions",
|
|
37
|
+
parse: (input) => Number.parseInt(input, 10),
|
|
38
|
+
}),
|
|
39
|
+
after: Flags.string({
|
|
40
|
+
description: "only actions after a date",
|
|
41
|
+
helpValue: "2025-04-09",
|
|
42
|
+
parse: (input) => new Date(input).toISOString(),
|
|
43
|
+
}),
|
|
44
|
+
today: Flags.boolean({
|
|
45
|
+
description: "only actions today",
|
|
46
|
+
exclusive: ["after"],
|
|
47
|
+
parse: (input) => `${new Date().toISOString().split("T")[0]}T00:00:00Z`,
|
|
48
|
+
}),
|
|
49
|
+
optin: Flags.boolean({
|
|
50
|
+
description: "only export the optin actions",
|
|
51
|
+
default: false,
|
|
52
|
+
}),
|
|
53
|
+
testing: Flags.boolean({
|
|
54
|
+
description: "also export the test actions",
|
|
55
|
+
default: false,
|
|
56
|
+
}),
|
|
57
|
+
doi: Flags.boolean({
|
|
58
|
+
description: "only export the double optin actions",
|
|
59
|
+
default: false,
|
|
60
|
+
}),
|
|
61
|
+
utm: Flags.boolean({
|
|
62
|
+
description: "display the utm tracking parameters",
|
|
63
|
+
default: true,
|
|
64
|
+
allowNo: true,
|
|
65
|
+
exclusive: ["simplify"],
|
|
66
|
+
}),
|
|
67
|
+
comment: Flags.boolean({
|
|
68
|
+
description: "display the comment",
|
|
69
|
+
default: true,
|
|
70
|
+
allowNo: true,
|
|
71
|
+
exclusive: ["simplify"],
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
fetch = async (flags) => {
|
|
76
|
+
const Document = gql`
|
|
77
|
+
query (
|
|
78
|
+
$after: DateTime
|
|
79
|
+
$campaignId: Int
|
|
80
|
+
$campaignName: String
|
|
81
|
+
$includeTesting: Boolean
|
|
82
|
+
$limit: Int
|
|
83
|
+
$onlyDoubleOptIn: Boolean
|
|
84
|
+
$onlyOptIn: Boolean
|
|
85
|
+
$orgName: String!
|
|
86
|
+
$start: Int
|
|
87
|
+
) {
|
|
88
|
+
exportActions(
|
|
89
|
+
after: $after
|
|
90
|
+
campaignId: $campaignId
|
|
91
|
+
campaignName: $campaignName
|
|
92
|
+
includeTesting: $includeTesting
|
|
93
|
+
limit: $limit
|
|
94
|
+
onlyDoubleOptIn: $onlyDoubleOptIn
|
|
95
|
+
onlyOptIn: $onlyOptIn
|
|
96
|
+
orgName: $orgName
|
|
97
|
+
start: $start
|
|
98
|
+
) {
|
|
99
|
+
actionId
|
|
100
|
+
actionPage {
|
|
101
|
+
locale
|
|
102
|
+
name
|
|
103
|
+
}
|
|
104
|
+
actionType
|
|
105
|
+
campaign {
|
|
106
|
+
name
|
|
107
|
+
}
|
|
108
|
+
contact {
|
|
109
|
+
contactRef
|
|
110
|
+
payload
|
|
111
|
+
nonce
|
|
112
|
+
publicKey {
|
|
113
|
+
public
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
createdAt
|
|
117
|
+
customFields
|
|
118
|
+
privacy {
|
|
119
|
+
emailStatus
|
|
120
|
+
emailStatusChanged
|
|
121
|
+
givenAt
|
|
122
|
+
optIn
|
|
123
|
+
withConsent
|
|
124
|
+
}
|
|
125
|
+
tracking {
|
|
126
|
+
campaign
|
|
127
|
+
content
|
|
128
|
+
medium
|
|
129
|
+
source
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
const result = await query(Document, {
|
|
135
|
+
after: flags.after,
|
|
136
|
+
// "campaignId": 42,
|
|
137
|
+
campaignName: flags.campaign,
|
|
138
|
+
includeTesting: flags.testing,
|
|
139
|
+
limit: flags.limit,
|
|
140
|
+
onlyDoubleOptIn: flags.doi,
|
|
141
|
+
onlyOptIn: flags.optin,
|
|
142
|
+
orgName: flags.org,
|
|
143
|
+
start: flags.start,
|
|
144
|
+
});
|
|
145
|
+
return result.exportActions.map((d) => {
|
|
146
|
+
d.customFields = JSON.parse(d.customFields);
|
|
147
|
+
if (!d.contact.publicKey) {
|
|
148
|
+
const ref = d.contactRef;
|
|
149
|
+
d.contact = JSON.parse(d.contact.payload);
|
|
150
|
+
d.contact.contactRef = ref;
|
|
151
|
+
} else {
|
|
152
|
+
this.error(
|
|
153
|
+
`encrypted contact we need the private key for ${d.contact.publicKey.public}`,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return d;
|
|
157
|
+
});
|
|
158
|
+
// return result.exportActions;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
simplify = (d) => {
|
|
162
|
+
const result = {
|
|
163
|
+
id: d.actionId,
|
|
164
|
+
firstname: d.contact.firstName,
|
|
165
|
+
country: d.contact.country,
|
|
166
|
+
email: d.contact.email,
|
|
167
|
+
type: d.actionType,
|
|
168
|
+
date: d.createdAt,
|
|
169
|
+
campaign: d.campaign.name,
|
|
170
|
+
widget_id: d.actionPage.id,
|
|
171
|
+
widget: d.actionPage.name,
|
|
172
|
+
// customFields
|
|
173
|
+
};
|
|
174
|
+
if (this.flags.comment && d.customFields?.comment)
|
|
175
|
+
result.comment = d.customFields.comment;
|
|
176
|
+
if (d.customFields?.emailProvider)
|
|
177
|
+
result.provider = d.customFields.emailProvider;
|
|
178
|
+
if (this.flags.utm && d.tracking) {
|
|
179
|
+
result.utm_medium =
|
|
180
|
+
d.tracking.medium === "unknown" ? undefined : d.tracking.medium;
|
|
181
|
+
result.utm_source =
|
|
182
|
+
d.tracking.source === "unknown" ? undefined : d.tracking.source;
|
|
183
|
+
result.utm_campaign =
|
|
184
|
+
d.tracking.campaign === "unknown" ? undefined : d.tracking.campaign;
|
|
185
|
+
if (d.tracking.content)
|
|
186
|
+
result.utm_content =
|
|
187
|
+
d.tracking.content === "unknown" ? undefined : d.tracking.content;
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
_table = (r) => {
|
|
193
|
+
super.table(r, null, (table) => table.sort(["id|des"]).toString());
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
async run() {
|
|
197
|
+
const { args, flags } = await this.parse();
|
|
198
|
+
if (flags.today) flags.after = flags.today;
|
|
199
|
+
let data = [];
|
|
200
|
+
|
|
201
|
+
data = await this.fetch(flags);
|
|
202
|
+
return this.output(data);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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, query } from "#src/urql.mjs";
|
|
5
|
+
|
|
6
|
+
export default class ReplayAction extends Command {
|
|
7
|
+
static examples = ["<%= config.bin %> <%= command.id %> %pizza%"];
|
|
8
|
+
|
|
9
|
+
static flags = {
|
|
10
|
+
// flag with no value (-f, --force)
|
|
11
|
+
...super.globalFlags,
|
|
12
|
+
org: Flags.string({
|
|
13
|
+
char: "o",
|
|
14
|
+
description: "campaigns of the organisation (coordinator or partner)",
|
|
15
|
+
required: true,
|
|
16
|
+
// exactlyOne: ["org", "title"],
|
|
17
|
+
helpValue: "<organisation name>",
|
|
18
|
+
}),
|
|
19
|
+
/* queue: Flag.string({
|
|
20
|
+
default: "CUSTOM_ACTION_DELIVER",
|
|
21
|
+
options: [
|
|
22
|
+
'CUSTOM_ACTION_CONFIRM',
|
|
23
|
+
'CUSTOM_ACTION_DELIVER',
|
|
24
|
+
'CUSTOM_SUPPORTER_CONFIRM',
|
|
25
|
+
'EMAIL_SUPPORTER',
|
|
26
|
+
'SQS',
|
|
27
|
+
'WEBHOOK'
|
|
28
|
+
],
|
|
29
|
+
}),
|
|
30
|
+
*/
|
|
31
|
+
campaign: Flags.string({
|
|
32
|
+
char: "c",
|
|
33
|
+
description: "name of the campaign, % for wildchar",
|
|
34
|
+
helpValue: "<campaign title>",
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
mutate = async (org, id, queue) => {
|
|
39
|
+
const Document = gql`
|
|
40
|
+
mutation Requeue($org: String!, $ids: [Int!]!, $queue: Queue!){
|
|
41
|
+
requeueActions(orgName:$org, ids: $ids, queue: $queue) {
|
|
42
|
+
count failed
|
|
43
|
+
}
|
|
44
|
+
}`;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
async run() {
|
|
48
|
+
const { args, flags } = await this.parse();
|
|
49
|
+
let data = [];
|
|
50
|
+
const ids = [];
|
|
51
|
+
data = await this.mutate(flags.org, ids, flags.queue);
|
|
52
|
+
return this.output(data);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import OrgGet from "#src/commands/org/get.mjs";
|
|
4
|
+
import Command from "#src/procaCommand.mjs";
|
|
5
|
+
import { gql, mutation } from "#src/urql.mjs";
|
|
6
|
+
import { getTwitter } from "#src/util/twitter.mjs";
|
|
7
|
+
|
|
8
|
+
export default class CampaignAdd extends Command {
|
|
9
|
+
static args = {
|
|
10
|
+
title: Args.string({
|
|
11
|
+
description: "title of the campaign",
|
|
12
|
+
multiple: true,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
// static strict = false;
|
|
16
|
+
|
|
17
|
+
static examples = [
|
|
18
|
+
"<%= config.bin %> <%= command.id %> -n <new_campaign> the full name of the campaign",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
static flags = {
|
|
22
|
+
// flag with no value (-f, --force)
|
|
23
|
+
...super.globalFlags,
|
|
24
|
+
name: Flags.string({
|
|
25
|
+
char: "n",
|
|
26
|
+
description: "name of the campaign",
|
|
27
|
+
helpValue: "<campaign name>",
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
org: Flags.string({
|
|
31
|
+
char: "o",
|
|
32
|
+
description: "name of the coordinator",
|
|
33
|
+
helpValue: "<org name>",
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
create = async (campaign) => {
|
|
39
|
+
const org = await this.getOrg(campaign.org);
|
|
40
|
+
|
|
41
|
+
const config = {
|
|
42
|
+
locales: {
|
|
43
|
+
en: {
|
|
44
|
+
"campaign:": {
|
|
45
|
+
description: "",
|
|
46
|
+
},
|
|
47
|
+
"common:": {},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
if (org.config.locale && org.config.locale !== "en") {
|
|
52
|
+
config.locales[org.config.locale] = {};
|
|
53
|
+
}
|
|
54
|
+
if (!config.portal) {
|
|
55
|
+
config.portal = [];
|
|
56
|
+
}
|
|
57
|
+
const AddOrgDocument = gql`
|
|
58
|
+
mutation ($org: String!
|
|
59
|
+
$name: String!
|
|
60
|
+
$title: String!
|
|
61
|
+
$config: Json!
|
|
62
|
+
) {
|
|
63
|
+
addCampaign (input: { name: $name, title: $title, config: $config }, orgName: $org) {
|
|
64
|
+
name
|
|
65
|
+
title
|
|
66
|
+
config
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
const result = await mutation(AddOrgDocument, {
|
|
71
|
+
org: org.name,
|
|
72
|
+
name: campaign.name,
|
|
73
|
+
title: campaign.title,
|
|
74
|
+
config: JSON.stringify(config),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
console.log("result", result);
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
async getOrg(orgName) {
|
|
82
|
+
const { config } = this;
|
|
83
|
+
const orgGet = new OrgGet({}, this.config);
|
|
84
|
+
const org = await orgGet.fetch({ name: orgName });
|
|
85
|
+
return org;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async run() {
|
|
89
|
+
//const { args, flags } = await this.parse(CampaignAdd);
|
|
90
|
+
const { args, flags } = await this.parse();
|
|
91
|
+
|
|
92
|
+
const campaign = {
|
|
93
|
+
org: flags.org,
|
|
94
|
+
name: flags.name,
|
|
95
|
+
title: args.title || flags.name,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const data = await this.create(campaign);
|
|
99
|
+
return this.output(data);
|
|
100
|
+
}
|
|
101
|
+
}
|