@openbkn/bkn-sdk 0.1.1-alpha.15 → 0.1.1-alpha.18
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/LICENSE +117 -34
- package/NOTICE +31 -0
- package/README.md +3 -2
- package/README.zh.md +3 -3
- package/dist/{chunk-KF3J46WL.js → chunk-LCOMMFH7.js} +295 -47
- package/dist/chunk-LCOMMFH7.js.map +1 -0
- package/dist/cli.js +185 -34
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +240 -35
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-KF3J46WL.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
use,
|
|
38
38
|
whoami,
|
|
39
39
|
writePlatformConfig
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-LCOMMFH7.js";
|
|
41
41
|
|
|
42
42
|
// src/cli.ts
|
|
43
43
|
import { Command as Command17 } from "commander";
|
|
@@ -45,7 +45,7 @@ import { Command as Command17 } from "commander";
|
|
|
45
45
|
// package.json
|
|
46
46
|
var package_default = {
|
|
47
47
|
name: "@openbkn/bkn-sdk",
|
|
48
|
-
version: "0.1.1-alpha.
|
|
48
|
+
version: "0.1.1-alpha.18",
|
|
49
49
|
description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
50
50
|
type: "module",
|
|
51
51
|
license: "SEE LICENSE IN LICENSE",
|
|
@@ -63,7 +63,7 @@ var package_default = {
|
|
|
63
63
|
import: "./dist/index.js"
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
files: ["dist", "README.md", "README.zh.md", "LICENSE"],
|
|
66
|
+
files: ["dist", "README.md", "README.zh.md", "LICENSE", "NOTICE"],
|
|
67
67
|
publishConfig: {
|
|
68
68
|
access: "public"
|
|
69
69
|
},
|
|
@@ -104,6 +104,7 @@ var package_default = {
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
// src/commands/admin.ts
|
|
107
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
107
108
|
import { Command as Command2 } from "commander";
|
|
108
109
|
|
|
109
110
|
// src/help/grouped-help.ts
|
|
@@ -626,6 +627,12 @@ function authCommand() {
|
|
|
626
627
|
// src/commands/admin.ts
|
|
627
628
|
var int = (v) => Number.parseInt(v, 10);
|
|
628
629
|
var DEFAULT_RESET_PASSWORD = "openbkn";
|
|
630
|
+
async function importLicenseFile(cmd, file, receipt) {
|
|
631
|
+
const text = readFileSync2(file, "utf8");
|
|
632
|
+
const res = await clientFrom(cmd).admin.licenseImport(text, { receipt });
|
|
633
|
+
printJson(res, outputOptions(cmd));
|
|
634
|
+
if ("stored" in res && res.stored) process.exitCode = 1;
|
|
635
|
+
}
|
|
629
636
|
function adminCommand() {
|
|
630
637
|
const admin = new Command2("admin").description("Operator CLI: org, user, role, models, audit");
|
|
631
638
|
registerAuthLeaves(admin.command("auth").description("Operator authentication"));
|
|
@@ -911,6 +918,27 @@ function adminCommand() {
|
|
|
911
918
|
);
|
|
912
919
|
});
|
|
913
920
|
}
|
|
921
|
+
const license = admin.command("license").description("Cluster license management");
|
|
922
|
+
license.command("show").description("Current license detail (state/edition/expiry/features)").action(async (_opts, cmd) => {
|
|
923
|
+
printJson(await clientFrom(cmd).admin.licenseGet(), outputOptions(cmd));
|
|
924
|
+
});
|
|
925
|
+
license.command("import <file>").description("Import a .lic license file (online deployments auto-activate)").action(async (file, _opts, cmd) => {
|
|
926
|
+
await importLicenseFile(cmd, file, false);
|
|
927
|
+
});
|
|
928
|
+
license.command("receipt <file>").description("Import an offline activation receipt (.lic from the license portal)").action(async (file, _opts, cmd) => {
|
|
929
|
+
await importLicenseFile(cmd, file, true);
|
|
930
|
+
});
|
|
931
|
+
license.command("activate").description("Report the installed license to the issuer (online deployments)").action(async (_opts, cmd) => {
|
|
932
|
+
printJson(await clientFrom(cmd).admin.licenseActivate(), outputOptions(cmd));
|
|
933
|
+
});
|
|
934
|
+
license.command("remove").description("Remove the installed license (back to unactivated)").action(async (_opts, cmd) => {
|
|
935
|
+
printJson(await clientFrom(cmd).admin.licenseRemove(), outputOptions(cmd));
|
|
936
|
+
});
|
|
937
|
+
license.command("fingerprint").description(
|
|
938
|
+
"This cluster's machine code (paste into the license portal for offline activation)"
|
|
939
|
+
).action(async (_opts, cmd) => {
|
|
940
|
+
printJson(await clientFrom(cmd).admin.licenseFingerprint(), outputOptions(cmd));
|
|
941
|
+
});
|
|
914
942
|
admin.command("audit").description("Audit log queries").command("list").description("List login audit events").option("--user <name>", "filter by user").option("--start <time>", "start time").option("--end <time>", "end time").option("--page <n>", "page", int, 1).option("--size <n>", "page size", int, 30).action(async (opts, cmd) => {
|
|
915
943
|
printJson(
|
|
916
944
|
await clientFrom(cmd).admin.auditList({
|
|
@@ -1151,7 +1179,7 @@ function appkeyCommand() {
|
|
|
1151
1179
|
import { Command as Command5 } from "commander";
|
|
1152
1180
|
|
|
1153
1181
|
// src/utils/bkn-validate.ts
|
|
1154
|
-
import { existsSync, readFileSync as
|
|
1182
|
+
import { existsSync, readFileSync as readFileSync3, readdirSync, statSync } from "fs";
|
|
1155
1183
|
import { join, resolve } from "path";
|
|
1156
1184
|
var BKN_OBJECT_NAME_MAX_LENGTH = 40;
|
|
1157
1185
|
function parseFrontmatter(text) {
|
|
@@ -1204,7 +1232,7 @@ function validateBknDirectory(dirPath) {
|
|
|
1204
1232
|
if (!existsSync(networkPath)) {
|
|
1205
1233
|
errors.push("Missing network.bkn at the BKN root.");
|
|
1206
1234
|
} else {
|
|
1207
|
-
const fm = parseFrontmatter(
|
|
1235
|
+
const fm = parseFrontmatter(readFileSync3(networkPath, "utf8"));
|
|
1208
1236
|
if (!fm) errors.push("network.bkn has no frontmatter block.");
|
|
1209
1237
|
else {
|
|
1210
1238
|
if (fm.type !== "knowledge_network")
|
|
@@ -1216,7 +1244,7 @@ function validateBknDirectory(dirPath) {
|
|
|
1216
1244
|
const otIds = /* @__PURE__ */ new Set();
|
|
1217
1245
|
const otFiles = bknFiles(join(dir, "object_types"));
|
|
1218
1246
|
for (const file of otFiles) {
|
|
1219
|
-
const fm = parseFrontmatter(
|
|
1247
|
+
const fm = parseFrontmatter(readFileSync3(file, "utf8"));
|
|
1220
1248
|
const rel = file.slice(dir.length + 1);
|
|
1221
1249
|
if (!fm || fm.type !== "object_type") {
|
|
1222
1250
|
errors.push(`${rel}: not a valid object_type (missing/wrong frontmatter type).`);
|
|
@@ -1236,7 +1264,7 @@ function validateBknDirectory(dirPath) {
|
|
|
1236
1264
|
}
|
|
1237
1265
|
const rtFiles = bknFiles(join(dir, "relation_types"));
|
|
1238
1266
|
for (const file of rtFiles) {
|
|
1239
|
-
const text =
|
|
1267
|
+
const text = readFileSync3(file, "utf8");
|
|
1240
1268
|
const fm = parseFrontmatter(text);
|
|
1241
1269
|
const rel = file.slice(dir.length + 1);
|
|
1242
1270
|
if (!fm || fm.type !== "relation_type") {
|
|
@@ -1735,6 +1763,16 @@ function contextCommand() {
|
|
|
1735
1763
|
outputOptions(cmd2)
|
|
1736
1764
|
);
|
|
1737
1765
|
});
|
|
1766
|
+
cmd.command("kn-detail <kn-id>").description("Get a KN's schema at a detail level (progressive: summary skeleton \u2192 drill down)").option("--detail-level <level>", "summary (default) | full", "summary").action(async (knId, opts, cmd2) => {
|
|
1767
|
+
const level = opts.detailLevel === "full" ? "full" : "summary";
|
|
1768
|
+
printJson(await clientFrom(cmd2).context.knDetail(knId, level), outputOptions(cmd2));
|
|
1769
|
+
});
|
|
1770
|
+
cmd.command("object-types <kn-id> <ids...>").description("Full definitions for the given object-type ids (unmatched \u2192 `missing`)").action(async (knId, ids, _opts, cmd2) => {
|
|
1771
|
+
printJson(await clientFrom(cmd2).context.objectTypes(knId, ids), outputOptions(cmd2));
|
|
1772
|
+
});
|
|
1773
|
+
cmd.command("relation-types <kn-id> <ids...>").description("Full definitions for the given relation-type ids (unmatched \u2192 `missing`)").action(async (knId, ids, _opts, cmd2) => {
|
|
1774
|
+
printJson(await clientFrom(cmd2).context.relationTypes(knId, ids), outputOptions(cmd2));
|
|
1775
|
+
});
|
|
1738
1776
|
cmd.command("info").description("List the deploy's MCP tool catalog (global \u2014 no KN needed)").action(async (_opts, cmd2) => {
|
|
1739
1777
|
printToolList(await clientFrom(cmd2).context.info(), outputOptions(cmd2));
|
|
1740
1778
|
});
|
|
@@ -2096,13 +2134,29 @@ Examples:
|
|
|
2096
2134
|
// src/commands/resource.ts
|
|
2097
2135
|
import { Command as Command12 } from "commander";
|
|
2098
2136
|
var int9 = (v) => Number.parseInt(v, 10);
|
|
2137
|
+
var parsePairs = (raw) => {
|
|
2138
|
+
if (!raw) return void 0;
|
|
2139
|
+
return raw.split(",").map((part) => {
|
|
2140
|
+
const idx = part.indexOf("=");
|
|
2141
|
+
if (idx < 1) throw new Error("--extension must be key=value[,key=value]");
|
|
2142
|
+
return { key: part.slice(0, idx).trim(), value: part.slice(idx + 1).trim() };
|
|
2143
|
+
}).filter((p) => p.key.length > 0);
|
|
2144
|
+
};
|
|
2099
2145
|
function resourceCommand() {
|
|
2100
2146
|
const cmd = new Command12("resource").alias("res").description("Resources \u2014 list, find, get, query, delete");
|
|
2101
|
-
cmd.command("list").description("List resources under a catalog").option("--catalog-id <id>", "filter by catalog id").option("--datasource-id <id>", "alias of --catalog-id").option("--category <c>", "resource category (table | logicview | dataset)").option("--type <c>", "alias of --category").option("--limit <n>", "page size", int9, DEFAULT_LIST_LIMIT).action(async (opts, cmd2) => {
|
|
2147
|
+
cmd.command("list").description("List resources under a catalog").option("--catalog-id <id>", "filter by catalog id").option("--datasource-id <id>", "alias of --catalog-id").option("--category <c>", "resource category (table | logicview | dataset)").option("--type <c>", "alias of --category").option("--status <status>", "filter by status").option("--database <name>", "filter by database").option("--limit <n>", "page size", int9, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int9, 0).option("--include-extensions", "include all extension key/value pairs").option("--include-extension-keys <keys>", "include selected extension keys").option("--extension <k=v,...>", "filter by extension key/value pairs").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (opts, cmd2) => {
|
|
2102
2148
|
const data = await clientFrom(cmd2).resource.list({
|
|
2103
2149
|
datasourceId: opts.catalogId ?? opts.datasourceId,
|
|
2104
2150
|
category: opts.category ?? opts.type,
|
|
2105
|
-
|
|
2151
|
+
status: opts.status,
|
|
2152
|
+
database: opts.database,
|
|
2153
|
+
limit: opts.limit,
|
|
2154
|
+
offset: opts.offset,
|
|
2155
|
+
includeExtensions: opts.includeExtensions,
|
|
2156
|
+
includeExtensionKeys: opts.includeExtensionKeys,
|
|
2157
|
+
extensionPairs: parsePairs(opts.extension),
|
|
2158
|
+
sort: opts.sort,
|
|
2159
|
+
direction: opts.direction
|
|
2106
2160
|
});
|
|
2107
2161
|
printJson(data, outputOptions(cmd2));
|
|
2108
2162
|
});
|
|
@@ -2324,11 +2378,11 @@ function toolCommand() {
|
|
|
2324
2378
|
}
|
|
2325
2379
|
|
|
2326
2380
|
// src/commands/trace.ts
|
|
2327
|
-
import { readFileSync as
|
|
2381
|
+
import { readFileSync as readFileSync5, writeFileSync } from "fs";
|
|
2328
2382
|
import { Command as Command15 } from "commander";
|
|
2329
2383
|
|
|
2330
|
-
// src/trace
|
|
2331
|
-
import { readFileSync as
|
|
2384
|
+
// src/bkn-trace/schema-validate.ts
|
|
2385
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
2332
2386
|
import { extname } from "path";
|
|
2333
2387
|
import yaml from "js-yaml";
|
|
2334
2388
|
import { z } from "zod";
|
|
@@ -2365,7 +2419,7 @@ var DiagnosisRule = z.object({
|
|
|
2365
2419
|
params: z.record(z.string(), z.unknown()).optional()
|
|
2366
2420
|
});
|
|
2367
2421
|
function parseFile(file) {
|
|
2368
|
-
const text =
|
|
2422
|
+
const text = readFileSync4(file, "utf8");
|
|
2369
2423
|
const ext = extname(file).toLowerCase();
|
|
2370
2424
|
if (ext === ".yaml" || ext === ".yml") return yaml.load(text);
|
|
2371
2425
|
return JSON.parse(text);
|
|
@@ -2404,7 +2458,7 @@ function validateSchemaFile(file, kind) {
|
|
|
2404
2458
|
// src/commands/trace.ts
|
|
2405
2459
|
function traceCommand() {
|
|
2406
2460
|
const cmd = new Command15("trace").description(
|
|
2407
|
-
"Trace
|
|
2461
|
+
"BKN Trace \u2014 fetch spans, diagnose (symbolic + LLM rubric), scan, eval-set, schema validate"
|
|
2408
2462
|
);
|
|
2409
2463
|
cmd.command("get <conversation-id>").description("Fetch all trace spans for a conversation").option("--max-spans <n>", "max spans", (v) => Number.parseInt(v, 10)).action(async (conversationId, opts, cmd2) => {
|
|
2410
2464
|
printJson(
|
|
@@ -2432,7 +2486,7 @@ function traceCommand() {
|
|
|
2432
2486
|
});
|
|
2433
2487
|
const evalSet = cmd.command("eval-set").description("Build + run trace eval sets");
|
|
2434
2488
|
evalSet.command("build <queries-file>").description("Build eval cases from a queries JSON file").option("--out <file>", "write the cases JSON here (default: stdout)").action(async (queriesFile, opts, cmd2) => {
|
|
2435
|
-
const raw = JSON.parse(
|
|
2489
|
+
const raw = JSON.parse(readFileSync5(queriesFile, "utf8"));
|
|
2436
2490
|
const cases = clientFrom(cmd2).trace.evalSetBuild(raw);
|
|
2437
2491
|
if (opts.out) {
|
|
2438
2492
|
writeFileSync(opts.out, JSON.stringify({ cases }, null, 2));
|
|
@@ -2442,7 +2496,7 @@ function traceCommand() {
|
|
|
2442
2496
|
}
|
|
2443
2497
|
});
|
|
2444
2498
|
evalSet.command("test <cases-file>").description("Run an eval set against an agent (--llm enables semantic_match)").requiredOption("--agent <id>", "agent id to run the queries against").option("--version <v>", "agent version", "v0").option("--llm", "enable semantic_match assertions via the local `claude` CLI").action(async (casesFile, opts, cmd2) => {
|
|
2445
|
-
const raw = JSON.parse(
|
|
2499
|
+
const raw = JSON.parse(readFileSync5(casesFile, "utf8"));
|
|
2446
2500
|
const cases = clientFrom(cmd2).trace.evalSetBuild(raw);
|
|
2447
2501
|
const result = await clientFrom(cmd2).trace.evalSetTest(opts.agent, cases, {
|
|
2448
2502
|
version: opts.version,
|
|
@@ -2463,14 +2517,35 @@ function traceCommand() {
|
|
|
2463
2517
|
// src/commands/vega.ts
|
|
2464
2518
|
import { Command as Command16 } from "commander";
|
|
2465
2519
|
var int12 = (v) => Number.parseInt(v, 10);
|
|
2520
|
+
var parsePairs2 = (raw) => {
|
|
2521
|
+
if (!raw) return void 0;
|
|
2522
|
+
return raw.split(",").map((part) => {
|
|
2523
|
+
const idx = part.indexOf("=");
|
|
2524
|
+
if (idx < 1) throw new InputError("--extension must be key=value[,key=value]");
|
|
2525
|
+
return { key: part.slice(0, idx).trim(), value: part.slice(idx + 1).trim() };
|
|
2526
|
+
}).filter((p) => p.key.length > 0);
|
|
2527
|
+
};
|
|
2466
2528
|
function vegaCommand() {
|
|
2467
2529
|
const vega = new Command16("vega").description(
|
|
2468
2530
|
"Vega observability \u2014 catalog, resources, index build tasks"
|
|
2469
2531
|
);
|
|
2470
2532
|
const catalog = vega.command("catalog").description("Catalog entries");
|
|
2471
|
-
catalog.command("list").description("List catalog entries").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", (v) => Number.parseInt(v, 10), 0).action(async (_opts, cmd) => {
|
|
2533
|
+
catalog.command("list").description("List catalog entries").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", (v) => Number.parseInt(v, 10), 0).option("--name <s>", "filter by name").option("--tag <s>", "filter by tag").option("--type <type>", "filter by catalog type: physical | logical").option("--enabled <bool>", "filter by enabled state").option("--health-check-status <s>", "filter by health status").option("--include-extensions", "include all extension key/value pairs").option("--include-extension-keys <keys>", "include selected extension keys").option("--extension <k=v,...>", "filter by extension key/value pairs").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (_opts, cmd) => {
|
|
2472
2534
|
const o = cmd.optsWithGlobals();
|
|
2473
|
-
const data = await clientFrom(cmd).vega.catalogs({
|
|
2535
|
+
const data = await clientFrom(cmd).vega.catalogs({
|
|
2536
|
+
limit: o.limit,
|
|
2537
|
+
offset: o.offset,
|
|
2538
|
+
name: o.name,
|
|
2539
|
+
tag: o.tag,
|
|
2540
|
+
type: o.type,
|
|
2541
|
+
enabled: o.enabled === void 0 ? void 0 : o.enabled === "true",
|
|
2542
|
+
healthCheckStatus: o.healthCheckStatus,
|
|
2543
|
+
includeExtensions: o.includeExtensions,
|
|
2544
|
+
includeExtensionKeys: o.includeExtensionKeys,
|
|
2545
|
+
extensionPairs: parsePairs2(o.extension),
|
|
2546
|
+
sort: o.sort,
|
|
2547
|
+
direction: o.direction
|
|
2548
|
+
});
|
|
2474
2549
|
printJson(data, outputOptions(cmd));
|
|
2475
2550
|
});
|
|
2476
2551
|
catalog.command("get <id>").description("Get a catalog by id").action(async (id, _opts, cmd) => {
|
|
@@ -2482,21 +2557,41 @@ function vegaCommand() {
|
|
|
2482
2557
|
catalog.command("health <ids...>").description("Health-status for one or more catalogs").action(async (ids, _opts, cmd) => {
|
|
2483
2558
|
printJson(await clientFrom(cmd).vega.catalogHealth(ids), outputOptions(cmd));
|
|
2484
2559
|
});
|
|
2485
|
-
catalog.command("create").description("Create a catalog (data source)").requiredOption("--name <s>", "catalog name").requiredOption("--connector-type <s>", "connector type (e.g. mysql)").requiredOption("--connector-config <json>", "connector config JSON").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled", "create enabled (default: disabled)").action(async (opts, cmd) => {
|
|
2560
|
+
catalog.command("create").description("Create a catalog (data source)").requiredOption("--name <s>", "catalog name").requiredOption("--connector-type <s>", "connector type (e.g. mysql)").requiredOption("--connector-config <json>", "connector config JSON").option("--id <id>", "explicit catalog id").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled", "create enabled (default: disabled)").option("--internal", "create an internal catalog").option("--extensions <json>", "extension key/value JSON object").action(async (opts, cmd) => {
|
|
2486
2561
|
let connectorConfig;
|
|
2487
2562
|
try {
|
|
2488
2563
|
connectorConfig = JSON.parse(opts.connectorConfig);
|
|
2489
2564
|
} catch {
|
|
2490
2565
|
throw new Error("--connector-config must be valid JSON");
|
|
2491
2566
|
}
|
|
2567
|
+
const extensions = opts.extensions ? JSON.parse(opts.extensions) : void 0;
|
|
2492
2568
|
printJson(
|
|
2493
2569
|
await clientFrom(cmd).vega.createCatalog({
|
|
2570
|
+
id: opts.id,
|
|
2494
2571
|
name: opts.name,
|
|
2495
2572
|
connectorType: opts.connectorType,
|
|
2496
2573
|
connectorConfig,
|
|
2497
2574
|
tags: opts.tags ? String(opts.tags).split(",").map((t) => t.trim()).filter(Boolean) : void 0,
|
|
2498
2575
|
description: opts.description,
|
|
2499
|
-
enabled: opts.enabled ? true : void 0
|
|
2576
|
+
enabled: opts.enabled ? true : void 0,
|
|
2577
|
+
internal: opts.internal ? true : void 0,
|
|
2578
|
+
extensions
|
|
2579
|
+
}),
|
|
2580
|
+
outputOptions(cmd)
|
|
2581
|
+
);
|
|
2582
|
+
});
|
|
2583
|
+
catalog.command("update <id>").description("Update a catalog").option("--name <s>", "catalog name").option("--connector-type <s>", "connector type").option("--connector-config <json>", "connector config JSON").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled <bool>", "enabled state").option("--extensions <json>", "extension key/value JSON object").action(async (id, opts, cmd) => {
|
|
2584
|
+
const connectorConfig = opts.connectorConfig ? JSON.parse(opts.connectorConfig) : void 0;
|
|
2585
|
+
const extensions = opts.extensions ? JSON.parse(opts.extensions) : void 0;
|
|
2586
|
+
printJson(
|
|
2587
|
+
await clientFrom(cmd).vega.updateCatalog(id, {
|
|
2588
|
+
name: opts.name,
|
|
2589
|
+
connectorType: opts.connectorType,
|
|
2590
|
+
connectorConfig,
|
|
2591
|
+
tags: opts.tags ? String(opts.tags).split(",").map((t) => t.trim()).filter(Boolean) : void 0,
|
|
2592
|
+
description: opts.description,
|
|
2593
|
+
enabled: opts.enabled === void 0 ? void 0 : opts.enabled === "true",
|
|
2594
|
+
extensions
|
|
2500
2595
|
}),
|
|
2501
2596
|
outputOptions(cmd)
|
|
2502
2597
|
);
|
|
@@ -2504,6 +2599,15 @@ function vegaCommand() {
|
|
|
2504
2599
|
catalog.command("enable <id>").description("Enable a catalog (required before discovery)").action(async (id, _opts, cmd) => {
|
|
2505
2600
|
printJson(await clientFrom(cmd).vega.enableCatalog(id), outputOptions(cmd));
|
|
2506
2601
|
});
|
|
2602
|
+
catalog.command("disable <id>").description("Disable a catalog").action(async (id, _opts, cmd) => {
|
|
2603
|
+
printJson(await clientFrom(cmd).vega.disableCatalog(id), outputOptions(cmd));
|
|
2604
|
+
});
|
|
2605
|
+
catalog.command("delete <id>").description("Delete a catalog").action(async (id, _opts, cmd) => {
|
|
2606
|
+
printJson(await clientFrom(cmd).vega.deleteCatalog(id), outputOptions(cmd));
|
|
2607
|
+
});
|
|
2608
|
+
catalog.command("test-connection <id>").description("Test a catalog connection").action(async (id, _opts, cmd) => {
|
|
2609
|
+
printJson(await clientFrom(cmd).vega.testCatalogConnection(id), outputOptions(cmd));
|
|
2610
|
+
});
|
|
2507
2611
|
catalog.command("discover <id>").description("Trigger catalog resource discovery").option("--wait", "wait for discovery to complete").action(async (id, opts, cmd) => {
|
|
2508
2612
|
printJson(
|
|
2509
2613
|
await clientFrom(cmd).vega.discoverCatalog(id, Boolean(opts.wait)),
|
|
@@ -2517,10 +2621,7 @@ function vegaCommand() {
|
|
|
2517
2621
|
connector.command("get <type>").description("Get a connector type").action(async (type, _opts, cmd) => {
|
|
2518
2622
|
printJson(await clientFrom(cmd).vega.connectorType(type), outputOptions(cmd));
|
|
2519
2623
|
});
|
|
2520
|
-
vega.command("sql").description("Run SQL / OpenSearch DSL directly against a vega-backend data source").option(
|
|
2521
|
-
"--resource-type <type>",
|
|
2522
|
-
"source type (mysql | postgresql | opensearch | \u2026); optional \u2014 inferred from the {{<id>}} placeholder"
|
|
2523
|
-
).option(
|
|
2624
|
+
vega.command("sql").description("Run SQL / OpenSearch DSL directly against a vega-backend data source").requiredOption("--resource-type <type>", "source type (mysql | postgresql | opensearch | \u2026)").option("--query-type <type>", "query mode: standard | stream").option(
|
|
2524
2625
|
"--query <sql>",
|
|
2525
2626
|
"SQL string; reference a resource with a {{<resource-id>}} placeholder"
|
|
2526
2627
|
).option("--stream-size <n>", "streaming batch size (100\u201310000)", int12).option("--query-timeout <s>", "query timeout in seconds (1\u20133600)", int12).option(
|
|
@@ -2540,9 +2641,8 @@ function vegaCommand() {
|
|
|
2540
2641
|
}
|
|
2541
2642
|
body = {
|
|
2542
2643
|
query: opts.query,
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
...opts.resourceType ? { resource_type: opts.resourceType } : {},
|
|
2644
|
+
resource_type: opts.resourceType,
|
|
2645
|
+
...opts.queryType ? { query_type: opts.queryType } : {},
|
|
2546
2646
|
...opts.streamSize !== void 0 ? { stream_size: opts.streamSize } : {},
|
|
2547
2647
|
...opts.queryTimeout !== void 0 ? { query_timeout: opts.queryTimeout } : {}
|
|
2548
2648
|
};
|
|
@@ -2550,12 +2650,20 @@ function vegaCommand() {
|
|
|
2550
2650
|
printJson(await clientFrom(cmd).vega.sql(body), outputOptions(cmd));
|
|
2551
2651
|
});
|
|
2552
2652
|
const resource = vega.command("resource").description("Vega-backend resources");
|
|
2553
|
-
resource.command("list").description("List resources").option("--datasource-id <id>", "filter by catalog/datasource id").option("--catalog-id <id>", "alias of --datasource-id").option("--type <category>", "resource category").option("--category <category>", "alias of --type").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).action(async (opts, cmd) => {
|
|
2653
|
+
resource.command("list").description("List resources").option("--datasource-id <id>", "filter by catalog/datasource id").option("--catalog-id <id>", "alias of --datasource-id").option("--type <category>", "resource category").option("--category <category>", "alias of --type").option("--status <status>", "filter by status").option("--database <name>", "filter by database").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int12, 0).option("--include-extensions", "include all extension key/value pairs").option("--include-extension-keys <keys>", "include selected extension keys").option("--extension <k=v,...>", "filter by extension key/value pairs").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (opts, cmd) => {
|
|
2554
2654
|
printJson(
|
|
2555
2655
|
await clientFrom(cmd).resource.list({
|
|
2556
2656
|
datasourceId: opts.datasourceId ?? opts.catalogId,
|
|
2557
2657
|
category: opts.type ?? opts.category,
|
|
2558
|
-
|
|
2658
|
+
status: opts.status,
|
|
2659
|
+
database: opts.database,
|
|
2660
|
+
limit: opts.limit,
|
|
2661
|
+
offset: opts.offset,
|
|
2662
|
+
includeExtensions: opts.includeExtensions,
|
|
2663
|
+
includeExtensionKeys: opts.includeExtensionKeys,
|
|
2664
|
+
extensionPairs: parsePairs2(opts.extension),
|
|
2665
|
+
sort: opts.sort,
|
|
2666
|
+
direction: opts.direction
|
|
2559
2667
|
}),
|
|
2560
2668
|
outputOptions(cmd)
|
|
2561
2669
|
);
|
|
@@ -2573,16 +2681,25 @@ function vegaCommand() {
|
|
|
2573
2681
|
dataset.command("build <resource-id>").description("Build a resource's index (creates a BuildTask)").requiredOption("--mode <mode>", "build mode: batch | streaming").option("--embedding-fields <list>", "comma-separated fields to vectorize").option(
|
|
2574
2682
|
"--build-key-fields <list>",
|
|
2575
2683
|
"comma-separated key fields (batch: time; streaming: row id)"
|
|
2576
|
-
).option("--embedding-model <id>", "embedding model id
|
|
2684
|
+
).option("--embedding-model <id>", "default embedding model name/id").option("--fulltext-fields <list>", "comma-separated fields for fulltext index").option("--fulltext-analyzer <name>", "fulltext analyzer").option("--execute-type <type>", "batch execution type: incremental | full").option("--wait", "poll until the build reaches a terminal state").option("--timeout <s>", "wait timeout in seconds", (v) => Number.parseInt(v, 10), 300).action(async (resourceId, _opts, cmd) => {
|
|
2577
2685
|
const o = cmd.optsWithGlobals();
|
|
2686
|
+
const embeddingFields = csv(o.embeddingFields);
|
|
2687
|
+
const buildKeyFields = csv(o.buildKeyFields);
|
|
2688
|
+
const fulltextFields = csv(o.fulltextFields);
|
|
2689
|
+
if (embeddingFields || buildKeyFields || o.embeddingModel || fulltextFields || o.fulltextAnalyzer) {
|
|
2690
|
+
await clientFrom(cmd).resource.configureIndex(resourceId, {
|
|
2691
|
+
embeddingFields,
|
|
2692
|
+
buildKeyFields,
|
|
2693
|
+
embeddingModel: o.embeddingModel,
|
|
2694
|
+
fulltextFields,
|
|
2695
|
+
fulltextAnalyzer: o.fulltextAnalyzer
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2578
2698
|
const task = await clientFrom(cmd).vega.build(
|
|
2579
2699
|
{
|
|
2580
2700
|
resource_id: resourceId,
|
|
2581
2701
|
mode: o.mode,
|
|
2582
|
-
|
|
2583
|
-
build_key_fields: csv(o.buildKeyFields),
|
|
2584
|
-
embedding_model: o.embeddingModel,
|
|
2585
|
-
model_dimensions: o.modelDimensions
|
|
2702
|
+
execute_type: o.executeType
|
|
2586
2703
|
},
|
|
2587
2704
|
{ wait: Boolean(o.wait), timeoutMs: o.timeout * 1e3 }
|
|
2588
2705
|
);
|
|
@@ -2592,6 +2709,40 @@ function vegaCommand() {
|
|
|
2592
2709
|
const task = await clientFrom(cmd).vega.buildStatus(taskId);
|
|
2593
2710
|
printJson(task, outputOptions(cmd));
|
|
2594
2711
|
});
|
|
2712
|
+
dataset.command("build-list").description("List BuildTasks").option("--limit <n>", "page size", int12, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int12, 0).option("--resource-id <id>", "filter by resource id").option("--catalog-id <id>", "filter by catalog id").option("--status <status>", "comma-separated statuses").option("--active", "only running/init tasks").option("--mode <mode>", "filter by mode: batch | streaming").option("--order-by <field>", "default | created_at | updated_at | status | mode").option("--order <dir>", "asc | desc").action(async (opts, cmd) => {
|
|
2713
|
+
printJson(
|
|
2714
|
+
await clientFrom(cmd).vega.buildTasks({
|
|
2715
|
+
limit: opts.limit,
|
|
2716
|
+
offset: opts.offset,
|
|
2717
|
+
resourceId: opts.resourceId,
|
|
2718
|
+
catalogId: opts.catalogId,
|
|
2719
|
+
status: opts.status,
|
|
2720
|
+
active: opts.active,
|
|
2721
|
+
mode: opts.mode,
|
|
2722
|
+
orderBy: opts.orderBy,
|
|
2723
|
+
order: opts.order
|
|
2724
|
+
}),
|
|
2725
|
+
outputOptions(cmd)
|
|
2726
|
+
);
|
|
2727
|
+
});
|
|
2728
|
+
dataset.command("build-start <task-id>").description("Start a BuildTask").option("--reset", "restart from the beginning").action(async (taskId, opts, cmd) => {
|
|
2729
|
+
printJson(
|
|
2730
|
+
await clientFrom(cmd).vega.startBuildTask(taskId, { reset: opts.reset }),
|
|
2731
|
+
outputOptions(cmd)
|
|
2732
|
+
);
|
|
2733
|
+
});
|
|
2734
|
+
dataset.command("build-stop <task-id>").description("Stop a BuildTask").action(async (taskId, _opts, cmd) => {
|
|
2735
|
+
printJson(await clientFrom(cmd).vega.stopBuildTask(taskId), outputOptions(cmd));
|
|
2736
|
+
});
|
|
2737
|
+
dataset.command("build-delete <ids...>").description("Delete one or more BuildTasks").option("--ignore-missing", "ignore missing task ids").option("--delete-active-index", "delete active indexes too").action(async (ids, opts, cmd) => {
|
|
2738
|
+
printJson(
|
|
2739
|
+
await clientFrom(cmd).vega.deleteBuildTasks(ids, {
|
|
2740
|
+
ignoreMissing: opts.ignoreMissing,
|
|
2741
|
+
deleteActiveIndex: opts.deleteActiveIndex
|
|
2742
|
+
}),
|
|
2743
|
+
outputOptions(cmd)
|
|
2744
|
+
);
|
|
2745
|
+
});
|
|
2595
2746
|
return group(vega, "AI DATA PLATFORM");
|
|
2596
2747
|
}
|
|
2597
2748
|
|