proca 0.5.4 → 0.5.6

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
@@ -18,7 +18,7 @@ $ npm install -g proca
18
18
  $ proca COMMAND
19
19
  running command...
20
20
  $ proca (--version)
21
- proca/0.5.4 linux-x64 node-v20.12.2
21
+ proca/0.5.6 linux-x64 node-v20.12.2
22
22
  $ proca --help [COMMAND]
23
23
  USAGE
24
24
  $ proca COMMAND
@@ -66,6 +66,7 @@ USAGE
66
66
  * [`proca help [COMMAND]`](#proca-help-command)
67
67
  * [`proca org add`](#proca-org-add)
68
68
  * [`proca org crm`](#proca-org-crm)
69
+ * [`proca org delete`](#proca-org-delete)
69
70
  * [`proca org get`](#proca-org-get)
70
71
  * [`proca org join`](#proca-org-join)
71
72
  * [`proca plugins`](#proca-plugins)
@@ -83,6 +84,7 @@ USAGE
83
84
  * [`proca user leave`](#proca-user-leave)
84
85
  * [`proca user list`](#proca-user-list)
85
86
  * [`proca widget add`](#proca-widget-add)
87
+ * [`proca widget cache`](#proca-widget-cache)
86
88
  * [`proca widget get`](#proca-widget-get)
87
89
  * [`proca widget list`](#proca-widget-list)
88
90
 
@@ -333,24 +335,25 @@ DESCRIPTION
333
335
 
334
336
  ## `proca config set [ENVIRONMENT]`
335
337
 
336
- create setting to access the server authentication
338
+ update the setting used to authenticate to the servers and services
337
339
 
338
340
  ```
339
341
  USAGE
340
- $ proca config set [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
341
- --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
342
- [--supabase-secrey-key <value>]
342
+ $ proca config set [ENVIRONMENT] [--simplify [--json | --human | --csv]] [--url
343
+ <url>] [--cloudflare-zone <value>] [--cloudflare-token <value>] [--token <API-token>] [--n8n <n8n api>] [--supabase
344
+ <url>] [--supabase-anon-key <value>] [--supabase-secrey-key <value>]
343
345
 
344
346
  ARGUMENTS
345
347
  ENVIRONMENT [default: default] environment
346
348
 
347
349
  FLAGS
348
- --force write over an existing configuration
350
+ --cloudflare-token=<value> token for your cloudflare cdn
351
+ --cloudflare-zone=<value> zone for your cloudflare cdn
349
352
  --n8n=<n8n api> api access on the n8n server
350
353
  --supabase=<url> url of the supabase
351
354
  --supabase-anon-key=<value> anonymous key
352
355
  --supabase-secrey-key=<value> secret service key
353
- --token=<API-token> (required) user token on proca server
356
+ --token=<API-token> user token on proca server
354
357
  --url=<url> [default: https://api.proca.app/api] url of the proca server api
355
358
 
356
359
  OUTPUT FLAGS
@@ -360,7 +363,7 @@ OUTPUT FLAGS
360
363
  --simplify flatten and filter to output only the most important attributes, mostly relevant for json
361
364
 
362
365
  DESCRIPTION
363
- create setting to access the server authentication
366
+ update the setting used to authenticate to the servers and services
364
367
 
365
368
  ALIASES
366
369
  $ proca config setup
@@ -513,6 +516,28 @@ DESCRIPTION
513
516
  view a org crm synchroniser
514
517
  ```
515
518
 
519
+ ## `proca org delete`
520
+
521
+ ```
522
+ USAGE
523
+ $ proca org delete [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-i <value>
524
+ | -n <org name> | -x <value>]
525
+
526
+ FLAGS
527
+ -i, --id=<value>
528
+ -n, --name=<org name> name of the org
529
+ -x, --dxid=<value> dxid
530
+
531
+ OUTPUT FLAGS
532
+ --csv Format output as csv
533
+ --human Format output to be read on screen by a human [default]
534
+ --json Format output as json
535
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
536
+
537
+ EXAMPLES
538
+ $ proca org delete <organisation_name>
539
+ ```
540
+
516
541
  ## `proca org get`
517
542
 
518
543
  view a org
@@ -991,6 +1016,36 @@ OUTPUT FLAGS
991
1016
  --simplify flatten and filter to output only the most important attributes, mostly relevant for json
992
1017
  ```
993
1018
 
1019
+ ## `proca widget cache`
1020
+
1021
+ clear the cdn cache of a widget
1022
+
1023
+ ```
1024
+ USAGE
1025
+ $ proca widget cache [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-i <value>
1026
+ | -n <the_short_name> | -x <value>] [--url <value>]
1027
+
1028
+ FLAGS
1029
+ -i, --id=<value>
1030
+ -n, --name=<the_short_name> name
1031
+ -x, --dxid=<value> dxid
1032
+ --url=<value> url of the widget on the CDN
1033
+
1034
+ OUTPUT FLAGS
1035
+ --csv Format output as csv
1036
+ --human Format output to be read on screen by a human [default]
1037
+ --json Format output as json
1038
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
1039
+
1040
+ DESCRIPTION
1041
+ clear the cdn cache of a widget
1042
+
1043
+ EXAMPLES
1044
+ $ proca widget cache --url https://cdn.proca.app/d/[campaign]/[org]/[locale]
1045
+
1046
+ $ proca widget cache --name [campaign]/[org]/[locale]
1047
+ ```
1048
+
994
1049
  ## `proca widget get`
995
1050
 
996
1051
  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": "0.5.4",
4
+ "version": "0.5.6",
5
5
  "author": "Xavier",
6
6
  "bin": {
7
7
  "proca": "./proca-cli"
@@ -1,6 +1,6 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
- import { get as getConfig, getFilename, write } from "#src/config.mjs";
3
+ import { get as getConfig, getFilename, load, write } from "#src/config.mjs";
4
4
  import Command from "#src/procaCommand.mjs";
5
5
 
6
6
  export default class CampaignList extends Command {
@@ -15,7 +15,8 @@ export default class CampaignList extends Command {
15
15
  }),
16
16
  };
17
17
 
18
- static description = "create setting to access the server authentication";
18
+ static description =
19
+ "update the setting used to authenticate to the servers and services";
19
20
 
20
21
  static examples = [
21
22
  "<%= config.bin %> <%= command.id %> --user=xavier@example.org --token=API-12345789",
@@ -24,20 +25,20 @@ export default class CampaignList extends Command {
24
25
  static flags = {
25
26
  // flag with no value (-f, --force)
26
27
  ...super.globalFlags,
27
- force: Flags.boolean({
28
- description: "write over an existing configuration",
29
- default: false,
30
- helpValue: "(default false)",
31
- }),
32
28
  url: Flags.string({
33
29
  description: "url of the proca server api",
34
30
  default: "https://api.proca.app/api",
35
31
  helpValue: "<url>",
36
32
  }),
33
+ "cloudflare-zone": Flags.string({
34
+ description: "zone for your cloudflare cdn",
35
+ }),
36
+ "cloudflare-token": Flags.string({
37
+ description: "token for your cloudflare cdn",
38
+ }),
37
39
  token: Flags.string({
38
40
  description: "user token on proca server",
39
41
  helpValue: "<API-token>",
40
- required: true,
41
42
  }),
42
43
  n8n: Flags.string({
43
44
  description: "api access on the n8n server",
@@ -82,10 +83,17 @@ export default class CampaignList extends Command {
82
83
  };
83
84
 
84
85
  async run() {
85
- const { args, flags } = await this.parse();
86
+ const config = this.config;
87
+ const { args, flags, raw } = await this.parse();
88
+ const rawf = raw.filter((d) => d.type === "flag").map((d) => d.flag);
86
89
  const file = getFilename(this.config.configDir);
87
90
 
88
- const userConfig = getConfig(file);
91
+ const userConfig = getConfig(file, true);
92
+
93
+ console.log("config file", file);
94
+ console.error(file, userConfig, rawf);
95
+ process.exit(1);
96
+
89
97
  if (userConfig && !this.flags.force) {
90
98
  this.error("config file exists already", {
91
99
  code: "CONFIG_ERR",
@@ -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,29 @@
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/widget.mjs";
5
+ import { gql, query } from "#src/urql.mjs";
6
+
7
+ export default class WidgetGet extends Command {
8
+ static description = "clear the cdn cache of a widget";
9
+
10
+ static examples = [
11
+ "<%= config.bin %> <%= command.id %> --url https://cdn.proca.app/d/[campaign]/[org]/[locale]",
12
+ "<%= config.bin %> <%= command.id %> --name [campaign]/[org]/[locale]",
13
+ ];
14
+ static args = this.multiid();
15
+
16
+ static flags = {
17
+ // flag with no value (-f, --force)
18
+ ...this.flagify({ multiid: true }),
19
+ url: Flags.string ({
20
+ description: "url of the widget on the CDN",
21
+ }),
22
+ };
23
+
24
+ async run() {
25
+ const { args, flags } = await this.parse();
26
+ console.log(flags);
27
+ }
28
+ }
29
+
package/src/config.mjs CHANGED
@@ -15,8 +15,12 @@ export const load = (folder, env = "default") => {
15
15
  };
16
16
  };
17
17
 
18
- export const get = (file) => {
18
+ export const get = (file, parsed = false) => {
19
19
  try {
20
+ if (parsed) {
21
+ const config = dotenv({ path: file });
22
+ return config.parsed;
23
+ }
20
24
  const userConfig = readFileSync(file, "utf8");
21
25
  return userConfig;
22
26
  } catch (e) {
package/src/urql.mjs CHANGED
@@ -16,8 +16,11 @@ export let client = {
16
16
 
17
17
  // Create a URQL client with your GraphQL API endpoint
18
18
  export const createClient = (config) => {
19
+ if (!config) {
20
+ console.error("config missing on createClient");
21
+ }
19
22
  client = _createClient({
20
- url: config.url || "https://api.proca.app/api",
23
+ url: config?.url || "https://api.proca.app/api",
21
24
  exchanges: [
22
25
  // cacheExchange, // Handles caching
23
26
  authExchange(async (utils) => {