runline 0.3.2 → 0.4.0

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.
@@ -1,3 +1,4 @@
1
1
  export declare function actions(options: {
2
2
  json?: boolean;
3
+ connected?: boolean;
3
4
  }): Promise<void>;
@@ -1,12 +1,19 @@
1
1
  import chalk from "chalk";
2
+ import { loadConfig } from "../config/loader.js";
2
3
  import { loadAllPlugins } from "../plugin/loader.js";
3
4
  import { registry } from "../plugin/registry.js";
4
5
  import { printJson } from "../utils/output.js";
5
6
  export async function actions(options) {
6
7
  await loadAllPlugins();
7
8
  const all = registry.getAllActions();
9
+ const connectedPlugins = options.connected
10
+ ? new Set(loadConfig().connections.map((c) => c.plugin))
11
+ : null;
12
+ const filtered = connectedPlugins
13
+ ? all.filter(({ plugin }) => connectedPlugins.has(plugin))
14
+ : all;
8
15
  if (options.json) {
9
- printJson(all.map(({ plugin, action }) => ({
16
+ printJson(filtered.map(({ plugin, action }) => ({
10
17
  plugin,
11
18
  action: action.name,
12
19
  description: action.description,
@@ -14,12 +21,18 @@ export async function actions(options) {
14
21
  })));
15
22
  return;
16
23
  }
17
- if (all.length === 0) {
18
- console.log("No actions registered. Install a plugin first.");
24
+ if (filtered.length === 0) {
25
+ if (options.connected) {
26
+ console.log("No actions found for connected services.");
27
+ console.log("Add a connection first: runline connection add <name> -p <plugin>");
28
+ }
29
+ else {
30
+ console.log("No actions registered. Install a plugin first.");
31
+ }
19
32
  return;
20
33
  }
21
34
  const grouped = new Map();
22
- for (const entry of all) {
35
+ for (const entry of filtered) {
23
36
  const list = grouped.get(entry.plugin) ?? [];
24
37
  list.push(entry);
25
38
  grouped.set(entry.plugin, list);
package/dist/main.js CHANGED
@@ -55,9 +55,10 @@ Examples:
55
55
  program
56
56
  .command("actions")
57
57
  .description("List all available actions and their schemas")
58
- .action(async (_opts, cmd) => {
58
+ .option("-c, --connected", "Only show actions for plugins with configured connections")
59
+ .action(async (opts, cmd) => {
59
60
  const globals = cmd.optsWithGlobals();
60
- await actions({ json: globals.json });
61
+ await actions({ json: globals.json, connected: opts.connected });
61
62
  });
62
63
  // ── connection ──────────────────────────────────────────
63
64
  const connCmd = program
@@ -270,7 +270,7 @@ const REPLY_METADATA_HEADERS = [
270
270
  /**
271
271
  * Translate a friendly filter bag into Gmail's list query shape.
272
272
  *
273
- * Mirrors n8n's `prepareQuery` helper: `sender`, `readStatus`,
273
+ * `sender`, `readStatus`,
274
274
  * `receivedAfter`, `receivedBefore` fold into the `q=` search
275
275
  * expression (which itself can be combined with an explicit `q`).
276
276
  * `labelIds`, `includeSpamTrash`, `pageToken`, `maxResults` pass
@@ -582,7 +582,7 @@ export default function gmail(rl) {
582
582
  },
583
583
  },
584
584
  async execute(input, ctx) {
585
- const p = input;
585
+ const p = (input ?? {});
586
586
  const email = {
587
587
  to: normalizeAddressList(p.to),
588
588
  cc: normalizeAddressList(p.cc),
@@ -613,7 +613,7 @@ export default function gmail(rl) {
613
613
  attachments: { type: "array", required: false },
614
614
  },
615
615
  async execute(input, ctx) {
616
- const p = input;
616
+ const p = (input ?? {});
617
617
  return replyToMessage(ctx, p.messageId, p);
618
618
  },
619
619
  });
@@ -634,7 +634,7 @@ export default function gmail(rl) {
634
634
  },
635
635
  },
636
636
  async execute(input, ctx) {
637
- const p = input;
637
+ const p = (input ?? {});
638
638
  const qs = { format: p.format ?? "full" };
639
639
  if (p.metadataHeaders)
640
640
  qs.metadataHeaders = p.metadataHeaders;
@@ -672,7 +672,7 @@ export default function gmail(rl) {
672
672
  },
673
673
  },
674
674
  async execute(input, ctx) {
675
- const p = input;
675
+ const p = (input ?? {});
676
676
  const qs = buildListQuery(p);
677
677
  if (p.returnAll) {
678
678
  return paginateAll(ctx, "/messages", "messages", qs);
@@ -777,7 +777,7 @@ export default function gmail(rl) {
777
777
  },
778
778
  },
779
779
  async execute(input, ctx) {
780
- const p = input;
780
+ const p = (input ?? {});
781
781
  const qs = { format: p.format ?? "full" };
782
782
  if (p.metadataHeaders)
783
783
  qs.metadataHeaders = p.metadataHeaders;
@@ -803,7 +803,7 @@ export default function gmail(rl) {
803
803
  returnAll: { type: "boolean", required: false },
804
804
  },
805
805
  async execute(input, ctx) {
806
- const p = input;
806
+ const p = (input ?? {});
807
807
  const qs = buildListQuery(p);
808
808
  if (p.returnAll)
809
809
  return paginateAll(ctx, "/threads", "threads", qs);
@@ -875,7 +875,7 @@ export default function gmail(rl) {
875
875
  attachments: { type: "array", required: false },
876
876
  },
877
877
  async execute(input, ctx) {
878
- const p = input;
878
+ const p = (input ?? {});
879
879
  const thread = (await gmailRequest(ctx, "GET", `/threads/${p.id}`, undefined, { format: "minimal" }));
880
880
  const last = thread.messages?.[thread.messages.length - 1];
881
881
  if (!last?.id) {
@@ -905,7 +905,7 @@ export default function gmail(rl) {
905
905
  attachments: { type: "array", required: false },
906
906
  },
907
907
  async execute(input, ctx) {
908
- const p = input;
908
+ const p = (input ?? {});
909
909
  const from = p.from ?? p.fromAlias;
910
910
  const email = {
911
911
  to: normalizeAddressList(p.to) ?? "",
@@ -943,7 +943,7 @@ export default function gmail(rl) {
943
943
  format: { type: "string", required: false },
944
944
  },
945
945
  async execute(input, ctx) {
946
- const p = input;
946
+ const p = (input ?? {});
947
947
  const qs = { format: p.format ?? "full" };
948
948
  return gmailRequest(ctx, "GET", `/drafts/${p.id}`, undefined, qs);
949
949
  },
@@ -958,7 +958,7 @@ export default function gmail(rl) {
958
958
  returnAll: { type: "boolean", required: false },
959
959
  },
960
960
  async execute(input, ctx) {
961
- const p = input;
961
+ const p = (input ?? {});
962
962
  const qs = {};
963
963
  if (p.q)
964
964
  qs.q = p.q;
@@ -1006,7 +1006,7 @@ export default function gmail(rl) {
1006
1006
  },
1007
1007
  },
1008
1008
  async execute(input, ctx) {
1009
- const p = input;
1009
+ const p = (input ?? {});
1010
1010
  const body = { name: p.name };
1011
1011
  if (p.labelListVisibility)
1012
1012
  body.labelListVisibility = p.labelListVisibility;
@@ -1047,7 +1047,7 @@ export default function gmail(rl) {
1047
1047
  messageListVisibility: { type: "string", required: false },
1048
1048
  },
1049
1049
  async execute(input, ctx) {
1050
- const p = input;
1050
+ const p = (input ?? {});
1051
1051
  const body = {};
1052
1052
  if (p.name)
1053
1053
  body.name = p.name;