proca 1.7.8 → 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 +469 -134
- package/package.json +5 -3
- 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/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 +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 +22 -23
- 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 +10 -5
- 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/list.mjs +2 -2
- 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 +34 -33
- package/src/commands/widget/list.mjs +93 -80
- package/src/commands/widget/rebuild.mjs +64 -0
- 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
|
@@ -4,19 +4,19 @@ import Command from "#src/procaCommand.mjs";
|
|
|
4
4
|
import { gql, mutation, query } from "#src/urql.mjs";
|
|
5
5
|
|
|
6
6
|
export default class OrgTemplate extends Command {
|
|
7
|
-
|
|
7
|
+
static description = "list services set for an organisation";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
static flags = {
|
|
10
|
+
...super.globalFlags,
|
|
11
|
+
org: Flags.string({
|
|
12
|
+
char: "o",
|
|
13
|
+
description: "organisation having the templates",
|
|
14
|
+
required: true,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
fetch = async (org) => {
|
|
19
|
+
const GetOrgDocument = gql`
|
|
20
20
|
query GetOrg($name: String!) {
|
|
21
21
|
org (name: $name) {
|
|
22
22
|
id name title
|
|
@@ -35,27 +35,27 @@ export default class OrgTemplate extends Command {
|
|
|
35
35
|
}
|
|
36
36
|
`;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
const result = await query(GetOrgDocument, {
|
|
39
|
+
name: org,
|
|
40
|
+
});
|
|
41
|
+
const supporterConfirm = (tplName) => {
|
|
42
|
+
if (
|
|
43
|
+
tplName.split("@")[0] === result.org.processing.supporterConfirmTemplate
|
|
44
|
+
) {
|
|
45
|
+
return result.org.processing.supporterConfirm ? "enabled" : "disabled";
|
|
46
|
+
}
|
|
47
|
+
return "";
|
|
48
|
+
};
|
|
49
|
+
const tpl = result.org.processing?.emailTemplates?.map((d) => ({
|
|
50
|
+
name: d,
|
|
51
|
+
actionConfirm: supporterConfirm(d),
|
|
52
|
+
}));
|
|
53
|
+
return tpl;
|
|
54
|
+
};
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
async run() {
|
|
57
|
+
const { flags } = await this.parse();
|
|
58
|
+
const tpl = await this.fetch(flags.org);
|
|
59
|
+
this.output(tpl);
|
|
60
|
+
}
|
|
61
61
|
}
|
|
@@ -4,30 +4,30 @@ import Command from "#src/procaCommand.mjs";
|
|
|
4
4
|
import { gql, query } from "#src/urql.mjs";
|
|
5
5
|
|
|
6
6
|
export default class UserList extends Command {
|
|
7
|
-
|
|
7
|
+
static description = "fetch the information about a user";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
static flags = {
|
|
12
|
+
...super.globalFlags,
|
|
13
|
+
email: Flags.string({ description: "user email" }),
|
|
14
|
+
org: Flags.string({
|
|
15
|
+
char: "o",
|
|
16
|
+
description: "name of the org",
|
|
17
|
+
exactlyOne: ["email", "id", "org"],
|
|
18
|
+
helpValue: "<org name>",
|
|
19
|
+
}),
|
|
20
|
+
id: Flags.string({
|
|
21
|
+
char: "i",
|
|
22
|
+
parse: (input) => {
|
|
23
|
+
return Number.parseInt(input, 10);
|
|
24
|
+
},
|
|
25
|
+
description: "id of the user",
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
fetch = async (params) => {
|
|
30
|
+
const Document = gql`
|
|
31
31
|
query ($email: String, $org: String, $id: Int) {
|
|
32
32
|
users (select: {email: $email, orgName: $org, id: $id}) {
|
|
33
33
|
apiToken {
|
|
@@ -45,47 +45,47 @@ query ($email: String, $org: String, $id: Int) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
const result = await query(Document, {
|
|
49
|
+
org: params.org,
|
|
50
|
+
id: params.id,
|
|
51
|
+
email: params.email,
|
|
52
|
+
});
|
|
53
|
+
return result.users[0];
|
|
54
|
+
};
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
simplify = (d) => {
|
|
57
|
+
const result = {
|
|
58
|
+
id: d.id,
|
|
59
|
+
email: d.email,
|
|
60
|
+
};
|
|
61
|
+
if (d.apiToken) {
|
|
62
|
+
result.tokenExpire = d.apiToken.expire;
|
|
63
|
+
}
|
|
64
|
+
if (d.isAdmin) {
|
|
65
|
+
result.admin = true;
|
|
66
|
+
}
|
|
67
|
+
const roles = d.roles.reduce((acc, item) => {
|
|
68
|
+
if (!acc[item.role]) {
|
|
69
|
+
acc[item.role] = [];
|
|
70
|
+
}
|
|
71
|
+
acc[item.role].push(item.org.name);
|
|
72
|
+
return acc;
|
|
73
|
+
}, {});
|
|
74
|
+
for (const role in roles) {
|
|
75
|
+
result[role] = roles[role].join(",");
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
};
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
table = (r) => {
|
|
81
|
+
super.table(r, null, null);
|
|
82
|
+
};
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
async run() {
|
|
85
|
+
const { args, flags } = await this.parse();
|
|
86
|
+
let data = [];
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
data = await this.fetch(flags);
|
|
89
|
+
return this.output(data);
|
|
90
|
+
}
|
|
91
91
|
}
|
|
@@ -4,33 +4,33 @@ import Command from "#src/procaCommand.mjs";
|
|
|
4
4
|
import { gql, mutation } from "#src/urql.mjs";
|
|
5
5
|
|
|
6
6
|
export default class UserInviteOrg extends Command {
|
|
7
|
-
|
|
7
|
+
static description = "invite a user to join an organisation with a role";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
static flags = {
|
|
12
|
+
...super.globalFlags,
|
|
13
|
+
role: Flags.string({
|
|
14
|
+
description: "permission level in that org",
|
|
15
|
+
default: "campaigner",
|
|
16
|
+
options: ["owner", "campaigner", "coordinator", "translator"],
|
|
17
|
+
}),
|
|
18
|
+
org: Flags.string({
|
|
19
|
+
char: "o",
|
|
20
|
+
required: true,
|
|
21
|
+
description: "name of the org",
|
|
22
|
+
helpValue: "<org name>",
|
|
23
|
+
}),
|
|
24
|
+
user: Flags.string({
|
|
25
|
+
char: "u",
|
|
26
|
+
required: true,
|
|
27
|
+
description: "email",
|
|
28
|
+
helpValue: "<user email>",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
invite = async (params) => {
|
|
33
|
+
const Document = gql`
|
|
34
34
|
mutation ($user: String!, $role: String!, $org: String!, $message: String) {
|
|
35
35
|
inviteOrgUser(orgName: $org, message: $message, input: { email: $user, role: $role}) {
|
|
36
36
|
objectId
|
|
@@ -38,19 +38,19 @@ mutation ($user: String!, $role: String!, $org: String!, $message: String) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
`;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const result = await mutation(Document, params);
|
|
42
|
+
//return result.users.map (d => {d.config = JSON.parse(d.config); return d});
|
|
43
|
+
console.log(result);
|
|
44
|
+
return result.inviteOrgUser;
|
|
45
|
+
};
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
table = (r) => {
|
|
48
|
+
super.table(r, null, null);
|
|
49
|
+
};
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
async run() {
|
|
52
|
+
const { args, flags } = await this.parse();
|
|
53
|
+
const data = await this.invite(flags);
|
|
54
|
+
this.output(data);
|
|
55
|
+
}
|
|
56
56
|
}
|
|
@@ -4,32 +4,32 @@ import Command from "#src/procaCommand.mjs";
|
|
|
4
4
|
import { gql, mutation } from "#src/urql.mjs";
|
|
5
5
|
|
|
6
6
|
export default class UserJoinOrg extends Command {
|
|
7
|
-
|
|
7
|
+
static description = "let a user join an organisation with a role";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
static flags = {
|
|
12
|
+
...super.globalFlags,
|
|
13
|
+
role: Flags.string({
|
|
14
|
+
description: "permission level in that org",
|
|
15
|
+
default: "campaigner",
|
|
16
|
+
options: ["owner", "campaigner", "coordinator", "translator"],
|
|
17
|
+
}),
|
|
18
|
+
org: Flags.string({
|
|
19
|
+
char: "o",
|
|
20
|
+
required: true,
|
|
21
|
+
description: "name of the org",
|
|
22
|
+
helpValue: "<org name>",
|
|
23
|
+
}),
|
|
24
|
+
user: Flags.string({
|
|
25
|
+
char: "u",
|
|
26
|
+
description: "email",
|
|
27
|
+
helpValue: "<user email>",
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
join = async (org) => {
|
|
32
|
+
const Document = gql`
|
|
33
33
|
mutation ($name: String!) {
|
|
34
34
|
joinOrg(name: $name) {
|
|
35
35
|
org {
|
|
@@ -41,41 +41,41 @@ mutation ($name: String!) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
`;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const result = await mutation(Document, {
|
|
45
|
+
name: org,
|
|
46
|
+
});
|
|
47
|
+
//return result.users.map (d => {d.config = JSON.parse(d.config); return d});
|
|
48
|
+
return { ...result.joinOrg.org, status: result.joinOrg.status };
|
|
49
|
+
};
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
mutate = async (params) => {
|
|
52
|
+
const Document = gql`
|
|
53
53
|
mutation ($org: String!, $user: String!, $role: String = "campaigner") {
|
|
54
54
|
addOrgUser (orgName: $org, input : { email: $user, role: $role }) {
|
|
55
55
|
status
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
`;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
const result = await mutation(Document, {
|
|
60
|
+
user: params.user,
|
|
61
|
+
org: params.org,
|
|
62
|
+
role: params.role,
|
|
63
|
+
});
|
|
64
|
+
return result.addOrgUser;
|
|
65
|
+
};
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
table = (r) => {
|
|
68
|
+
super.table(r, null, null);
|
|
69
|
+
};
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
async run() {
|
|
72
|
+
const { args, flags } = await this.parse();
|
|
73
|
+
let data = undefined;
|
|
74
|
+
if (!flags.user) {
|
|
75
|
+
data = await this.join(flags.org);
|
|
76
|
+
} else {
|
|
77
|
+
data = await this.mutate(flags);
|
|
78
|
+
}
|
|
79
|
+
this.output(data);
|
|
80
|
+
}
|
|
81
81
|
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
-
import getCurrentUser from "#src/commands/config/user.mjs";
|
|
3
|
+
import { getCurrentUser } from "#src/commands/config/user.mjs";
|
|
4
4
|
import Command from "#src/procaCommand.mjs";
|
|
5
5
|
import { gql, mutation } from "#src/urql.mjs";
|
|
6
6
|
|
|
7
7
|
export default class OrgLeave extends Command {
|
|
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
|
-
|
|
8
|
+
actionTypes = new Set();
|
|
9
|
+
|
|
10
|
+
static args = {};
|
|
11
|
+
|
|
12
|
+
static description = "leave a org";
|
|
13
|
+
|
|
14
|
+
static examples = ["<%= config.bin %> <%= command.id %> -i 42"];
|
|
15
|
+
|
|
16
|
+
static flags = {
|
|
17
|
+
// flag with no value (-f, --force)
|
|
18
|
+
...super.globalFlags,
|
|
19
|
+
user: Flags.string({
|
|
20
|
+
char: "u",
|
|
21
|
+
description: "email",
|
|
22
|
+
helpValue: "<user email>",
|
|
23
|
+
}),
|
|
24
|
+
org: Flags.string({
|
|
25
|
+
char: "o",
|
|
26
|
+
description: "name of the org",
|
|
27
|
+
required: true,
|
|
28
|
+
helpValue: "<org name>",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
mutate = async ({ user, org }) => {
|
|
33
|
+
const Document = gql`
|
|
34
34
|
mutation ($email: String!, $org: String!) {
|
|
35
35
|
deleteOrgUser(email: $email, orgName: $org) { status }
|
|
36
36
|
}`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
const result = await mutation(Document, {
|
|
38
|
+
email: user,
|
|
39
|
+
org: org,
|
|
40
|
+
});
|
|
41
|
+
return result.deleteOrgUser;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
table = (r) => {
|
|
45
|
+
super.table(r, null, null);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
async run() {
|
|
49
|
+
const { args, flags } = await this.parse();
|
|
50
|
+
if (!flags.user) {
|
|
51
|
+
const me = await getCurrentUser();
|
|
52
|
+
flags.user = me.email;
|
|
53
|
+
}
|
|
54
|
+
const data = await this.mutate(flags);
|
|
55
|
+
this.output(data);
|
|
56
|
+
}
|
|
57
57
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { error, stdout, ux } from "@oclif/core/ux";
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
3
2
|
import Command from "#src/procaCommand.mjs";
|
|
4
3
|
import { gql, query } from "#src/urql.mjs";
|
|
5
4
|
|
|
@@ -9,6 +8,7 @@ export default class UserList extends Command {
|
|
|
9
8
|
static description = "list all the users";
|
|
10
9
|
|
|
11
10
|
static examples = ["<%= config.bin %> <%= command.id %> %pizza%"];
|
|
11
|
+
static aliases = ["org:user:get"];
|
|
12
12
|
|
|
13
13
|
static flags = {
|
|
14
14
|
// flag with no value (-f, --force)
|