• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dialoguedb / client-nodejs / 26549428352

28 May 2026 01:41AM UTC coverage: 83.537%. First build
26549428352

Pull #80

github

web-flow
Merge 997333343 into c9508f8b7
Pull Request #80: Draft PR for release version v2.0.0

938 of 1116 branches covered (84.05%)

Branch coverage included in aggregate %.

0 of 216 new or added lines in 6 files covered. (0.0%)

1112 of 1338 relevant lines covered (83.11%)

38.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cli/message.ts
1
import { Command } from "commander";
NEW
2
import { readFile } from "node:fs/promises";
×
NEW
3
import {
×
4
  loadDialogueOrExit,
5
  output,
6
  parseCSV,
7
  parseIntStrict,
8
  parseJSON,
9
  resolveContent,
10
  withErrorHandler,
11
} from "./shared";
12

NEW
13
export function registerMessageCommands(program: Command): void {
×
NEW
14
  const message = program
×
15
    .command("message")
16
    .description("Manage messages within a dialogue");
17

NEW
18
  message
×
19
    .command("add <dialogueId>")
20
    .description("Add a message to a dialogue")
21
    .requiredOption("--role <role>", "Message role (e.g. user, assistant)")
22
    .option("--content <content>", "Message content (string)")
23
    .option("--content-json <json>", "Message content (JSON)")
24
    .option("--stdin", "Read content from stdin")
25
    .option("--name <name>", "Optional name")
26
    .option("--namespace <namespace>", "Namespace")
27
    .option("--tags <csv>", "Tags (comma-separated)")
28
    .action(
29
      withErrorHandler(async (dialogueId: string, opts) => {
NEW
30
        const d = await loadDialogueOrExit(dialogueId, opts.namespace);
×
31

32
        let content: unknown;
NEW
33
        if (opts.contentJson) {
×
NEW
34
          content = parseJSON("content-json", opts.contentJson);
×
35
        } else {
NEW
36
          content = await resolveContent({
×
37
            content: opts.content,
38
            stdin: opts.stdin,
39
          });
40
        }
41

NEW
42
        const msg = await d.saveMessage({
×
43
          role: opts.role,
44
          content: content as any,
45
          ...(opts.name && { name: opts.name }),
×
46
          ...(opts.tags && { tags: parseCSV(opts.tags) }),
×
47
        });
NEW
48
        output(msg);
×
49
      })
50
    );
51

NEW
52
  message
×
53
    .command("add-batch <dialogueId>")
54
    .description("Add multiple messages from a JSON file")
55
    .requiredOption(
56
      "--file <path>",
57
      "Path to JSON file containing array of {role, content}"
58
    )
59
    .option("--namespace <namespace>", "Namespace")
60
    .action(
61
      withErrorHandler(async (dialogueId: string, opts) => {
NEW
62
        const d = await loadDialogueOrExit(dialogueId, opts.namespace);
×
NEW
63
        const raw = await readFile(opts.file, "utf8");
×
NEW
64
        const messages = parseJSON("file", raw);
×
NEW
65
        if (!Array.isArray(messages)) {
×
NEW
66
          throw new Error(
×
67
            `--file must contain a JSON array, got ${typeof messages}`
68
          );
69
        }
NEW
70
        const saved = await d.saveMessages(messages as any);
×
NEW
71
        output(saved);
×
72
      })
73
    );
74

NEW
75
  message
×
76
    .command("list <dialogueId>")
77
    .description("List messages in a dialogue")
78
    .option("--limit <n>", "Limit")
79
    .option("--order <asc|desc>", "Sort order")
80
    .option("--namespace <namespace>", "Namespace")
81
    .option("--next-page", "Append next page using cached cursor")
82
    .action(
83
      withErrorHandler(async (dialogueId: string, opts) => {
NEW
84
        const d = await loadDialogueOrExit(dialogueId, opts.namespace);
×
NEW
85
        const filters: Record<string, unknown> = {};
×
NEW
86
        if (opts.limit) filters.limit = parseIntStrict("limit", opts.limit);
×
NEW
87
        if (opts.order) filters.order = opts.order;
×
NEW
88
        if (opts.nextPage) filters.next = true;
×
NEW
89
        const items = await d.loadMessages(filters as any);
×
NEW
90
        output(items);
×
91
      })
92
    );
93

NEW
94
  message
×
95
    .command("get <dialogueId> <messageId>")
96
    .description("Get a single message by ID")
97
    .option("--namespace <namespace>", "Namespace")
98
    .action(
99
      withErrorHandler(async (dialogueId: string, messageId: string, opts) => {
NEW
100
        const d = await loadDialogueOrExit(dialogueId, opts.namespace);
×
NEW
101
        const msg = await d.getMessage(messageId);
×
NEW
102
        output(msg);
×
103
      })
104
    );
105

NEW
106
  message
×
107
    .command("delete <dialogueId> <messageId>")
108
    .description("Delete a message by ID")
109
    .option("--namespace <namespace>", "Namespace")
110
    .action(
111
      withErrorHandler(async (dialogueId: string, messageId: string, opts) => {
NEW
112
        const d = await loadDialogueOrExit(dialogueId, opts.namespace);
×
NEW
113
        await d.deleteMessage(messageId);
×
NEW
114
        output({ deleted: messageId });
×
115
      })
116
    );
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc