@openbkn/bkn-sdk 0.1.0 → 0.1.1-alpha.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.
- package/README.md +18 -3
- package/dist/{chunk-4NXAIG4G.js → chunk-DXA44XWY.js} +286 -56
- package/dist/chunk-DXA44XWY.js.map +1 -0
- package/dist/cli.js +58 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +74 -26
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4NXAIG4G.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
formatError,
|
|
14
14
|
listPlatforms,
|
|
15
15
|
logout,
|
|
16
|
+
parseEmbeddingFields,
|
|
16
17
|
parsePkMap,
|
|
17
18
|
rawCall,
|
|
18
19
|
readPlatformConfig,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
usersOf,
|
|
28
29
|
whoami,
|
|
29
30
|
writePlatformConfig
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-DXA44XWY.js";
|
|
31
32
|
|
|
32
33
|
// src/cli.ts
|
|
33
34
|
import { Command as Command16 } from "commander";
|
|
@@ -35,7 +36,7 @@ import { Command as Command16 } from "commander";
|
|
|
35
36
|
// package.json
|
|
36
37
|
var package_default = {
|
|
37
38
|
name: "@openbkn/bkn-sdk",
|
|
38
|
-
version: "0.1.0",
|
|
39
|
+
version: "0.1.1-alpha.0",
|
|
39
40
|
description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
40
41
|
type: "module",
|
|
41
42
|
license: "Apache-2.0",
|
|
@@ -1379,8 +1380,18 @@ function bknCommand() {
|
|
|
1379
1380
|
job.command("delete <kn-id> <job-ids>").description("Delete job(s) (comma-joined ids)").action(async (knId, ids, _o, cmd) => {
|
|
1380
1381
|
printJson(await clientFrom(cmd).kn.jobDelete(knId, ids), outputOptions(cmd));
|
|
1381
1382
|
});
|
|
1382
|
-
bkn.command("push <directory>").description("Pack a BKN directory into a tar and import it as a knowledge network").option("--branch <name>", "target branch", "main").
|
|
1383
|
-
|
|
1383
|
+
bkn.command("push <directory>").description("Pack a BKN directory into a tar and import it as a knowledge network").option("--branch <name>", "target branch", "main").option("--build", "submit a Vega build task for each object type declaring a vector index").option(
|
|
1384
|
+
"--embedding-model <id>",
|
|
1385
|
+
"embedding model id for declared vector indexes (with --build)"
|
|
1386
|
+
).action(async (dir, opts, cmd) => {
|
|
1387
|
+
printJson(
|
|
1388
|
+
await clientFrom(cmd).kn.push(dir, {
|
|
1389
|
+
branch: opts.branch,
|
|
1390
|
+
build: Boolean(opts.build),
|
|
1391
|
+
embeddingModel: opts.embeddingModel
|
|
1392
|
+
}),
|
|
1393
|
+
outputOptions(cmd)
|
|
1394
|
+
);
|
|
1384
1395
|
});
|
|
1385
1396
|
bkn.command("pull <kn-id> [directory]").description("Download a knowledge network as a BKN tar and extract it locally").option("--branch <name>", "source branch", "main").action(async (knId, dir, opts, cmd) => {
|
|
1386
1397
|
printJson(
|
|
@@ -1397,7 +1408,10 @@ function bknCommand() {
|
|
|
1397
1408
|
bkn.command("resources").description("List BKN-backend resources").action(async (_opts, cmd) => {
|
|
1398
1409
|
printJson(await clientFrom(cmd).kn.bknResources(), outputOptions(cmd));
|
|
1399
1410
|
});
|
|
1400
|
-
bkn.command("create-from-catalog <catalog-id>").description("Build a knowledge network from a Vega catalog's tables").requiredOption("--name <name>", "knowledge network name").option("--tables <list>", "comma-separated table names (default: all)").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,<table>:<col>...]'").option("--build", "submit a Vega build task per resource after creation").option(
|
|
1411
|
+
bkn.command("create-from-catalog <catalog-id>").description("Build a knowledge network from a Vega catalog's tables").requiredOption("--name <name>", "knowledge network name").option("--tables <list>", "comma-separated table names (default: all)").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,<table>:<col>...]'").option("--build", "submit a Vega build task per resource after creation").option(
|
|
1412
|
+
"--embedding-fields <map>",
|
|
1413
|
+
"columns to vectorize per table (with --build): '<table>:<col>[+<col>...][,...]'"
|
|
1414
|
+
).option("--embedding-model <id>", "embedding model id for the vector index (with --build)").option("--no-rollback", "keep a partially-created KN on failure").action(async (catalogId, opts, cmd) => {
|
|
1401
1415
|
printJson(
|
|
1402
1416
|
await clientFrom(cmd).kn.createFromCatalog({
|
|
1403
1417
|
catalogId,
|
|
@@ -1405,6 +1419,8 @@ function bknCommand() {
|
|
|
1405
1419
|
tables: csv(opts.tables),
|
|
1406
1420
|
pkMap: opts.pkMap ? parsePkMap(opts.pkMap) : void 0,
|
|
1407
1421
|
build: Boolean(opts.build),
|
|
1422
|
+
embeddingFields: opts.embeddingFields ? parseEmbeddingFields(opts.embeddingFields) : void 0,
|
|
1423
|
+
embeddingModel: opts.embeddingModel,
|
|
1408
1424
|
noRollback: opts.rollback === false,
|
|
1409
1425
|
onProgress: (m) => console.error(m)
|
|
1410
1426
|
}),
|
|
@@ -1416,7 +1432,10 @@ function bknCommand() {
|
|
|
1416
1432
|
printJson(result, outputOptions(cmd));
|
|
1417
1433
|
if (!result.valid) process.exitCode = 1;
|
|
1418
1434
|
});
|
|
1419
|
-
bkn.command("create-from-csv <catalog-id>").description("Import CSV files into a Vega catalog, then build a KN from them").requiredOption("--files <glob>", "CSV paths (comma-separated or glob)").requiredOption("--name <name>", "knowledge network name").option("--table-prefix <s>", "prefix for derived table names", "").option("--batch-size <n>", "rows per insert batch", int3, 500).option("--tables <list>", "subset of imported tables to include in the KN").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,...]'").option("--build", "submit a Vega build task per resource after creation").option(
|
|
1435
|
+
bkn.command("create-from-csv <catalog-id>").description("Import CSV files into a Vega catalog, then build a KN from them").requiredOption("--files <glob>", "CSV paths (comma-separated or glob)").requiredOption("--name <name>", "knowledge network name").option("--table-prefix <s>", "prefix for derived table names", "").option("--batch-size <n>", "rows per insert batch", int3, 500).option("--tables <list>", "subset of imported tables to include in the KN").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,...]'").option("--build", "submit a Vega build task per resource after creation").option(
|
|
1436
|
+
"--embedding-fields <map>",
|
|
1437
|
+
"columns to vectorize per table (with --build): '<table>:<col>[+<col>...][,...]'"
|
|
1438
|
+
).option("--embedding-model <id>", "embedding model id for the vector index (with --build)").option("--no-rollback", "keep a partially-created KN on failure").action(async (catalogId, opts, cmd) => {
|
|
1420
1439
|
printJson(
|
|
1421
1440
|
await clientFrom(cmd).kn.createFromCsv({
|
|
1422
1441
|
catalogId,
|
|
@@ -1427,6 +1446,8 @@ function bknCommand() {
|
|
|
1427
1446
|
tables: csv(opts.tables),
|
|
1428
1447
|
pkMap: opts.pkMap ? parsePkMap(opts.pkMap) : void 0,
|
|
1429
1448
|
build: Boolean(opts.build),
|
|
1449
|
+
embeddingFields: opts.embeddingFields ? parseEmbeddingFields(opts.embeddingFields) : void 0,
|
|
1450
|
+
embeddingModel: opts.embeddingModel,
|
|
1430
1451
|
noRollback: opts.rollback === false,
|
|
1431
1452
|
onProgress: (m) => console.error(m)
|
|
1432
1453
|
}),
|
|
@@ -2234,6 +2255,34 @@ function vegaCommand() {
|
|
|
2234
2255
|
catalog.command("health <ids...>").description("Health-status for one or more catalogs").action(async (ids, _opts, cmd) => {
|
|
2235
2256
|
printJson(await clientFrom(cmd).vega.catalogHealth(ids), outputOptions(cmd));
|
|
2236
2257
|
});
|
|
2258
|
+
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) => {
|
|
2259
|
+
let connectorConfig;
|
|
2260
|
+
try {
|
|
2261
|
+
connectorConfig = JSON.parse(opts.connectorConfig);
|
|
2262
|
+
} catch {
|
|
2263
|
+
throw new Error("--connector-config must be valid JSON");
|
|
2264
|
+
}
|
|
2265
|
+
printJson(
|
|
2266
|
+
await clientFrom(cmd).vega.createCatalog({
|
|
2267
|
+
name: opts.name,
|
|
2268
|
+
connectorType: opts.connectorType,
|
|
2269
|
+
connectorConfig,
|
|
2270
|
+
tags: opts.tags ? String(opts.tags).split(",").map((t) => t.trim()).filter(Boolean) : void 0,
|
|
2271
|
+
description: opts.description,
|
|
2272
|
+
enabled: opts.enabled ? true : void 0
|
|
2273
|
+
}),
|
|
2274
|
+
outputOptions(cmd)
|
|
2275
|
+
);
|
|
2276
|
+
});
|
|
2277
|
+
catalog.command("enable <id>").description("Enable a catalog (required before discovery)").action(async (id, _opts, cmd) => {
|
|
2278
|
+
printJson(await clientFrom(cmd).vega.enableCatalog(id), outputOptions(cmd));
|
|
2279
|
+
});
|
|
2280
|
+
catalog.command("discover <id>").description("Trigger catalog resource discovery").option("--wait", "wait for discovery to complete").action(async (id, opts, cmd) => {
|
|
2281
|
+
printJson(
|
|
2282
|
+
await clientFrom(cmd).vega.discoverCatalog(id, Boolean(opts.wait)),
|
|
2283
|
+
outputOptions(cmd)
|
|
2284
|
+
);
|
|
2285
|
+
});
|
|
2237
2286
|
const connector = vega.command("connector-type").description("Connector types");
|
|
2238
2287
|
connector.command("list").description("List connector types").action(async (_opts, cmd) => {
|
|
2239
2288
|
printJson(await clientFrom(cmd).vega.connectorTypes(), outputOptions(cmd));
|
|
@@ -2242,11 +2291,11 @@ function vegaCommand() {
|
|
|
2242
2291
|
printJson(await clientFrom(cmd).vega.connectorType(type), outputOptions(cmd));
|
|
2243
2292
|
});
|
|
2244
2293
|
const resource = vega.command("resource").description("Vega-backend resources");
|
|
2245
|
-
resource.command("list").description("List resources").option("--datasource-id <id>", "filter by catalog/datasource id").option("--type <category>", "resource category").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).action(async (opts, cmd) => {
|
|
2294
|
+
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) => {
|
|
2246
2295
|
printJson(
|
|
2247
2296
|
await clientFrom(cmd).resource.list({
|
|
2248
|
-
datasourceId: opts.datasourceId,
|
|
2249
|
-
category: opts.type,
|
|
2297
|
+
datasourceId: opts.datasourceId ?? opts.catalogId,
|
|
2298
|
+
category: opts.type ?? opts.category,
|
|
2250
2299
|
limit: opts.limit
|
|
2251
2300
|
}),
|
|
2252
2301
|
outputOptions(cmd)
|