proca 1.8.2 → 2.0.1
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 +347 -195
- package/package.json +2 -1
- 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 +92 -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 +98 -111
- 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/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/area/count.mjs +38 -0
- package/src/commands/contact/count.mjs +0 -1
- package/src/commands/contact/list.mjs +128 -132
- 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 +9 -1
- 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/reset.mjs +72 -72
- package/src/commands/widget/add.mjs +61 -70
- package/src/commands/widget/delete.mjs +27 -27
- package/src/commands/widget/external/update.mjs +52 -0
- package/src/commands/widget/get.mjs +5 -0
- package/src/commands/widget/list.mjs +7 -5
- 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 +32 -9
- package/src/urql.mjs +39 -39
- package/src/util/twitter.mjs +19 -19
- package/theme.json +27 -27
package/src/commands/org/add.mjs
CHANGED
|
@@ -5,36 +5,36 @@ import { gql, mutation } from "#src/urql.mjs";
|
|
|
5
5
|
import { getTwitter } from "#src/util/twitter.mjs";
|
|
6
6
|
|
|
7
7
|
export default class OrgAdd extends Command {
|
|
8
|
-
|
|
8
|
+
static args = {};
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
create = async (_org) => {
|
|
34
|
+
const org = { ..._org, config: JSON.stringify(_org.config) };
|
|
35
|
+
console.log(org);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const AddOrgDocument = gql`
|
|
38
38
|
mutation ($org: OrgInput!) {
|
|
39
39
|
addOrg(input: $org) {
|
|
40
40
|
config
|
|
@@ -43,33 +43,33 @@ mutation ($org: OrgInput!) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
`;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
const org = {
|
|
63
|
+
name: flags.twitter || flags.name,
|
|
64
|
+
title: flags.title || flags.name,
|
|
65
|
+
config: {},
|
|
66
|
+
};
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
if (flags.twitter) {
|
|
69
|
+
await getTwitter(org);
|
|
70
|
+
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
const data = await this.create(org);
|
|
73
|
+
return this.output(data);
|
|
74
|
+
}
|
|
75
75
|
}
|
package/src/commands/org/crm.mjs
CHANGED
|
@@ -5,28 +5,28 @@ import Command from "#src/procaCommand.mjs";
|
|
|
5
5
|
import { gql, mutation, query } from "#src/urql.mjs";
|
|
6
6
|
|
|
7
7
|
export default class OrgCRM extends Command {
|
|
8
|
-
|
|
8
|
+
static description = "view a org crm synchroniser";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
fetch = async (params) => {
|
|
29
|
+
const GetOrgDocument = gql`
|
|
30
30
|
query GetOrg($name: String!) {
|
|
31
31
|
org (name: $name) {
|
|
32
32
|
id name title
|
|
@@ -34,55 +34,55 @@ export default class OrgCRM extends Command {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
const result = await query(GetOrgDocument, {
|
|
38
|
+
name: params.name,
|
|
39
|
+
});
|
|
40
|
+
return result.org;
|
|
41
|
+
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
mutate = async (name, deliver) => {
|
|
44
|
+
const Document = gql`
|
|
45
45
|
mutation ($name: String!, $deliver: Boolean!) {
|
|
46
46
|
updateOrgProcessing (name: $name,customActionDeliver: $deliver) {
|
|
47
47
|
id, name, title, processing {customActionDeliver}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
table = (r) => {
|
|
74
|
+
super.table(r, null, null);
|
|
75
|
+
};
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
88
|
}
|
|
@@ -4,45 +4,45 @@ import Command from "#src/procaCommand.mjs";
|
|
|
4
4
|
import { gql, mutation } from "#src/urql.mjs";
|
|
5
5
|
|
|
6
6
|
export default class OrgDelete extends Command {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
static examples = [
|
|
8
|
+
"<%= config.bin %> <%= command.id %> <organisation_name>",
|
|
9
|
+
];
|
|
10
|
+
static args = this.multiid();
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
delete = async (org) => {
|
|
23
|
+
console.log(org);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const DeleteOrgDocument = gql`
|
|
26
26
|
mutation ($org: String!) {
|
|
27
27
|
deleteOrg(name: $org)
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
async run() {
|
|
43
|
+
const { args, flags } = await this.parse();
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const data = await this.delete(flags.name);
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
48
|
}
|
|
@@ -1,83 +1,111 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import Command from "#src/procaCommand.mjs";
|
|
3
|
-
import { gql, mutation
|
|
3
|
+
import { gql, mutation } from "#src/urql.mjs";
|
|
4
4
|
|
|
5
5
|
const SERVICE_NAMES = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
"MAILJET",
|
|
7
|
+
"SES",
|
|
8
|
+
"STRIPE",
|
|
9
|
+
"TEST_STRIPE",
|
|
10
|
+
"SYSTEM",
|
|
11
|
+
"PREVIEW",
|
|
12
|
+
"WEBHOOK",
|
|
13
|
+
"SUPABASE",
|
|
14
|
+
"SMTP",
|
|
15
15
|
].map((d) => d.toLowerCase());
|
|
16
16
|
|
|
17
17
|
export default class OrgEmail extends Command {
|
|
18
|
-
|
|
18
|
+
static description =
|
|
19
|
+
"Set email service and supporter confirmation for an org";
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
static flags = {
|
|
22
|
-
...super.globalFlags,
|
|
23
|
-
org: Flags.string({
|
|
24
|
-
aliases: ["name", "o"],
|
|
25
|
-
description: "organisation running the service",
|
|
26
|
-
required: true,
|
|
27
|
-
}),
|
|
28
|
-
mailer: Flags.string({
|
|
29
|
-
description: "service to send emails",
|
|
30
|
-
options: SERVICE_NAMES,
|
|
31
|
-
helpValue: SERVICE_NAMES,
|
|
32
|
-
required: true,
|
|
33
|
-
default: "MAILJET",
|
|
34
|
-
}),
|
|
35
|
-
from: Flags.string({
|
|
36
|
-
description: "Email address to send from (default: <org>@proca.app)",
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
21
|
+
static args = this.multiid();
|
|
39
22
|
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
};
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
53
54
|
) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
}
|
|
59
74
|
}
|
|
60
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);
|
|
61
87
|
}
|
|
62
|
-
`;
|
|
63
|
-
const result = await mutation(Document, {
|
|
64
|
-
name: flags.org,
|
|
65
|
-
emailBackend: flags.mailer.toUpperCase(),
|
|
66
|
-
emailFrom: flags.from,
|
|
67
|
-
});
|
|
68
|
-
return result.updateOrgProcessing;
|
|
69
|
-
}
|
|
70
88
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
});
|
|
80
105
|
|
|
81
|
-
|
|
82
|
-
|
|
106
|
+
async run() {
|
|
107
|
+
const { flags } = await this.parse();
|
|
108
|
+
const result = await this.mutate(flags);
|
|
109
|
+
this.output(result);
|
|
110
|
+
}
|
|
83
111
|
}
|
package/src/commands/org/get.mjs
CHANGED
|
@@ -4,6 +4,11 @@ import Command from "#src/procaCommand.mjs";
|
|
|
4
4
|
//import {FragmentSummary,} from "#src/queries/org.mjs";
|
|
5
5
|
import { gql, query } from "#src/urql.mjs";
|
|
6
6
|
|
|
7
|
+
export const getOrg = (params) => {
|
|
8
|
+
const d = new OrgGet([]);
|
|
9
|
+
return d.fetch(params);
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
export default class OrgGet extends Command {
|
|
8
13
|
static description = "view a org";
|
|
9
14
|
|
|
@@ -137,7 +142,10 @@ export default class OrgGet extends Command {
|
|
|
137
142
|
};
|
|
138
143
|
|
|
139
144
|
async run() {
|
|
140
|
-
|
|
145
|
+
console.log("starting");
|
|
146
|
+
const { flags } = await this.parse();
|
|
147
|
+
console.log("flags", this.Flags);
|
|
148
|
+
|
|
141
149
|
const data = await this.fetch(flags);
|
|
142
150
|
return this.output(data);
|
|
143
151
|
}
|