@proca/cli 3.4.5 → 3.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 +1991 -61
- package/package.json +88 -72
- package/proca-cli +8 -0
- package/src/commands/action/add.mjs +192 -0
- package/src/commands/action/confirm.mjs +93 -0
- package/src/commands/action/count.mjs +61 -0
- package/src/commands/action/list.mjs +204 -0
- package/src/commands/action/replay.mjs +56 -0
- package/src/commands/action/requeue.mjs +156 -0
- package/src/commands/campaign/add.mjs +113 -0
- package/src/commands/campaign/copy.mjs +91 -0
- package/src/commands/campaign/delete.mjs +41 -0
- package/src/commands/campaign/get.mjs +132 -0
- package/src/commands/campaign/list.mjs +161 -0
- package/src/commands/campaign/mtt.mjs +131 -0
- package/src/commands/campaign/queries.graphql +19 -0
- package/src/commands/campaign/status.mjs +63 -0
- package/src/commands/campaign/widget/archive.mjs +124 -0
- package/src/commands/campaign/widget/copy.mjs +175 -0
- package/src/commands/campaign/widget/get.mjs +19 -0
- package/src/commands/campaign/widget/index.mjs +17 -0
- package/src/commands/campaign/widget/rebuild.mjs +50 -0
- package/src/commands/config/add.mjs +97 -0
- package/src/commands/config/folder.mjs +42 -0
- package/src/commands/config/server.mjs +33 -0
- package/src/commands/config/set.mjs +103 -0
- package/src/commands/config/user.mjs +79 -0
- package/src/commands/contact/count.mjs +41 -0
- package/src/commands/contact/list.mjs +207 -0
- package/src/commands/org/add.mjs +75 -0
- package/src/commands/org/crm.mjs +88 -0
- package/src/commands/org/delete.mjs +48 -0
- package/src/commands/org/email.mjs +111 -0
- package/src/commands/org/get.mjs +152 -0
- package/src/commands/service/add.mjs +78 -0
- package/src/commands/service/list.mjs +24 -0
- package/src/commands/target/add.mjs +94 -0
- package/src/commands/template/add.mjs +97 -0
- package/src/commands/template/list.mjs +61 -0
- package/src/commands/user/get.mjs +91 -0
- package/src/commands/user/invite.mjs +56 -0
- package/src/commands/user/join.mjs +81 -0
- package/src/commands/user/leave.mjs +57 -0
- package/src/commands/user/list.mjs +80 -0
- package/src/commands/user/reset.mjs +83 -0
- package/src/commands/widget/add.mjs +116 -0
- package/src/commands/widget/delete.mjs +45 -0
- package/src/commands/widget/get.mjs +60 -0
- package/src/commands/widget/list.mjs +135 -0
- package/src/commands/widget/rebuild.mjs +64 -0
- package/src/commands/widget/update.mjs +174 -0
- package/src/config.mjs +49 -0
- package/src/generated/schema.json +10677 -0
- package/src/hooks/help.mjs +14 -0
- package/src/hooks/init.mjs +41 -0
- package/src/index.mjs +1 -0
- package/src/procaCommand.mjs +316 -0
- package/src/queries/campaign.mjs +35 -0
- package/src/queries/widget.mjs +25 -0
- package/src/urql.mjs +60 -0
- package/src/util/twitter.mjs +23 -0
- package/theme.json +29 -0
- package/bin/proca-cli +0 -4
- package/dist/browser.d.ts +0 -1
- package/dist/browser.js +0 -28
- package/dist/browser.js.map +0 -1
- package/dist/campaign.d.ts +0 -156
- package/dist/campaign.js +0 -192
- package/dist/campaign.js.map +0 -1
- package/dist/cli.d.ts +0 -40
- package/dist/cli.js +0 -416
- package/dist/cli.js.map +0 -1
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -18
- package/dist/client.js.map +0 -1
- package/dist/config.d.ts +0 -35
- package/dist/config.js +0 -71
- package/dist/config.js.map +0 -1
- package/dist/crypto.d.ts +0 -40
- package/dist/crypto.js +0 -53
- package/dist/crypto.js.map +0 -1
- package/dist/export.d.ts +0 -15
- package/dist/export.js +0 -145
- package/dist/export.js.map +0 -1
- package/dist/format.d.ts +0 -37
- package/dist/format.js +0 -200
- package/dist/format.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -39
- package/dist/index.js.map +0 -1
- package/dist/keys.d.ts +0 -4
- package/dist/keys.js +0 -38
- package/dist/keys.js.map +0 -1
- package/dist/org.d.ts +0 -11
- package/dist/org.js +0 -97
- package/dist/org.js.map +0 -1
- package/dist/proca.d.ts +0 -2095
- package/dist/proca.js +0 -398
- package/dist/proca.js.map +0 -1
- package/dist/queue.d.ts +0 -8
- package/dist/queue.js +0 -126
- package/dist/queue.js.map +0 -1
- package/dist/queueMessage.d.ts +0 -102
- package/dist/queueMessage.js +0 -109
- package/dist/queueMessage.js.map +0 -1
- package/dist/service/actionnetwork.d.ts +0 -10
- package/dist/service/actionnetwork.js +0 -302
- package/dist/service/actionnetwork.js.map +0 -1
- package/dist/service/distance.d.ts +0 -3
- package/dist/service/distance.js +0 -96
- package/dist/service/distance.js.map +0 -1
- package/dist/service/echo.d.ts +0 -4
- package/dist/service/echo.js +0 -19
- package/dist/service/echo.js.map +0 -1
- package/dist/service/email.d.ts +0 -14
- package/dist/service/email.js +0 -67
- package/dist/service/email.js.map +0 -1
- package/dist/service/identity.d.ts +0 -58
- package/dist/service/identity.js +0 -190
- package/dist/service/identity.js.map +0 -1
- package/dist/service/index.d.ts +0 -14
- package/dist/service/index.js +0 -61
- package/dist/service/index.js.map +0 -1
- package/dist/setup.d.ts +0 -2
- package/dist/setup.js +0 -291
- package/dist/setup.js.map +0 -1
- package/dist/util.d.ts +0 -5
- package/dist/util.js +0 -30
- package/dist/util.js.map +0 -1
- package/dist/watch.d.ts +0 -9
- package/dist/watch.js +0 -80
- package/dist/watch.js.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import { formatDistanceToNowStrict } from "date-fns";
|
|
4
|
+
import Command from "#src/procaCommand.mjs";
|
|
5
|
+
import {
|
|
6
|
+
FragmentOrg,
|
|
7
|
+
FragmentStats,
|
|
8
|
+
FragmentSummary,
|
|
9
|
+
} from "#src/queries/campaign.mjs";
|
|
10
|
+
import { gql, query } from "#src/urql.mjs";
|
|
11
|
+
|
|
12
|
+
export default class List extends Command {
|
|
13
|
+
actionTypes = new Set();
|
|
14
|
+
|
|
15
|
+
static args = {
|
|
16
|
+
title: Args.string({ description: "name of the campaign, % for wildchar" }),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
static examples = ["<%= config.bin %> <%= command.id %> %pizza%"];
|
|
20
|
+
|
|
21
|
+
static flags = {
|
|
22
|
+
// flag with no value (-f, --force)
|
|
23
|
+
...super.globalFlags,
|
|
24
|
+
org: Flags.string({
|
|
25
|
+
char: "o",
|
|
26
|
+
description: "campaigns of the organisation (coordinator or partner)",
|
|
27
|
+
required: true,
|
|
28
|
+
// exactlyOne: ["org", "title"],
|
|
29
|
+
helpValue: "<organisation name>",
|
|
30
|
+
}),
|
|
31
|
+
campaign: Flags.string({
|
|
32
|
+
char: "c",
|
|
33
|
+
description: "name of the campaign, % for wildchar",
|
|
34
|
+
helpValue: "<campaign title>",
|
|
35
|
+
}),
|
|
36
|
+
limit: Flags.string({
|
|
37
|
+
char: "n",
|
|
38
|
+
description: "max number of actions",
|
|
39
|
+
parse: (input) => Number.parseInt(input, 10),
|
|
40
|
+
}),
|
|
41
|
+
after: Flags.string({
|
|
42
|
+
description: "only actions after a date",
|
|
43
|
+
helpValue: "2025-04-09",
|
|
44
|
+
parse: (input) => new Date(input).toISOString(),
|
|
45
|
+
}),
|
|
46
|
+
today: Flags.boolean({
|
|
47
|
+
description: "only actions today",
|
|
48
|
+
exclusive: ["after"],
|
|
49
|
+
parse: (input) => `${new Date().toISOString().split("T")[0]}T00:00:00Z`,
|
|
50
|
+
}),
|
|
51
|
+
optin: Flags.boolean({
|
|
52
|
+
description: "only export the optin actions",
|
|
53
|
+
default: false,
|
|
54
|
+
}),
|
|
55
|
+
testing: Flags.boolean({
|
|
56
|
+
description: "also export the test actions",
|
|
57
|
+
default: false,
|
|
58
|
+
}),
|
|
59
|
+
doi: Flags.boolean({
|
|
60
|
+
description: "only export the double optin actions",
|
|
61
|
+
default: false,
|
|
62
|
+
}),
|
|
63
|
+
utm: Flags.boolean({
|
|
64
|
+
description: "display the utm tracking parameters",
|
|
65
|
+
default: true,
|
|
66
|
+
allowNo: true,
|
|
67
|
+
exclusive: ["simplify"],
|
|
68
|
+
}),
|
|
69
|
+
comment: Flags.boolean({
|
|
70
|
+
description: "display the comment",
|
|
71
|
+
default: true,
|
|
72
|
+
allowNo: true,
|
|
73
|
+
exclusive: ["simplify"],
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
fetch = async (flags) => {
|
|
78
|
+
const Document = gql`
|
|
79
|
+
query (
|
|
80
|
+
$after: DateTime
|
|
81
|
+
$campaignId: Int
|
|
82
|
+
$campaignName: String
|
|
83
|
+
$includeTesting: Boolean
|
|
84
|
+
$limit: Int
|
|
85
|
+
$onlyDoubleOptIn: Boolean
|
|
86
|
+
$onlyOptIn: Boolean
|
|
87
|
+
$orgName: String!
|
|
88
|
+
$start: Int
|
|
89
|
+
) {
|
|
90
|
+
contacts(
|
|
91
|
+
after: $after
|
|
92
|
+
campaignId: $campaignId
|
|
93
|
+
campaignName: $campaignName
|
|
94
|
+
includeTesting: $includeTesting
|
|
95
|
+
limit: $limit
|
|
96
|
+
onlyDoubleOptIn: $onlyDoubleOptIn
|
|
97
|
+
onlyOptIn: $onlyOptIn
|
|
98
|
+
orgName: $orgName
|
|
99
|
+
start: $start
|
|
100
|
+
) {
|
|
101
|
+
actionId
|
|
102
|
+
actionPage {
|
|
103
|
+
id
|
|
104
|
+
locale
|
|
105
|
+
name
|
|
106
|
+
}
|
|
107
|
+
actionType
|
|
108
|
+
campaign {
|
|
109
|
+
name
|
|
110
|
+
}
|
|
111
|
+
contact {
|
|
112
|
+
contactRef
|
|
113
|
+
payload
|
|
114
|
+
nonce
|
|
115
|
+
publicKey {
|
|
116
|
+
public
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
createdAt
|
|
120
|
+
customFields
|
|
121
|
+
privacy {
|
|
122
|
+
emailStatus
|
|
123
|
+
emailStatusChanged
|
|
124
|
+
givenAt
|
|
125
|
+
optIn
|
|
126
|
+
withConsent
|
|
127
|
+
}
|
|
128
|
+
tracking {
|
|
129
|
+
campaign
|
|
130
|
+
content
|
|
131
|
+
medium
|
|
132
|
+
source
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
const result = await query(Document, {
|
|
138
|
+
after: flags.after,
|
|
139
|
+
// "campaignId": 42,
|
|
140
|
+
campaignName: flags.campaign,
|
|
141
|
+
includeTesting: flags.testing,
|
|
142
|
+
limit: flags.limit,
|
|
143
|
+
onlyDoubleOptIn: flags.doi,
|
|
144
|
+
onlyOptIn: flags.optin,
|
|
145
|
+
orgName: flags.org,
|
|
146
|
+
start: flags.start,
|
|
147
|
+
});
|
|
148
|
+
return result.contacts.map((d) => {
|
|
149
|
+
d.customFields = JSON.parse(d.customFields);
|
|
150
|
+
if (!d.contact.publicKey) {
|
|
151
|
+
const ref = d.contactRef;
|
|
152
|
+
d.contact = JSON.parse(d.contact.payload);
|
|
153
|
+
d.contact.contactRef = ref;
|
|
154
|
+
} else {
|
|
155
|
+
this.error(
|
|
156
|
+
`encrypted contact we need the private key for ${d.contact.publicKey.public}`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return d;
|
|
160
|
+
});
|
|
161
|
+
// return result.exportActions;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
simplify = (d) => {
|
|
165
|
+
const result = {
|
|
166
|
+
id: d.actionId,
|
|
167
|
+
firstname: d.contact.firstName,
|
|
168
|
+
country: d.contact.country,
|
|
169
|
+
email: d.contact.email,
|
|
170
|
+
type: d.actionType,
|
|
171
|
+
date: formatDistanceToNowStrict(d.createdAt),
|
|
172
|
+
campaign: !this.flags.campaign && d.campaign.name,
|
|
173
|
+
widget_id: d.actionPage.id,
|
|
174
|
+
widget: d.actionPage.name,
|
|
175
|
+
// customFields
|
|
176
|
+
};
|
|
177
|
+
if (this.flags.comment && d.customFields?.comment)
|
|
178
|
+
result.comment = d.customFields.comment;
|
|
179
|
+
if (this.flags.utm && d.tracking) {
|
|
180
|
+
result.utm_medium =
|
|
181
|
+
d.tracking.medium === "unknown" ? undefined : d.tracking.medium;
|
|
182
|
+
result.utm_source =
|
|
183
|
+
d.tracking.source === "unknown" ? undefined : d.tracking.source;
|
|
184
|
+
result.utm_campaign =
|
|
185
|
+
d.tracking.campaign === "unknown" ? undefined : d.tracking.campaign;
|
|
186
|
+
if (d.tracking.content)
|
|
187
|
+
result.utm_content =
|
|
188
|
+
d.tracking.content === "unknown" ? undefined : d.tracking.content;
|
|
189
|
+
}
|
|
190
|
+
if (d.customFields?.emailProvider)
|
|
191
|
+
result.provider = d.customFields.emailProvider;
|
|
192
|
+
return result;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
_table = (r) => {
|
|
196
|
+
super.table(r, null, (table) => table.sort(["id|des"]).toString());
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
async run() {
|
|
200
|
+
const { args, flags } = await this.parse();
|
|
201
|
+
if (flags.today) flags.after = flags.today;
|
|
202
|
+
let data = [];
|
|
203
|
+
|
|
204
|
+
data = await this.fetch(flags);
|
|
205
|
+
return this.output(data);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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, mutation } from "#src/urql.mjs";
|
|
5
|
+
import { getTwitter } from "#src/util/twitter.mjs";
|
|
6
|
+
|
|
7
|
+
export default class OrgAdd extends Command {
|
|
8
|
+
static args = {};
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
"<%= config.bin %> <%= command.id %> --name <twitter of the organisation> --title='this is an organisation'",
|
|
12
|
+
"<%= config.bin %> <%= command.id %> --twitter <twitter of the organisation>",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
static flags = {
|
|
16
|
+
...super.globalFlags,
|
|
17
|
+
twitter: Flags.string({
|
|
18
|
+
description: "twitter account",
|
|
19
|
+
helpValue: "<screen name>",
|
|
20
|
+
}),
|
|
21
|
+
name: Flags.string({
|
|
22
|
+
char: "n",
|
|
23
|
+
description: "short name of the org",
|
|
24
|
+
helpValue: "<org acronym/name>",
|
|
25
|
+
}),
|
|
26
|
+
title: Flags.string({
|
|
27
|
+
char: "t",
|
|
28
|
+
description: "title/full name of the org",
|
|
29
|
+
helpValue: "<org full name>",
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
create = async (_org) => {
|
|
34
|
+
const org = { ..._org, config: JSON.stringify(_org.config) };
|
|
35
|
+
console.log(org);
|
|
36
|
+
|
|
37
|
+
const AddOrgDocument = gql`
|
|
38
|
+
mutation ($org: OrgInput!) {
|
|
39
|
+
addOrg(input: $org) {
|
|
40
|
+
config
|
|
41
|
+
name
|
|
42
|
+
title
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
const result = await mutation(AddOrgDocument, {
|
|
47
|
+
org,
|
|
48
|
+
});
|
|
49
|
+
if (!result.addOrg) {
|
|
50
|
+
console.log(result);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
return result?.addOrg;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
async run() {
|
|
57
|
+
const { args, flags } = await this.parse();
|
|
58
|
+
if (!flags.name && !flags.twitter) {
|
|
59
|
+
this.error("You must provide either --name or --twitter");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const org = {
|
|
63
|
+
name: flags.twitter || flags.name,
|
|
64
|
+
title: flags.title || flags.name,
|
|
65
|
+
config: {},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (flags.twitter) {
|
|
69
|
+
await getTwitter(org);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const data = await this.create(org);
|
|
73
|
+
return this.output(data);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 {FragmentSummary,} from "#src/queries/org.mjs";
|
|
5
|
+
import { gql, mutation, query } from "#src/urql.mjs";
|
|
6
|
+
|
|
7
|
+
export default class OrgCRM extends Command {
|
|
8
|
+
static description = "view a org crm synchroniser";
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
// flag with no value (-f, --force)
|
|
12
|
+
...super.globalFlags,
|
|
13
|
+
name: Flags.string({
|
|
14
|
+
char: "n",
|
|
15
|
+
charAliases: ["o"],
|
|
16
|
+
required: true,
|
|
17
|
+
description: "name of the org",
|
|
18
|
+
helpValue: "<org name>",
|
|
19
|
+
}),
|
|
20
|
+
synchronize: Flags.boolean({
|
|
21
|
+
// default: undefined,
|
|
22
|
+
aliases: ["deliver", "enable"],
|
|
23
|
+
description: "enable or disable the synchronisation queue",
|
|
24
|
+
allowNo: true,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
fetch = async (params) => {
|
|
29
|
+
const GetOrgDocument = gql`
|
|
30
|
+
query GetOrg($name: String!) {
|
|
31
|
+
org (name: $name) {
|
|
32
|
+
id name title
|
|
33
|
+
processing { customActionDeliver }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const result = await query(GetOrgDocument, {
|
|
38
|
+
name: params.name,
|
|
39
|
+
});
|
|
40
|
+
return result.org;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
mutate = async (name, deliver) => {
|
|
44
|
+
const Document = gql`
|
|
45
|
+
mutation ($name: String!, $deliver: Boolean!) {
|
|
46
|
+
updateOrgProcessing (name: $name,customActionDeliver: $deliver) {
|
|
47
|
+
id, name, title, processing {customActionDeliver}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
console.log("deliver", deliver);
|
|
52
|
+
const result = await mutation(Document, {
|
|
53
|
+
name: name,
|
|
54
|
+
deliver: deliver,
|
|
55
|
+
});
|
|
56
|
+
console.log("deliver", deliver);
|
|
57
|
+
return result.updateOrgProcessing;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
simplify = (d) => {
|
|
61
|
+
const result = {
|
|
62
|
+
id: d.id,
|
|
63
|
+
name: d.name,
|
|
64
|
+
title: d.title,
|
|
65
|
+
deliver: d.processing.customActionDeliver,
|
|
66
|
+
queue: d.processing.customActionDeliver
|
|
67
|
+
? `cus.${d.id}.deliver`
|
|
68
|
+
: "call with --synchronize to enable",
|
|
69
|
+
};
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
table = (r) => {
|
|
74
|
+
super.table(r, null, null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
async run() {
|
|
78
|
+
const { args, flags } = await this.parse();
|
|
79
|
+
if (typeof flags.synchronize === "boolean") {
|
|
80
|
+
const data = await this.mutate(flags.name, flags.synchronize);
|
|
81
|
+
return this.output(data);
|
|
82
|
+
}
|
|
83
|
+
const data = await this.fetch(flags);
|
|
84
|
+
if (!data.processing.customActionDeliver)
|
|
85
|
+
this.info("actions aren't delivered, call with --synchronize to enable");
|
|
86
|
+
return this.output(data);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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, mutation } from "#src/urql.mjs";
|
|
5
|
+
|
|
6
|
+
export default class OrgDelete extends Command {
|
|
7
|
+
static examples = [
|
|
8
|
+
"<%= config.bin %> <%= command.id %> <organisation_name>",
|
|
9
|
+
];
|
|
10
|
+
static args = this.multiid();
|
|
11
|
+
|
|
12
|
+
static flags = {
|
|
13
|
+
// flag with no value (-f, --force)
|
|
14
|
+
...this.flagify({ multiid: true }),
|
|
15
|
+
name: Flags.string({
|
|
16
|
+
char: "n",
|
|
17
|
+
description: "name of the org",
|
|
18
|
+
helpValue: "<org name>",
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
delete = async (org) => {
|
|
23
|
+
console.log(org);
|
|
24
|
+
|
|
25
|
+
const DeleteOrgDocument = gql`
|
|
26
|
+
mutation ($org: String!) {
|
|
27
|
+
deleteOrg(name: $org)
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const result = await mutation(DeleteOrgDocument, {
|
|
32
|
+
org,
|
|
33
|
+
});
|
|
34
|
+
console.log(result);
|
|
35
|
+
if (!result.deleteOrg) {
|
|
36
|
+
console.log(result);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
return result?.deleteOrg;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
async run() {
|
|
43
|
+
const { args, flags } = await this.parse();
|
|
44
|
+
|
|
45
|
+
const data = await this.delete(flags.name);
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import Command from "#src/procaCommand.mjs";
|
|
3
|
+
import { gql, mutation } from "#src/urql.mjs";
|
|
4
|
+
|
|
5
|
+
const SERVICE_NAMES = [
|
|
6
|
+
"MAILJET",
|
|
7
|
+
"SES",
|
|
8
|
+
"STRIPE",
|
|
9
|
+
"TEST_STRIPE",
|
|
10
|
+
"SYSTEM",
|
|
11
|
+
"PREVIEW",
|
|
12
|
+
"WEBHOOK",
|
|
13
|
+
"SUPABASE",
|
|
14
|
+
"SMTP",
|
|
15
|
+
].map((d) => d.toLowerCase());
|
|
16
|
+
|
|
17
|
+
export default class OrgEmail extends Command {
|
|
18
|
+
static description =
|
|
19
|
+
"Set email service and supporter confirmation for an org";
|
|
20
|
+
|
|
21
|
+
static args = this.multiid();
|
|
22
|
+
|
|
23
|
+
static flags = {
|
|
24
|
+
...this.flagify({ multiid: true }),
|
|
25
|
+
mailer: Flags.string({
|
|
26
|
+
description: "service to send emails",
|
|
27
|
+
options: SERVICE_NAMES,
|
|
28
|
+
helpValue: SERVICE_NAMES,
|
|
29
|
+
default: "system",
|
|
30
|
+
}),
|
|
31
|
+
from: Flags.string({
|
|
32
|
+
description: "Email address to send from",
|
|
33
|
+
helpValue: "default <org>@proca.app",
|
|
34
|
+
}),
|
|
35
|
+
"supporter-confirm": Flags.boolean({
|
|
36
|
+
description: "enable/disable action confirmation emails",
|
|
37
|
+
allowNo: true,
|
|
38
|
+
}),
|
|
39
|
+
"supporter-confirm-template": Flags.string({
|
|
40
|
+
description: "add confirmation template",
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
async mutate(flags) {
|
|
45
|
+
flags.from = flags.from || `${flags.org}@proca.app`;
|
|
46
|
+
|
|
47
|
+
const Document = gql`
|
|
48
|
+
mutation UpdateOrgProcessing(
|
|
49
|
+
$name: String!
|
|
50
|
+
$emailBackend: ServiceName!
|
|
51
|
+
$emailFrom: String!
|
|
52
|
+
$supporterConfirm: Boolean
|
|
53
|
+
$supporterConfirmTemplate: String
|
|
54
|
+
) {
|
|
55
|
+
updateOrgProcessing(
|
|
56
|
+
name: $name
|
|
57
|
+
emailBackend: $emailBackend
|
|
58
|
+
emailFrom: $emailFrom
|
|
59
|
+
supporterConfirm: $supporterConfirm
|
|
60
|
+
supporterConfirmTemplate: $supporterConfirmTemplate
|
|
61
|
+
) {
|
|
62
|
+
id
|
|
63
|
+
name
|
|
64
|
+
processing {
|
|
65
|
+
emailBackend
|
|
66
|
+
emailFrom
|
|
67
|
+
supporterConfirm
|
|
68
|
+
supporterConfirmTemplate
|
|
69
|
+
}
|
|
70
|
+
personalData {
|
|
71
|
+
supporterConfirm
|
|
72
|
+
supporterConfirmTemplate
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
const variables = {
|
|
79
|
+
name: flags.name,
|
|
80
|
+
emailBackend: flags.mailer.toUpperCase(),
|
|
81
|
+
emailFrom: flags.from,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (flags["supporter-confirm"] !== undefined) {
|
|
85
|
+
variables.supporterConfirm = flags["supporter-confirm"];
|
|
86
|
+
console.log("supporter-confirm", variables.supporterConfirm);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (flags["supporter-confirm-template"]) {
|
|
90
|
+
variables.supporterConfirmTemplate = flags["supporter-confirm-template"];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const result = await mutation(Document, variables);
|
|
94
|
+
return result.updateOrgProcessing;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
simplify = (d) => ({
|
|
98
|
+
id: d.id,
|
|
99
|
+
name: d.name,
|
|
100
|
+
mailer: d.processing.emailBackend,
|
|
101
|
+
from: d.processing.emailFrom,
|
|
102
|
+
supporterConfirm: d.personalData?.supporterConfirm,
|
|
103
|
+
supporterConfirmTemplate: d.personalData?.supporterConfirmTemplate,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
async run() {
|
|
107
|
+
const { flags } = await this.parse();
|
|
108
|
+
const result = await this.mutate(flags);
|
|
109
|
+
this.output(result);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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 {FragmentSummary,} from "#src/queries/org.mjs";
|
|
5
|
+
import { gql, query } from "#src/urql.mjs";
|
|
6
|
+
|
|
7
|
+
export const getOrg = (params) => {
|
|
8
|
+
const d = new OrgGet([]);
|
|
9
|
+
return d.fetch(params);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default class OrgGet extends Command {
|
|
13
|
+
static description = "view a org";
|
|
14
|
+
|
|
15
|
+
static examples = ["<%= config.bin %> <%= command.id %> <name of the ngo>"];
|
|
16
|
+
|
|
17
|
+
static args = this.multiid();
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
// flag with no value (-f, --force)
|
|
21
|
+
...this.flagify({ multiid: false }),
|
|
22
|
+
name: Flags.string({
|
|
23
|
+
char: "n",
|
|
24
|
+
charAliases: ["o"],
|
|
25
|
+
description: "name of the org",
|
|
26
|
+
helpValue: "<org name>",
|
|
27
|
+
}),
|
|
28
|
+
config: Flags.boolean({
|
|
29
|
+
description: "display the config",
|
|
30
|
+
default: false,
|
|
31
|
+
allowNo: true,
|
|
32
|
+
}),
|
|
33
|
+
personaldata: Flags.boolean({
|
|
34
|
+
description: "how are the personal data of the supporter processed",
|
|
35
|
+
default: true,
|
|
36
|
+
allowNo: true,
|
|
37
|
+
}),
|
|
38
|
+
processing: Flags.boolean({
|
|
39
|
+
description: "additional processing workflows on the actions",
|
|
40
|
+
default: true,
|
|
41
|
+
allowNo: true,
|
|
42
|
+
}),
|
|
43
|
+
keys: Flags.boolean({
|
|
44
|
+
default: true,
|
|
45
|
+
allowNo: true,
|
|
46
|
+
}),
|
|
47
|
+
campaigns: Flags.boolean({
|
|
48
|
+
default: false,
|
|
49
|
+
allowNo: true,
|
|
50
|
+
}),
|
|
51
|
+
users: Flags.boolean({
|
|
52
|
+
default: true,
|
|
53
|
+
allowNo: true,
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
fetch = async (params) => {
|
|
58
|
+
const GetOrgDocument = gql`
|
|
59
|
+
query GetOrg($name: String!, $withCampaigns: Boolean = true, $withKeys: Boolean = true, $withPersonalData: Boolean = false, $withProcessing: Boolean= false ) {
|
|
60
|
+
org (name: $name) {
|
|
61
|
+
id name title
|
|
62
|
+
config
|
|
63
|
+
keys @include(if: $withKeys) {id, name, expired, expiredAt, public}
|
|
64
|
+
|
|
65
|
+
campaigns @include(if: $withCampaigns) {id, name, title, org {name}}
|
|
66
|
+
personalData @include(if: $withPersonalData) {
|
|
67
|
+
contactSchema
|
|
68
|
+
doiThankYou
|
|
69
|
+
highSecurity
|
|
70
|
+
replyEnabled
|
|
71
|
+
supporterConfirm
|
|
72
|
+
supporterConfirmTemplate
|
|
73
|
+
}
|
|
74
|
+
processing @include(if: $withProcessing) {
|
|
75
|
+
customActionConfirm
|
|
76
|
+
customActionDeliver
|
|
77
|
+
customEventDeliver
|
|
78
|
+
customSupporterConfirm
|
|
79
|
+
detailBackend
|
|
80
|
+
doiThankYou
|
|
81
|
+
emailBackend
|
|
82
|
+
emailFrom
|
|
83
|
+
emailTemplates
|
|
84
|
+
eventBackend
|
|
85
|
+
pushBackend
|
|
86
|
+
storageBackend
|
|
87
|
+
supporterConfirm
|
|
88
|
+
supporterConfirmTemplate
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
services {
|
|
92
|
+
host
|
|
93
|
+
id
|
|
94
|
+
name
|
|
95
|
+
path
|
|
96
|
+
user
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
const result = await query(GetOrgDocument, {
|
|
103
|
+
name: params.name,
|
|
104
|
+
withCampaigns: params.campaigns,
|
|
105
|
+
withKeys: params.keys || true,
|
|
106
|
+
withPersonalData: params.personaldata,
|
|
107
|
+
$withProcessing: params.processing,
|
|
108
|
+
});
|
|
109
|
+
result.org.config = JSON.parse(result.org.config);
|
|
110
|
+
return result.org;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
simplify = (d) => {
|
|
114
|
+
const result = {
|
|
115
|
+
id: d.id,
|
|
116
|
+
Name: d.name,
|
|
117
|
+
Title: d.title,
|
|
118
|
+
"can targets reply?": d.replyEnabled ? true : undefined,
|
|
119
|
+
"confirm actions?": d.supporterConfirm
|
|
120
|
+
? d.supporterConfirmTemplate
|
|
121
|
+
: undefined,
|
|
122
|
+
};
|
|
123
|
+
if (this.flags.stats) {
|
|
124
|
+
result["#Supporters"] = d.stats.supporterCount;
|
|
125
|
+
|
|
126
|
+
this.actionTypes.forEach((type) => {
|
|
127
|
+
const action = d.stats.actionCount.find(
|
|
128
|
+
(action) => action.actionType === type,
|
|
129
|
+
);
|
|
130
|
+
if (action) result[`#${type}`] = action.count;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
table = (r) => {
|
|
137
|
+
super.table(r, null, null);
|
|
138
|
+
if (this.flags.config) {
|
|
139
|
+
r.config.locales = undefined;
|
|
140
|
+
this.prettyJson(r.config);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
async run() {
|
|
145
|
+
console.log("starting");
|
|
146
|
+
const { flags } = await this.parse();
|
|
147
|
+
console.log("flags", this.Flags);
|
|
148
|
+
|
|
149
|
+
const data = await this.fetch(flags);
|
|
150
|
+
return this.output(data);
|
|
151
|
+
}
|
|
152
|
+
}
|