proca 1.7.2 → 1.7.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 CHANGED
@@ -52,6 +52,7 @@ you should also use the local proca-api in your [widget generator](https://githu
52
52
  * [`proca action count`](#proca-action-count)
53
53
  * [`proca action list [TITLE]`](#proca-action-list-title)
54
54
  * [`proca action replay`](#proca-action-replay)
55
+ * [`proca action requeue`](#proca-action-requeue)
55
56
  * [`proca campaign add [TITLE]`](#proca-campaign-add-title)
56
57
  * [`proca campaign close`](#proca-campaign-close)
57
58
  * [`proca campaign delete`](#proca-campaign-delete)
@@ -90,6 +91,7 @@ you should also use the local proca-api in your [widget generator](https://githu
90
91
  * [`proca template add`](#proca-template-add)
91
92
  * [`proca template list`](#proca-template-list)
92
93
  * [`proca user get`](#proca-user-get)
94
+ * [`proca user invite`](#proca-user-invite)
93
95
  * [`proca user join`](#proca-user-join)
94
96
  * [`proca user leave`](#proca-user-leave)
95
97
  * [`proca user list`](#proca-user-list)
@@ -97,6 +99,7 @@ you should also use the local proca-api in your [widget generator](https://githu
97
99
  * [`proca user reset [USER]`](#proca-user-reset-user)
98
100
  * [`proca user whoami`](#proca-user-whoami)
99
101
  * [`proca widget add`](#proca-widget-add)
102
+ * [`proca widget delete`](#proca-widget-delete)
100
103
  * [`proca widget get`](#proca-widget-get)
101
104
  * [`proca widget list`](#proca-widget-list)
102
105
 
@@ -257,6 +260,34 @@ EXAMPLES
257
260
  $ proca action replay %pizza%
258
261
  ```
259
262
 
263
+ ## `proca action requeue`
264
+
265
+ requeue an action
266
+
267
+ ```
268
+ USAGE
269
+ $ proca action requeue --id <value> -o <org name> -q <user email> [--json | --human |
270
+ --csv] [--env <value>] [--simplify]
271
+
272
+ FLAGS
273
+ -o, --org=<org name> (required) name of the org
274
+ -q, --queue=<user email> (required) queue to redeliver to
275
+ --env=<value> [default: default] allow to switch between configurations (server or users)
276
+ --id=<value> (required) action id
277
+
278
+ OUTPUT FLAGS
279
+ --csv Format output as csv
280
+ --human Format output to be read on screen by a human [default]
281
+ --json Format output as json
282
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
283
+
284
+ DESCRIPTION
285
+ requeue an action
286
+
287
+ EXAMPLES
288
+ $ proca action requeue
289
+ ```
290
+
260
291
  ## `proca campaign add [TITLE]`
261
292
 
262
293
  ```
@@ -1346,6 +1377,35 @@ EXAMPLES
1346
1377
  $ proca user get
1347
1378
  ```
1348
1379
 
1380
+ ## `proca user invite`
1381
+
1382
+ invite a user to join an organisation with a role
1383
+
1384
+ ```
1385
+ USAGE
1386
+ $ proca user invite -o <org name> -u <user email> [--json | --human | --csv] [--env
1387
+ <value>] [--simplify] [--role owner|campaigner|coordinator|translator]
1388
+
1389
+ FLAGS
1390
+ -o, --org=<org name> (required) name of the org
1391
+ -u, --user=<user email> (required) email
1392
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1393
+ --role=<option> [default: campaigner] permission level in that org
1394
+ <options: owner|campaigner|coordinator|translator>
1395
+
1396
+ OUTPUT FLAGS
1397
+ --csv Format output as csv
1398
+ --human Format output to be read on screen by a human [default]
1399
+ --json Format output as json
1400
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1401
+
1402
+ DESCRIPTION
1403
+ invite a user to join an organisation with a role
1404
+
1405
+ EXAMPLES
1406
+ $ proca user invite
1407
+ ```
1408
+
1349
1409
  ## `proca user join`
1350
1410
 
1351
1411
  let a user join an organisation with a role
@@ -1533,6 +1593,31 @@ OUTPUT FLAGS
1533
1593
  --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1534
1594
  ```
1535
1595
 
1596
+ ## `proca widget delete`
1597
+
1598
+ Delete a widget
1599
+
1600
+ ```
1601
+ USAGE
1602
+ $ proca widget delete [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
1603
+ [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
1604
+
1605
+ FLAGS
1606
+ -i, --id=<value>
1607
+ -n, --name=<the_short_name> name
1608
+ -x, --dxid=<value> dxid
1609
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1610
+
1611
+ OUTPUT FLAGS
1612
+ --csv Format output as csv
1613
+ --human Format output to be read on screen by a human [default]
1614
+ --json Format output as json
1615
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1616
+
1617
+ DESCRIPTION
1618
+ Delete a widget
1619
+ ```
1620
+
1536
1621
  ## `proca widget get`
1537
1622
 
1538
1623
  view a widget
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proca",
3
3
  "description": "Access the proca api",
4
- "version": "1.7.2",
4
+ "version": "1.7.3",
5
5
  "author": "Xavier",
6
6
  "bin": {
7
7
  "proca": "proca-cli"
@@ -0,0 +1,60 @@
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 ActionRequeue extends Command {
7
+ static description = "requeue an action";
8
+
9
+ static examples = ["<%= config.bin %> <%= command.id %>"];
10
+
11
+ static flags = {
12
+ ...super.globalFlags,
13
+ id: Flags.string({
14
+ description: "action id",
15
+ parse: (input) => Number.parseInt(input, 10),
16
+ required: true,
17
+ }),
18
+ org: Flags.string({
19
+ char: "o",
20
+ required: true,
21
+ description: "name of the org",
22
+ helpValue: "<org name>",
23
+ }),
24
+ queue: Flags.string({
25
+ char: "q",
26
+ required: true,
27
+ description: "queue to redeliver to",
28
+ helpValue: "<user email>",
29
+ }),
30
+ };
31
+
32
+ mutate = async (org) => {
33
+ const Document = gql`
34
+ mutation ($user: String!, $role: String!, $org: String!, message: String) {
35
+ inviteOrgUser(orgName: $org, message: $message, input :{ email: $user, role: $role}) {
36
+ objectId
37
+ code
38
+ }
39
+ }
40
+ `;
41
+ const result = await mutation(Document, {
42
+ org,
43
+ role,
44
+ user,
45
+ });
46
+ //return result.users.map (d => {d.config = JSON.parse(d.config); return d});
47
+ return result.inviteOrg;
48
+ };
49
+
50
+ table = (r) => {
51
+ super.table(r, null, null);
52
+ };
53
+
54
+ async run() {
55
+ throw new Error("NOT IMPLEMENTED");
56
+ const { args, flags } = await this.parse();
57
+ const data = await this.mutate(flag);
58
+ this.output(data);
59
+ }
60
+ }
@@ -0,0 +1,56 @@
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 UserInviteOrg extends Command {
7
+ static description = "invite a user to join an organisation with a role";
8
+
9
+ static examples = ["<%= config.bin %> <%= command.id %>"];
10
+
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
+
32
+ invite = async (params) => {
33
+ const Document = gql`
34
+ mutation ($user: String!, $role: String!, $org: String!, $message: String) {
35
+ inviteOrgUser(orgName: $org, message: $message, input: { email: $user, role: $role}) {
36
+ objectId
37
+ code
38
+ }
39
+ }
40
+ `;
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
+
47
+ table = (r) => {
48
+ super.table(r, null, null);
49
+ };
50
+
51
+ async run() {
52
+ const { args, flags } = await this.parse();
53
+ const data = await this.invite(flags);
54
+ this.output(data);
55
+ }
56
+ }
@@ -0,0 +1,45 @@
1
+ import { createInterface } from "node:readline";
2
+ import { Flags } from "@oclif/core";
3
+ import WidgetGet from "#src/commands/widget/get.mjs";
4
+ import Command from "#src/procaCommand.mjs";
5
+ import { gql, mutation } from "#src/urql.mjs";
6
+
7
+ export default class WidgetDelete extends Command {
8
+ static description = "Delete a widget";
9
+
10
+ static args = this.multiid();
11
+
12
+ static flags = {
13
+ ...this.flagify({ multiid: true }),
14
+ };
15
+
16
+ delete = async (flags) => {
17
+ const deletePageDocument = gql`
18
+ mutation delete( $name:String!) {
19
+ deleteActionPage(name: $name)
20
+ }
21
+ `;
22
+
23
+ const r = await mutation(deletePageDocument, { name: flags.name });
24
+ return { deleted: r.deleteActionPage };
25
+ };
26
+
27
+ table = (r) => {
28
+ super.table(r, null, null);
29
+ };
30
+
31
+ async run() {
32
+ const { flags } = await this.parse(WidgetDelete);
33
+ const wg = new WidgetGet([], this.config);
34
+ const widget = await wg.fetch(flags);
35
+ try {
36
+ const data = await this.delete({ name: widget.name });
37
+ widget.status = data.deleted;
38
+ } catch (e) {
39
+ widget.status = "can't delete widgets with actions";
40
+ this.output(widget);
41
+ this.error("a widget with actions can't be deleted");
42
+ }
43
+ return this.output(widget);
44
+ }
45
+ }
@@ -1,7 +1,7 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
3
  import Command from "#src/procaCommand.mjs";
4
- import { FragmentSummary } from "#src/queries/widget.mjs";
4
+ import { FragmentSummary, FragmentSummaryOrg } from "#src/queries/widget.mjs";
5
5
  import { gql, query } from "#src/urql.mjs";
6
6
 
7
7
  export default class WidgetList extends Command {
@@ -68,7 +68,7 @@ query SearchWidgets($org: String!, $withConfig: Boolean!) {
68
68
  }
69
69
  }
70
70
  }
71
- ${FragmentSummary}
71
+ ${FragmentSummaryOrg}
72
72
  }`;
73
73
  const result = await query(Document, {
74
74
  org: name,
@@ -96,8 +96,13 @@ ${FragmentSummary}
96
96
  result.extra = d.extraSupporters;
97
97
  }
98
98
  // if (d.journey) result.journey = d.journey.join(" → ");
99
- result.org = d.org.name;
100
- result.org_id = d.org.id;
99
+ if (d.org) {
100
+ result.org = d.org.name;
101
+ result.org_id = d.org.id;
102
+ }
103
+ if (d.campaign) {
104
+ result.campaign = d.campaign.name;
105
+ }
101
106
  if (this.flags.config) {
102
107
  }
103
108
  return result;
@@ -11,3 +11,15 @@ location
11
11
  org {name, ... on PrivateOrg {id} }
12
12
  }
13
13
  `;
14
+
15
+ export const FragmentSummaryOrg = gql`fragment Summary on PrivateActionPage {
16
+ id
17
+ locale
18
+ name
19
+ journey
20
+ extraSupporters
21
+ status
22
+ location
23
+ campaign {name }
24
+ }
25
+ `;