@kweaver-ai/kweaver-sdk 0.5.0 → 0.5.2
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 +6 -1
- package/README.zh.md +5 -0
- package/dist/api/agent-chat.d.ts +1 -1
- package/dist/api/agent-chat.js +4 -4
- package/dist/api/agent-list.d.ts +35 -0
- package/dist/api/agent-list.js +86 -12
- package/dist/api/bkn-backend.d.ts +60 -0
- package/dist/api/bkn-backend.js +103 -10
- package/dist/api/conversations.d.ts +6 -3
- package/dist/api/conversations.js +26 -27
- package/dist/api/dataflow.js +1 -10
- package/dist/api/datasources.js +1 -10
- package/dist/api/dataviews.js +1 -10
- package/dist/api/headers.d.ts +9 -0
- package/dist/api/headers.js +25 -0
- package/dist/api/knowledge-networks.d.ts +41 -0
- package/dist/api/knowledge-networks.js +69 -22
- package/dist/api/ontology-query.d.ts +14 -1
- package/dist/api/ontology-query.js +63 -49
- package/dist/api/semantic-search.js +2 -12
- package/dist/api/skills.d.ts +141 -0
- package/dist/api/skills.js +216 -0
- package/dist/api/vega.d.ts +63 -0
- package/dist/api/vega.js +131 -10
- package/dist/auth/oauth.d.ts +5 -1
- package/dist/auth/oauth.js +293 -94
- package/dist/cli.js +29 -4
- package/dist/client.d.ts +3 -0
- package/dist/client.js +4 -0
- package/dist/commands/agent.d.ts +33 -1
- package/dist/commands/agent.js +721 -49
- package/dist/commands/auth.js +211 -21
- package/dist/commands/bkn-ops.d.ts +77 -0
- package/dist/commands/bkn-ops.js +1056 -0
- package/dist/commands/bkn-query.d.ts +14 -0
- package/dist/commands/bkn-query.js +370 -0
- package/dist/commands/bkn-schema.d.ts +135 -0
- package/dist/commands/bkn-schema.js +1461 -0
- package/dist/commands/bkn-utils.d.ts +36 -0
- package/dist/commands/bkn-utils.js +102 -0
- package/dist/commands/bkn.d.ts +7 -113
- package/dist/commands/bkn.js +175 -2429
- package/dist/commands/dataview.d.ts +7 -0
- package/dist/commands/dataview.js +38 -2
- package/dist/commands/ds.d.ts +1 -0
- package/dist/commands/ds.js +8 -1
- package/dist/commands/import-csv.d.ts +2 -0
- package/dist/commands/import-csv.js +3 -2
- package/dist/commands/skill.d.ts +26 -0
- package/dist/commands/skill.js +524 -0
- package/dist/commands/vega.js +371 -14
- package/dist/config/jwt.d.ts +6 -0
- package/dist/config/jwt.js +21 -0
- package/dist/config/store.d.ts +37 -5
- package/dist/config/store.js +363 -30
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/resources/bkn.d.ts +4 -0
- package/dist/resources/bkn.js +4 -0
- package/dist/resources/conversations.d.ts +5 -2
- package/dist/resources/conversations.js +17 -3
- package/dist/resources/skills.d.ts +47 -0
- package/dist/resources/skills.js +47 -0
- package/dist/resources/vega.d.ts +11 -0
- package/dist/resources/vega.js +37 -1
- package/package.json +1 -1
package/dist/commands/auth.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { autoSelectBusinessDomain, clearPlatformSession, deletePlatform, getConfigDir, getCurrentPlatform, getPlatformAlias, hasPlatform, listPlatforms, loadClientConfig, loadTokenConfig, resolvePlatformIdentifier, setCurrentPlatform, setPlatformAlias, } from "../config/store.js";
|
|
1
|
+
import { autoSelectBusinessDomain, clearPlatformSession, deletePlatform, deleteUser, getActiveUser, getConfigDir, getCurrentPlatform, getPlatformAlias, hasPlatform, listPlatforms, listUserProfiles, loadClientConfig, loadTokenConfig, resolvePlatformIdentifier, resolveUserId, setActiveUser, setCurrentPlatform, setPlatformAlias, } from "../config/store.js";
|
|
2
|
+
import { decodeJwtPayload } from "../config/jwt.js";
|
|
2
3
|
import { buildCopyCommand, formatHttpError, normalizeBaseUrl, oauth2Login, playwrightLogin, refreshTokenLogin, } from "../auth/oauth.js";
|
|
3
4
|
export async function runAuthCommand(args) {
|
|
4
5
|
const target = args[0];
|
|
@@ -6,12 +7,15 @@ export async function runAuthCommand(args) {
|
|
|
6
7
|
if (!target || target === "--help" || target === "-h") {
|
|
7
8
|
console.log(`kweaver auth login <url> [options] Login to a platform (browser OAuth2 by default)
|
|
8
9
|
kweaver auth <url> Login (shorthand; same options as login)
|
|
10
|
+
kweaver auth whoami [url|alias] Show current user identity (from id_token)
|
|
9
11
|
kweaver auth export [url|alias] [--json] Export credentials; run printed command on a headless host
|
|
10
12
|
kweaver auth status [url|alias] Show current auth status
|
|
11
|
-
kweaver auth list List
|
|
13
|
+
kweaver auth list List all platforms and users (tree view)
|
|
12
14
|
kweaver auth use <url|alias> Switch active platform
|
|
13
|
-
kweaver auth
|
|
14
|
-
kweaver auth
|
|
15
|
+
kweaver auth users [url|alias] List all user profiles (with usernames) for a platform
|
|
16
|
+
kweaver auth switch [url|alias] --user <id|username> Switch active user for a platform
|
|
17
|
+
kweaver auth logout [url|alias] [--user <id>] Logout (clear local token)
|
|
18
|
+
kweaver auth delete <url|alias> [--user <id>] Delete saved credentials
|
|
15
19
|
|
|
16
20
|
Login options:
|
|
17
21
|
--alias <name> Save platform with a short alias (use with use / status / logout)
|
|
@@ -22,6 +26,10 @@ Login options:
|
|
|
22
26
|
--refresh-token <t> Use on a machine without a browser: exchange refresh token for access token.
|
|
23
27
|
Requires --client-id and --client-secret.
|
|
24
28
|
Get these from the callback page after browser login or \`auth export\`.
|
|
29
|
+
--port <n> Local callback port (default: 9010). Use when 9010 is occupied.
|
|
30
|
+
--redirect-uri <uri> Full OAuth2 redirect URI override. Localhost URIs start a local server;
|
|
31
|
+
non-localhost URIs use a manual paste-the-callback-URL flow.
|
|
32
|
+
Overrides --port. Example: http://127.0.0.1:8080/callback
|
|
25
33
|
-u, --username Username (with -p triggers Playwright headless login)
|
|
26
34
|
-p, --password Password
|
|
27
35
|
--playwright Force Playwright browser login even without -u/-p
|
|
@@ -40,10 +48,19 @@ Login options:
|
|
|
40
48
|
}
|
|
41
49
|
return runAuthCommand([url, ...rest.slice(1)]);
|
|
42
50
|
}
|
|
51
|
+
if (target === "whoami") {
|
|
52
|
+
return runAuthWhoamiCommand(rest);
|
|
53
|
+
}
|
|
43
54
|
if (target === "export") {
|
|
44
55
|
return runAuthExportCommand(rest);
|
|
45
56
|
}
|
|
46
|
-
|
|
57
|
+
if (target === "users") {
|
|
58
|
+
return runAuthUsersCommand(rest);
|
|
59
|
+
}
|
|
60
|
+
if (target === "switch") {
|
|
61
|
+
return runAuthSwitchCommand(rest);
|
|
62
|
+
}
|
|
63
|
+
const LOGIN_SUBCOMMANDS = new Set(["status", "list", "use", "delete", "logout", "export", "whoami", "users", "switch"]);
|
|
47
64
|
if (target && !LOGIN_SUBCOMMANDS.has(target)) {
|
|
48
65
|
try {
|
|
49
66
|
const normalizedTarget = normalizeBaseUrl(target);
|
|
@@ -54,7 +71,14 @@ Login options:
|
|
|
54
71
|
const clientId = readOption(args, "--client-id");
|
|
55
72
|
const clientSecret = readOption(args, "--client-secret");
|
|
56
73
|
const refreshToken = readOption(args, "--refresh-token");
|
|
74
|
+
const customRedirectUri = readOption(args, "--redirect-uri");
|
|
75
|
+
const customPortStr = readOption(args, "--port");
|
|
76
|
+
const customPort = customPortStr ? parseInt(customPortStr, 10) : undefined;
|
|
57
77
|
const tlsInsecure = args.includes("--insecure") || args.includes("-k");
|
|
78
|
+
if (customPort !== undefined && (Number.isNaN(customPort) || customPort < 1 || customPort > 65535)) {
|
|
79
|
+
console.error("Invalid --port value. Expected a number between 1 and 65535.");
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
58
82
|
let token;
|
|
59
83
|
if (refreshToken) {
|
|
60
84
|
if (!clientId || !clientSecret) {
|
|
@@ -68,17 +92,20 @@ Login options:
|
|
|
68
92
|
});
|
|
69
93
|
}
|
|
70
94
|
else if (username && password) {
|
|
71
|
-
// Headless Playwright login with credentials
|
|
72
95
|
console.log("Logging in (headless)...");
|
|
73
|
-
token = await playwrightLogin(normalizedTarget, {
|
|
96
|
+
token = await playwrightLogin(normalizedTarget, {
|
|
97
|
+
username, password, tlsInsecure,
|
|
98
|
+
port: customPort, redirectUri: customRedirectUri ?? undefined,
|
|
99
|
+
});
|
|
74
100
|
}
|
|
75
101
|
else if (usePlaywright) {
|
|
76
|
-
// Explicit Playwright fallback
|
|
77
102
|
console.log("Opening browser for login (Playwright)...");
|
|
78
|
-
token = await playwrightLogin(normalizedTarget, {
|
|
103
|
+
token = await playwrightLogin(normalizedTarget, {
|
|
104
|
+
tlsInsecure,
|
|
105
|
+
port: customPort, redirectUri: customRedirectUri ?? undefined,
|
|
106
|
+
});
|
|
79
107
|
}
|
|
80
108
|
else {
|
|
81
|
-
// Default: OAuth2 authorization code flow (supports refresh_token)
|
|
82
109
|
if (clientId) {
|
|
83
110
|
console.log(`Opening browser for OAuth2 login (client: ${clientId})...`);
|
|
84
111
|
}
|
|
@@ -89,6 +116,7 @@ Login options:
|
|
|
89
116
|
clientId: clientId ?? undefined,
|
|
90
117
|
clientSecret: clientSecret ?? undefined,
|
|
91
118
|
tlsInsecure,
|
|
119
|
+
port: customPort, redirectUri: customRedirectUri ?? undefined,
|
|
92
120
|
});
|
|
93
121
|
}
|
|
94
122
|
if (alias) {
|
|
@@ -105,6 +133,11 @@ Login options:
|
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
135
|
console.log(`Current platform: ${normalizedTarget}`);
|
|
136
|
+
const activeUser = getActiveUser(normalizedTarget);
|
|
137
|
+
if (activeUser) {
|
|
138
|
+
const userLabel = token.displayName ? `${token.displayName} (${activeUser})` : activeUser;
|
|
139
|
+
console.log(`User: ${userLabel}`);
|
|
140
|
+
}
|
|
108
141
|
console.log(`Access token saved: yes`);
|
|
109
142
|
if (token.refreshToken) {
|
|
110
143
|
console.log(`Refresh token: yes (auto-refresh enabled)`);
|
|
@@ -144,8 +177,14 @@ Login options:
|
|
|
144
177
|
`Config directory: ${getConfigDir()}`,
|
|
145
178
|
`Platform: ${token.baseUrl}`,
|
|
146
179
|
`Current platform: ${token.baseUrl === currentPlatform ? "yes" : "no"}`,
|
|
147
|
-
`Token present: yes`,
|
|
148
180
|
];
|
|
181
|
+
const statusActiveUser = getActiveUser(platform);
|
|
182
|
+
if (statusActiveUser) {
|
|
183
|
+
const statusDisplayName = token.displayName;
|
|
184
|
+
const userLabel = statusDisplayName ? `${statusDisplayName} (${statusActiveUser})` : statusActiveUser;
|
|
185
|
+
lines.push(`User: ${userLabel}`);
|
|
186
|
+
}
|
|
187
|
+
lines.push(`Token present: yes`);
|
|
149
188
|
lines.push(`Refresh token: ${token.refreshToken ? "yes (auto-refresh enabled)" : "no"}`);
|
|
150
189
|
if (token.tlsInsecure) {
|
|
151
190
|
lines.push(`TLS: certificate verification disabled (saved; dev only)`);
|
|
@@ -179,8 +218,18 @@ Login options:
|
|
|
179
218
|
console.log(`Config directory: ${getConfigDir()}`);
|
|
180
219
|
for (const platform of platforms) {
|
|
181
220
|
const marker = platform.baseUrl === currentPlatform ? "*" : "-";
|
|
182
|
-
const aliasPart = platform.alias ? `
|
|
183
|
-
console.log(`${marker} ${platform.baseUrl}${aliasPart}
|
|
221
|
+
const aliasPart = platform.alias ? ` (${platform.alias})` : "";
|
|
222
|
+
console.log(`${marker} ${platform.baseUrl}${aliasPart}`);
|
|
223
|
+
const profiles = listUserProfiles(platform.baseUrl);
|
|
224
|
+
const activeUser = getActiveUser(platform.baseUrl);
|
|
225
|
+
for (let i = 0; i < profiles.length; i++) {
|
|
226
|
+
const p = profiles[i];
|
|
227
|
+
const isLast = i === profiles.length - 1;
|
|
228
|
+
const branch = isLast ? "└──" : "├──";
|
|
229
|
+
const activeMarker = p.userId === activeUser ? " *" : "";
|
|
230
|
+
const label = p.username ? `${p.username} (${p.userId})` : p.userId;
|
|
231
|
+
console.log(` ${branch} ${label}${activeMarker}`);
|
|
232
|
+
}
|
|
184
233
|
}
|
|
185
234
|
return 0;
|
|
186
235
|
}
|
|
@@ -200,16 +249,24 @@ Login options:
|
|
|
200
249
|
return 0;
|
|
201
250
|
}
|
|
202
251
|
if (target === "delete") {
|
|
203
|
-
const
|
|
252
|
+
const deleteUserArg = readOption(args, "--user");
|
|
253
|
+
const positionalArgs = args.slice(1).filter((a) => a !== "--user" && a !== deleteUserArg);
|
|
254
|
+
const resolvedTarget = positionalArgs[0] ? resolvePlatformIdentifier(positionalArgs[0]) : "";
|
|
204
255
|
const deleteTarget = resolvedTarget && /^https?:\/\//.test(resolvedTarget) ? normalizeBaseUrl(resolvedTarget) : resolvedTarget;
|
|
205
256
|
if (!deleteTarget) {
|
|
206
|
-
console.error("Usage: kweaver auth delete <platform-url|alias>");
|
|
257
|
+
console.error("Usage: kweaver auth delete <platform-url|alias> [--user <userId|username>]");
|
|
207
258
|
return 1;
|
|
208
259
|
}
|
|
209
260
|
if (!hasPlatform(deleteTarget)) {
|
|
210
261
|
console.error(`No saved token for ${deleteTarget}.`);
|
|
211
262
|
return 1;
|
|
212
263
|
}
|
|
264
|
+
if (deleteUserArg) {
|
|
265
|
+
const deleteUserId = resolveUserId(deleteTarget, deleteUserArg) ?? deleteUserArg;
|
|
266
|
+
deleteUser(deleteTarget, deleteUserId);
|
|
267
|
+
console.log(`Deleted user ${deleteUserId} from ${deleteTarget}`);
|
|
268
|
+
return 0;
|
|
269
|
+
}
|
|
213
270
|
const wasCurrent = getCurrentPlatform() === deleteTarget;
|
|
214
271
|
deletePlatform(deleteTarget);
|
|
215
272
|
console.log(`Deleted platform: ${deleteTarget}`);
|
|
@@ -220,10 +277,12 @@ Login options:
|
|
|
220
277
|
return 0;
|
|
221
278
|
}
|
|
222
279
|
if (target === "logout") {
|
|
223
|
-
const
|
|
280
|
+
const logoutUserArg = readOption(args, "--user");
|
|
281
|
+
const positionalArgs = args.slice(1).filter((a) => a !== "--user" && a !== logoutUserArg);
|
|
282
|
+
const resolvedTarget = positionalArgs[0] ? resolvePlatformIdentifier(positionalArgs[0]) : getCurrentPlatform();
|
|
224
283
|
const logoutTarget = resolvedTarget && /^https?:\/\//.test(resolvedTarget) ? normalizeBaseUrl(resolvedTarget) : resolvedTarget;
|
|
225
284
|
if (!logoutTarget) {
|
|
226
|
-
console.error("Usage: kweaver auth logout [platform-url|alias]");
|
|
285
|
+
console.error("Usage: kweaver auth logout [platform-url|alias] [--user <userId|username>]");
|
|
227
286
|
console.error("No current platform. Specify a platform to logout.");
|
|
228
287
|
return 1;
|
|
229
288
|
}
|
|
@@ -231,20 +290,151 @@ Login options:
|
|
|
231
290
|
console.error(`No saved token for ${logoutTarget}.`);
|
|
232
291
|
return 1;
|
|
233
292
|
}
|
|
234
|
-
|
|
235
|
-
|
|
293
|
+
const logoutUserId = logoutUserArg ? resolveUserId(logoutTarget, logoutUserArg) ?? logoutUserArg : undefined;
|
|
294
|
+
clearPlatformSession(logoutTarget, logoutUserId);
|
|
295
|
+
const userHint = logoutUserId ? ` (user: ${logoutUserId})` : "";
|
|
296
|
+
console.log(`Logged out: ${logoutTarget}${userHint}`);
|
|
236
297
|
console.log(`Run \`kweaver auth login ${logoutTarget}\` to sign in again.`);
|
|
237
298
|
return 0;
|
|
238
299
|
}
|
|
239
300
|
console.error("Usage: kweaver auth login <platform-url> [--alias <name>] [-u user] [-p pass] [--playwright]");
|
|
301
|
+
console.error(" kweaver auth whoami [platform-url|alias]");
|
|
240
302
|
console.error(" kweaver auth export [platform-url|alias] [--json]");
|
|
241
303
|
console.error(" kweaver auth status [platform-url|alias]");
|
|
242
304
|
console.error(" kweaver auth list");
|
|
243
305
|
console.error(" kweaver auth use <platform-url|alias>");
|
|
244
|
-
console.error(" kweaver auth
|
|
245
|
-
console.error(" kweaver auth
|
|
306
|
+
console.error(" kweaver auth users [platform-url|alias]");
|
|
307
|
+
console.error(" kweaver auth switch [platform-url|alias] --user <userId>");
|
|
308
|
+
console.error(" kweaver auth logout [platform-url|alias] [--user <userId>]");
|
|
309
|
+
console.error(" kweaver auth delete <platform-url|alias> [--user <userId>]");
|
|
246
310
|
return 1;
|
|
247
311
|
}
|
|
312
|
+
function resolvePlatformArg(args) {
|
|
313
|
+
const positional = args.find((a) => !a.startsWith("-"));
|
|
314
|
+
const resolved = positional ? resolvePlatformIdentifier(positional) : null;
|
|
315
|
+
if (resolved && /^https?:\/\//.test(resolved))
|
|
316
|
+
return normalizeBaseUrl(resolved);
|
|
317
|
+
return resolved ?? getCurrentPlatform();
|
|
318
|
+
}
|
|
319
|
+
function runAuthUsersCommand(args) {
|
|
320
|
+
if (args[0] === "--help" || args[0] === "-h") {
|
|
321
|
+
console.log(`kweaver auth users [platform-url|alias]
|
|
322
|
+
|
|
323
|
+
List all user profiles stored for a platform.
|
|
324
|
+
Each line shows: userId (username) where username is decoded from the id_token.
|
|
325
|
+
You can use either userId or username with --user in switch/logout/delete.`);
|
|
326
|
+
return 0;
|
|
327
|
+
}
|
|
328
|
+
const platform = resolvePlatformArg(args);
|
|
329
|
+
if (!platform) {
|
|
330
|
+
console.error("No active platform. Run `kweaver auth login <platform-url>` first.");
|
|
331
|
+
return 1;
|
|
332
|
+
}
|
|
333
|
+
const profiles = listUserProfiles(platform);
|
|
334
|
+
if (profiles.length === 0) {
|
|
335
|
+
console.error(`No user profiles for ${platform}.`);
|
|
336
|
+
return 1;
|
|
337
|
+
}
|
|
338
|
+
const active = getActiveUser(platform);
|
|
339
|
+
console.log(`Platform: ${platform}`);
|
|
340
|
+
for (const p of profiles) {
|
|
341
|
+
const marker = p.userId === active ? "*" : "-";
|
|
342
|
+
const displayName = p.username ? ` (${p.username})` : "";
|
|
343
|
+
console.log(`${marker} ${p.userId}${displayName}`);
|
|
344
|
+
}
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
function runAuthSwitchCommand(args) {
|
|
348
|
+
if (args[0] === "--help" || args[0] === "-h") {
|
|
349
|
+
console.log(`kweaver auth switch [platform-url|alias] --user <userId|username>
|
|
350
|
+
|
|
351
|
+
Switch the active user for a platform.
|
|
352
|
+
You can specify either the userId (sub claim) or the username (preferred_username from id_token).`);
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
const userArg = readOption(args, "--user");
|
|
356
|
+
if (!userArg) {
|
|
357
|
+
console.error("Usage: kweaver auth switch [platform-url|alias] --user <userId|username>");
|
|
358
|
+
return 1;
|
|
359
|
+
}
|
|
360
|
+
const filteredArgs = args.filter((a) => a !== "--user" && a !== userArg);
|
|
361
|
+
const platform = resolvePlatformArg(filteredArgs);
|
|
362
|
+
if (!platform) {
|
|
363
|
+
console.error("No active platform. Run `kweaver auth login <platform-url>` first.");
|
|
364
|
+
return 1;
|
|
365
|
+
}
|
|
366
|
+
const resolvedId = resolveUserId(platform, userArg);
|
|
367
|
+
if (!resolvedId) {
|
|
368
|
+
console.error(`User '${userArg}' not found for ${platform}.`);
|
|
369
|
+
const profiles = listUserProfiles(platform);
|
|
370
|
+
if (profiles.length > 0) {
|
|
371
|
+
const hints = profiles.map((p) => p.username ? `${p.userId} (${p.username})` : p.userId);
|
|
372
|
+
console.error(`Available users: ${hints.join(", ")}`);
|
|
373
|
+
}
|
|
374
|
+
return 1;
|
|
375
|
+
}
|
|
376
|
+
setActiveUser(platform, resolvedId);
|
|
377
|
+
const profiles = listUserProfiles(platform);
|
|
378
|
+
const profile = profiles.find((p) => p.userId === resolvedId);
|
|
379
|
+
const displayName = profile?.username ? ` (${profile.username})` : "";
|
|
380
|
+
console.log(`Switched to user ${resolvedId}${displayName} on ${platform}`);
|
|
381
|
+
return 0;
|
|
382
|
+
}
|
|
383
|
+
function runAuthWhoamiCommand(args) {
|
|
384
|
+
if (args[0] === "--help" || args[0] === "-h") {
|
|
385
|
+
console.log(`kweaver auth whoami [platform-url|alias] [--json]
|
|
386
|
+
|
|
387
|
+
Show current user identity decoded from the saved id_token.
|
|
388
|
+
|
|
389
|
+
Options:
|
|
390
|
+
--json Output as JSON (machine-readable)`);
|
|
391
|
+
return 0;
|
|
392
|
+
}
|
|
393
|
+
const jsonOutput = args.includes("--json");
|
|
394
|
+
const positional = args.find((a) => !a.startsWith("-"));
|
|
395
|
+
const resolved = positional ? resolvePlatformIdentifier(positional) : null;
|
|
396
|
+
const platform = resolved && /^https?:\/\//.test(resolved) ? normalizeBaseUrl(resolved) : resolved ?? getCurrentPlatform();
|
|
397
|
+
if (!platform) {
|
|
398
|
+
console.error("No active platform. Run `kweaver auth login <platform-url>` first.");
|
|
399
|
+
return 1;
|
|
400
|
+
}
|
|
401
|
+
const token = loadTokenConfig(platform);
|
|
402
|
+
if (!token) {
|
|
403
|
+
console.error(`No saved token for ${platform}.`);
|
|
404
|
+
return 1;
|
|
405
|
+
}
|
|
406
|
+
if (!token.idToken) {
|
|
407
|
+
console.error(`No id_token saved for ${platform}. Re-login to obtain one.`);
|
|
408
|
+
return 1;
|
|
409
|
+
}
|
|
410
|
+
const payload = decodeJwtPayload(token.idToken);
|
|
411
|
+
if (!payload) {
|
|
412
|
+
console.error("Failed to decode id_token.");
|
|
413
|
+
return 1;
|
|
414
|
+
}
|
|
415
|
+
const displayNameValue = token.displayName ?? null;
|
|
416
|
+
if (jsonOutput) {
|
|
417
|
+
const out = { platform, ...payload };
|
|
418
|
+
if (displayNameValue)
|
|
419
|
+
out.displayName = displayNameValue;
|
|
420
|
+
console.log(JSON.stringify(out, null, 2));
|
|
421
|
+
return 0;
|
|
422
|
+
}
|
|
423
|
+
console.log(`Platform: ${platform}`);
|
|
424
|
+
if (displayNameValue)
|
|
425
|
+
console.log(`Username: ${displayNameValue}`);
|
|
426
|
+
console.log(`User ID: ${payload.sub ?? "(unknown)"}`);
|
|
427
|
+
console.log(`Issuer: ${payload.iss ?? "(unknown)"}`);
|
|
428
|
+
if (payload.sid)
|
|
429
|
+
console.log(`Session: ${payload.sid}`);
|
|
430
|
+
if (payload.iat) {
|
|
431
|
+
console.log(`Issued: ${new Date(payload.iat * 1000).toISOString()}`);
|
|
432
|
+
}
|
|
433
|
+
if (payload.exp) {
|
|
434
|
+
console.log(`Expires: ${new Date(payload.exp * 1000).toISOString()}`);
|
|
435
|
+
}
|
|
436
|
+
return 0;
|
|
437
|
+
}
|
|
248
438
|
async function runAuthExportCommand(args) {
|
|
249
439
|
if (args[0] === "--help" || args[0] === "-h") {
|
|
250
440
|
console.log(`kweaver auth export [platform-url|alias] [--json]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type BknEncodingImportOptions } from "../utils/bkn-encoding.js";
|
|
2
|
+
export declare function parseKnBuildArgs(args: string[]): {
|
|
3
|
+
knId: string;
|
|
4
|
+
wait: boolean;
|
|
5
|
+
timeout: number;
|
|
6
|
+
businessDomain: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function runKnBuildCommand(args: string[]): Promise<number>;
|
|
9
|
+
export declare function runKnValidateCommand(args: string[]): Promise<number>;
|
|
10
|
+
export interface KnPushOptions {
|
|
11
|
+
directory: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
businessDomain: string;
|
|
14
|
+
pretty: boolean;
|
|
15
|
+
encodingOptions: BknEncodingImportOptions;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseKnPushArgs(args: string[]): KnPushOptions;
|
|
18
|
+
export interface KnPullOptions {
|
|
19
|
+
knId: string;
|
|
20
|
+
directory: string;
|
|
21
|
+
branch: string;
|
|
22
|
+
businessDomain: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function parseKnPullArgs(args: string[]): KnPullOptions;
|
|
25
|
+
export declare function packDirectoryToTar(dirPath: string): Buffer;
|
|
26
|
+
export declare function extractTarToDirectory(tarBuffer: Buffer, dirPath: string): void;
|
|
27
|
+
export declare function runKnPushCommand(args: string[]): Promise<number>;
|
|
28
|
+
export declare function runKnPullCommand(args: string[]): Promise<number>;
|
|
29
|
+
export declare function parseKnCreateFromDsArgs(args: string[]): {
|
|
30
|
+
dsId: string;
|
|
31
|
+
name: string;
|
|
32
|
+
tables: string[];
|
|
33
|
+
build: boolean;
|
|
34
|
+
timeout: number;
|
|
35
|
+
businessDomain: string;
|
|
36
|
+
pretty: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** Generate a BKN ObjectType YAML markdown file for a table. */
|
|
39
|
+
export declare function generateObjectTypeBkn(tableName: string, dvId: string, pk: string, dk: string, columns: Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
}>): string;
|
|
43
|
+
export declare function runKnCreateFromDsCommand(args: string[], sampleRows?: Record<string, Array<Record<string, string | null>>>): Promise<number>;
|
|
44
|
+
export declare function parseKnCreateFromCsvArgs(args: string[]): {
|
|
45
|
+
dsId: string;
|
|
46
|
+
files: string;
|
|
47
|
+
name: string;
|
|
48
|
+
tablePrefix: string;
|
|
49
|
+
batchSize: number;
|
|
50
|
+
tables: string[];
|
|
51
|
+
build: boolean;
|
|
52
|
+
timeout: number;
|
|
53
|
+
businessDomain: string;
|
|
54
|
+
};
|
|
55
|
+
export declare function runKnCreateFromCsvCommand(args: string[]): Promise<number>;
|
|
56
|
+
export interface ActionScheduleParsed {
|
|
57
|
+
action: string;
|
|
58
|
+
knId: string;
|
|
59
|
+
itemId: string;
|
|
60
|
+
body: string;
|
|
61
|
+
extra: string;
|
|
62
|
+
yes: boolean;
|
|
63
|
+
pretty: boolean;
|
|
64
|
+
businessDomain: string;
|
|
65
|
+
}
|
|
66
|
+
export declare function parseActionScheduleArgs(args: string[]): ActionScheduleParsed;
|
|
67
|
+
export declare function runKnActionScheduleCommand(args: string[]): Promise<number>;
|
|
68
|
+
export interface JobParsed {
|
|
69
|
+
action: string;
|
|
70
|
+
knId: string;
|
|
71
|
+
itemId: string;
|
|
72
|
+
yes: boolean;
|
|
73
|
+
pretty: boolean;
|
|
74
|
+
businessDomain: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function parseJobArgs(args: string[]): JobParsed;
|
|
77
|
+
export declare function runKnJobCommand(args: string[]): Promise<number>;
|