@kweaver-ai/kweaver-sdk 0.4.13 → 0.4.15

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,13 +1,17 @@
1
- import { getCurrentPlatform, resolveBusinessDomain, savePlatformBusinessDomain, loadPlatformBusinessDomain, } from "../config/store.js";
1
+ import { listBusinessDomains } from "../api/business-domains.js";
2
+ import { withTokenRetry } from "../auth/oauth.js";
3
+ import { getCurrentPlatform, loadPlatformBusinessDomain, resolveBusinessDomain, savePlatformBusinessDomain, } from "../config/store.js";
2
4
  const HELP = `kweaver config
3
5
 
4
6
  Subcommands:
5
7
  set-bd <value> Set the default business domain for the current platform
8
+ list-bd List business domains as JSON (requires login)
6
9
  show Show current config (platform, business domain)
7
10
  --help Show this message
8
11
 
9
12
  Examples:
10
13
  kweaver config set-bd 54308785-4438-43df-9490-a7fd11df5765
14
+ kweaver config list-bd
11
15
  kweaver config show`;
12
16
  export async function runConfigCommand(args) {
13
17
  const [sub, ...rest] = args;
@@ -46,6 +50,35 @@ export async function runConfigCommand(args) {
46
50
  console.log(`Business domain set to: ${value}`);
47
51
  return 0;
48
52
  }
53
+ if (sub === "list-bd") {
54
+ const platform = getCurrentPlatform();
55
+ if (!platform) {
56
+ console.error("No active platform. Run `kweaver auth login <url>` first.");
57
+ return 1;
58
+ }
59
+ try {
60
+ const rows = await withTokenRetry((token) => listBusinessDomains({
61
+ baseUrl: platform,
62
+ accessToken: token.accessToken,
63
+ tlsInsecure: token.tlsInsecure,
64
+ }));
65
+ const currentId = resolveBusinessDomain(platform);
66
+ const payload = {
67
+ currentId,
68
+ domains: rows.map((r) => ({
69
+ ...r,
70
+ current: r.id === currentId,
71
+ })),
72
+ };
73
+ console.log(JSON.stringify(payload, null, 2));
74
+ return 0;
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : String(error);
78
+ console.error(`Failed to list business domains: ${message}`);
79
+ return 1;
80
+ }
81
+ }
49
82
  console.error(`Unknown config subcommand: ${sub}`);
50
83
  console.log(HELP);
51
84
  return 1;