@openbkn/bkn-sdk 0.1.1-alpha.16 → 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/README.md +3 -2
- package/README.zh.md +3 -3
- package/dist/{chunk-SH2KLES5.js → chunk-LCOMMFH7.js} +280 -47
- package/dist/chunk-LCOMMFH7.js.map +1 -0
- package/dist/cli.js +174 -33
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +235 -35
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-SH2KLES5.js.map +0 -1
|
@@ -296,7 +296,11 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
296
296
|
async function request(ctx, path, init = {}) {
|
|
297
297
|
const url = new URL(path.startsWith("http") ? path : `${ctx.baseUrl}${path}`);
|
|
298
298
|
for (const [k, v] of Object.entries(init.query ?? {})) {
|
|
299
|
-
if (
|
|
299
|
+
if (Array.isArray(v)) {
|
|
300
|
+
for (const item of v) url.searchParams.append(k, String(item));
|
|
301
|
+
} else if (v !== void 0) {
|
|
302
|
+
url.searchParams.set(k, String(v));
|
|
303
|
+
}
|
|
300
304
|
}
|
|
301
305
|
applyTls(ctx);
|
|
302
306
|
const hasBody = init.body !== void 0;
|
|
@@ -694,6 +698,43 @@ async function setRolePermissionSafe(ctx, roleId, grant, perm) {
|
|
|
694
698
|
});
|
|
695
699
|
return { ok: true };
|
|
696
700
|
}
|
|
701
|
+
function getLicenseSafe(ctx) {
|
|
702
|
+
return request(ctx, `${ADMIN}/license`);
|
|
703
|
+
}
|
|
704
|
+
async function importLicenseSafe(ctx, licenseText, opts = {}) {
|
|
705
|
+
const text = licenseText.trim();
|
|
706
|
+
if (!text) throw new InputError("license text is empty");
|
|
707
|
+
try {
|
|
708
|
+
return await request(ctx, `${ADMIN}/license/${opts.receipt ? "receipt" : "import"}`, {
|
|
709
|
+
method: "POST",
|
|
710
|
+
body: { license: text }
|
|
711
|
+
});
|
|
712
|
+
} catch (err) {
|
|
713
|
+
if (err instanceof HttpError) {
|
|
714
|
+
const stored = storedImport(err.body);
|
|
715
|
+
if (stored) return stored;
|
|
716
|
+
}
|
|
717
|
+
throw err;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function storedImport(body) {
|
|
721
|
+
try {
|
|
722
|
+
const parsed = JSON.parse(body);
|
|
723
|
+
if (parsed && parsed.stored === true) return parsed;
|
|
724
|
+
} catch {
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
function activateLicenseSafe(ctx) {
|
|
729
|
+
return request(ctx, `${ADMIN}/license/activate`, { method: "POST" });
|
|
730
|
+
}
|
|
731
|
+
async function removeLicenseSafe(ctx) {
|
|
732
|
+
await request(ctx, `${ADMIN}/license`, { method: "DELETE" });
|
|
733
|
+
return { ok: true };
|
|
734
|
+
}
|
|
735
|
+
function getLicenseFingerprintSafe(ctx) {
|
|
736
|
+
return request(ctx, `${ADMIN}/license/fingerprint`);
|
|
737
|
+
}
|
|
697
738
|
|
|
698
739
|
// src/resources/admin.ts
|
|
699
740
|
var DEFAULT_NEW_USER_PASSWORD = "openbkn";
|
|
@@ -754,7 +795,13 @@ function admin(ctx) {
|
|
|
754
795
|
roleUpdate: (roleId, input) => updateRoleSafe(ctx, roleId, input),
|
|
755
796
|
roleDelete: (roleId) => deleteRoleSafe(ctx, roleId),
|
|
756
797
|
rolePermission: (roleId, grant, resourceType, resourceId, operations) => setRolePermissionSafe(ctx, roleId, grant, { resourceType, resourceId, operations }),
|
|
757
|
-
auditList: (_opts) => notOnSafe("audit list")
|
|
798
|
+
auditList: (_opts) => notOnSafe("audit list"),
|
|
799
|
+
// ── license (cluster license hub; weak judgements — display/ops only) ──
|
|
800
|
+
licenseGet: () => getLicenseSafe(ctx),
|
|
801
|
+
licenseImport: (licenseText, opts) => importLicenseSafe(ctx, licenseText, opts),
|
|
802
|
+
licenseActivate: () => activateLicenseSafe(ctx),
|
|
803
|
+
licenseRemove: () => removeLicenseSafe(ctx),
|
|
804
|
+
licenseFingerprint: () => getLicenseFingerprintSafe(ctx)
|
|
758
805
|
};
|
|
759
806
|
}
|
|
760
807
|
|
|
@@ -1522,7 +1569,16 @@ function listResources2(ctx, opts = {}) {
|
|
|
1522
1569
|
catalog_id: opts.datasourceId || void 0,
|
|
1523
1570
|
name: opts.name || void 0,
|
|
1524
1571
|
category: opts.category || void 0,
|
|
1525
|
-
|
|
1572
|
+
status: opts.status || void 0,
|
|
1573
|
+
database: opts.database || void 0,
|
|
1574
|
+
limit: opts.limit && opts.limit > 0 ? opts.limit : void 0,
|
|
1575
|
+
offset: opts.offset,
|
|
1576
|
+
sort: opts.sort,
|
|
1577
|
+
direction: opts.direction,
|
|
1578
|
+
include_extensions: opts.includeExtensions === void 0 ? void 0 : String(opts.includeExtensions),
|
|
1579
|
+
include_extension_keys: opts.includeExtensionKeys || void 0,
|
|
1580
|
+
extension_key: opts.extensionPairs?.map((p) => p.key),
|
|
1581
|
+
extension_value: opts.extensionPairs?.map((p) => p.value)
|
|
1526
1582
|
}
|
|
1527
1583
|
});
|
|
1528
1584
|
}
|
|
@@ -1532,18 +1588,103 @@ function getResource(ctx, id) {
|
|
|
1532
1588
|
function createResourceRaw(ctx, body) {
|
|
1533
1589
|
return request(ctx, BASE3, { method: "POST", body });
|
|
1534
1590
|
}
|
|
1535
|
-
function
|
|
1591
|
+
function updateResourceRaw(ctx, id, body) {
|
|
1592
|
+
return request(ctx, `${BASE3}/${encodeURIComponent(id)}`, { method: "PUT", body });
|
|
1593
|
+
}
|
|
1594
|
+
async function updateResource(ctx, id, patch) {
|
|
1595
|
+
const current = firstResource(await getResource(ctx, id));
|
|
1596
|
+
return updateResourceRaw(ctx, id, resourceUpdateBody(id, current, patch));
|
|
1597
|
+
}
|
|
1598
|
+
async function configureResourceIndex(ctx, id, opts) {
|
|
1599
|
+
const current = firstResource(await getResource(ctx, id));
|
|
1600
|
+
const schema = (current.schema_definition ?? []).map((prop) => ({ ...prop }));
|
|
1601
|
+
const indexConfig = {
|
|
1602
|
+
...current.index_config ?? {},
|
|
1603
|
+
...opts.buildKeyFields?.length ? { build_key_fields: opts.buildKeyFields } : {},
|
|
1604
|
+
...opts.embeddingModel ? { default_embedding_model: opts.embeddingModel } : {},
|
|
1605
|
+
...opts.fulltextAnalyzer ? { default_fulltext_analyzer: opts.fulltextAnalyzer } : {}
|
|
1606
|
+
};
|
|
1607
|
+
for (const field of opts.embeddingFields ?? []) {
|
|
1608
|
+
ensureFeature(
|
|
1609
|
+
schema,
|
|
1610
|
+
field,
|
|
1611
|
+
"vector",
|
|
1612
|
+
opts.embeddingModel ? { embedding_model: opts.embeddingModel } : void 0
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
for (const field of opts.fulltextFields ?? []) {
|
|
1616
|
+
ensureFeature(
|
|
1617
|
+
schema,
|
|
1618
|
+
field,
|
|
1619
|
+
"fulltext",
|
|
1620
|
+
opts.fulltextAnalyzer ? { analyzer: opts.fulltextAnalyzer } : void 0
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
return updateResourceRaw(
|
|
1624
|
+
ctx,
|
|
1625
|
+
id,
|
|
1626
|
+
resourceUpdateBody(id, current, { schemaDefinition: schema, indexConfig })
|
|
1627
|
+
);
|
|
1628
|
+
}
|
|
1629
|
+
function resourceUpdateBody(id, current, patch) {
|
|
1536
1630
|
const body = {
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1631
|
+
id,
|
|
1632
|
+
name: patch.name ?? current.name,
|
|
1633
|
+
catalog_id: patch.catalogId ?? current.catalog_id,
|
|
1634
|
+
tags: patch.tags ?? current.tags ?? [],
|
|
1635
|
+
description: patch.description ?? current.description ?? "",
|
|
1636
|
+
category: patch.category ?? current.category,
|
|
1637
|
+
status: patch.status ?? current.status,
|
|
1638
|
+
database: patch.database ?? current.database,
|
|
1639
|
+
source_identifier: patch.sourceIdentifier ?? current.source_identifier,
|
|
1640
|
+
source_metadata: patch.sourceMetadata ?? current.source_metadata,
|
|
1641
|
+
schema_definition: patch.schemaDefinition ?? current.schema_definition,
|
|
1642
|
+
index_config: patch.indexConfig === void 0 ? current.index_config : patch.indexConfig,
|
|
1643
|
+
logic_definition: patch.logicDefinition ?? current.logic_definition
|
|
1541
1644
|
};
|
|
1542
|
-
if (
|
|
1543
|
-
|
|
1645
|
+
if (patch.extensions !== void 0 || current.extensions !== void 0) {
|
|
1646
|
+
body.extensions = patch.extensions ?? current.extensions;
|
|
1647
|
+
}
|
|
1648
|
+
return body;
|
|
1649
|
+
}
|
|
1650
|
+
function ensureFeature(schema, field, featureType, config) {
|
|
1651
|
+
const prop = schema.find((p) => p.name === field);
|
|
1652
|
+
if (!prop) throw new Error(`resource field '${field}' not found in schema_definition`);
|
|
1653
|
+
const features = [...prop.features ?? []];
|
|
1654
|
+
const existing = features.find(
|
|
1655
|
+
(f) => f.feature_type === featureType && (f.ref_property || field) === field
|
|
1656
|
+
);
|
|
1657
|
+
if (existing) {
|
|
1658
|
+
existing.ref_property = existing.ref_property || field;
|
|
1659
|
+
existing.config = { ...existing.config ?? {}, ...config ?? {} };
|
|
1660
|
+
} else {
|
|
1661
|
+
features.push({
|
|
1662
|
+
name: `${field}_${featureType}`,
|
|
1663
|
+
feature_type: featureType,
|
|
1664
|
+
ref_property: field,
|
|
1665
|
+
is_default: false,
|
|
1666
|
+
is_native: false,
|
|
1667
|
+
...config ? { config } : {}
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
prop.features = features;
|
|
1544
1671
|
}
|
|
1545
|
-
function
|
|
1546
|
-
|
|
1672
|
+
function firstResource(result) {
|
|
1673
|
+
if (result && typeof result === "object") {
|
|
1674
|
+
const o = result;
|
|
1675
|
+
if (Array.isArray(o.entries)) return o.entries[0] ?? {};
|
|
1676
|
+
return o;
|
|
1677
|
+
}
|
|
1678
|
+
return {};
|
|
1679
|
+
}
|
|
1680
|
+
function deleteResource(ctx, id, opts = {}) {
|
|
1681
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
1682
|
+
return request(ctx, `${BASE3}/${ids.map(encodeURIComponent).join(",")}`, {
|
|
1683
|
+
method: "DELETE",
|
|
1684
|
+
query: {
|
|
1685
|
+
ignore_missing: opts.ignoreMissing === void 0 ? void 0 : String(opts.ignoreMissing)
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1547
1688
|
}
|
|
1548
1689
|
async function findResource(ctx, name, opts = {}) {
|
|
1549
1690
|
const result = await listResources2(ctx, { name, datasourceId: opts.datasourceId });
|
|
@@ -2875,10 +3016,7 @@ var BuildMode = z.enum(["batch", "streaming"]);
|
|
|
2875
3016
|
var CreateBuildTaskRequest = z.object({
|
|
2876
3017
|
resource_id: z.string().min(1),
|
|
2877
3018
|
mode: BuildMode,
|
|
2878
|
-
|
|
2879
|
-
build_key_fields: z.array(z.string()).optional(),
|
|
2880
|
-
embedding_model: z.string().optional(),
|
|
2881
|
-
model_dimensions: z.number().int().positive().optional()
|
|
3019
|
+
execute_type: z.enum(["incremental", "full"]).optional()
|
|
2882
3020
|
});
|
|
2883
3021
|
var BuildTask = z.object({
|
|
2884
3022
|
id: z.string(),
|
|
@@ -2889,34 +3027,83 @@ var BuildTask = z.object({
|
|
|
2889
3027
|
total_count: z.number().optional(),
|
|
2890
3028
|
synced_count: z.number().optional(),
|
|
2891
3029
|
vectorized_count: z.number().optional(),
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
3030
|
+
index_config: z.unknown().optional(),
|
|
3031
|
+
catalog_id: z.string().optional(),
|
|
3032
|
+
index_health: z.object({
|
|
3033
|
+
embedding: z.string(),
|
|
3034
|
+
fulltext: z.string(),
|
|
3035
|
+
usable: z.boolean()
|
|
3036
|
+
}).passthrough().optional()
|
|
2896
3037
|
}).passthrough();
|
|
2897
3038
|
async function createBuildTask(ctx, req) {
|
|
2898
3039
|
const p = CreateBuildTaskRequest.parse(req);
|
|
2899
3040
|
const body = {
|
|
2900
3041
|
resource_id: p.resource_id,
|
|
2901
3042
|
mode: p.mode,
|
|
2902
|
-
...p.
|
|
2903
|
-
...p.build_key_fields?.length ? { build_key_fields: p.build_key_fields.join(",") } : {},
|
|
2904
|
-
...p.embedding_model ? { embedding_model: p.embedding_model } : {},
|
|
2905
|
-
...p.model_dimensions ? { model_dimensions: p.model_dimensions } : {}
|
|
3043
|
+
...p.execute_type ? { execute_type: p.execute_type } : {}
|
|
2906
3044
|
};
|
|
2907
3045
|
const res = await request(ctx, `${VEGA_BASE}/build-tasks`, { method: "POST", body });
|
|
2908
3046
|
return BuildTask.parse(res);
|
|
2909
3047
|
}
|
|
3048
|
+
function listBuildTasks(ctx, opts = {}) {
|
|
3049
|
+
return request(ctx, `${VEGA_BASE}/build-tasks`, {
|
|
3050
|
+
query: {
|
|
3051
|
+
limit: opts.limit,
|
|
3052
|
+
offset: opts.offset,
|
|
3053
|
+
resource_id: opts.resourceId || void 0,
|
|
3054
|
+
catalog_id: opts.catalogId || void 0,
|
|
3055
|
+
status: Array.isArray(opts.status) ? opts.status.join(",") : opts.status || void 0,
|
|
3056
|
+
active: opts.active === void 0 ? void 0 : String(opts.active),
|
|
3057
|
+
mode: opts.mode,
|
|
3058
|
+
order_by: opts.orderBy,
|
|
3059
|
+
order: opts.order
|
|
3060
|
+
}
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
2910
3063
|
async function getBuildTask(ctx, taskId) {
|
|
2911
3064
|
const res = await request(ctx, `${VEGA_BASE}/build-tasks/${encodeURIComponent(taskId)}`);
|
|
2912
3065
|
return BuildTask.parse(res);
|
|
2913
3066
|
}
|
|
3067
|
+
function deleteBuildTasks(ctx, ids, opts = {}) {
|
|
3068
|
+
return request(ctx, `${VEGA_BASE}/build-tasks/${ids.map(encodeURIComponent).join(",")}`, {
|
|
3069
|
+
method: "DELETE",
|
|
3070
|
+
query: {
|
|
3071
|
+
ignore_missing: opts.ignoreMissing === void 0 ? void 0 : String(opts.ignoreMissing),
|
|
3072
|
+
delete_active_index: opts.deleteActiveIndex === void 0 ? void 0 : String(opts.deleteActiveIndex)
|
|
3073
|
+
}
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
function startBuildTask(ctx, taskId, opts = {}) {
|
|
3077
|
+
return request(ctx, `${VEGA_BASE}/build-tasks/${encodeURIComponent(taskId)}/start`, {
|
|
3078
|
+
method: "POST",
|
|
3079
|
+
body: opts.reset === void 0 ? {} : { reset: opts.reset }
|
|
3080
|
+
});
|
|
3081
|
+
}
|
|
3082
|
+
function stopBuildTask(ctx, taskId) {
|
|
3083
|
+
return request(ctx, `${VEGA_BASE}/build-tasks/${encodeURIComponent(taskId)}/stop`, {
|
|
3084
|
+
method: "POST"
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
2914
3087
|
function runSql(ctx, body) {
|
|
2915
3088
|
return request(ctx, `${VEGA_BASE}/resources/query`, { method: "POST", body });
|
|
2916
3089
|
}
|
|
2917
3090
|
async function listCatalogs(ctx, opts = {}) {
|
|
2918
3091
|
return request(ctx, `${VEGA_BASE}/catalogs`, {
|
|
2919
|
-
query: {
|
|
3092
|
+
query: {
|
|
3093
|
+
limit: opts.limit,
|
|
3094
|
+
offset: opts.offset,
|
|
3095
|
+
name: opts.name || void 0,
|
|
3096
|
+
tag: opts.tag || void 0,
|
|
3097
|
+
type: opts.type || void 0,
|
|
3098
|
+
enabled: opts.enabled === void 0 ? void 0 : String(opts.enabled),
|
|
3099
|
+
health_check_status: opts.healthCheckStatus || void 0,
|
|
3100
|
+
include_extensions: opts.includeExtensions === void 0 ? void 0 : String(opts.includeExtensions),
|
|
3101
|
+
include_extension_keys: opts.includeExtensionKeys || void 0,
|
|
3102
|
+
extension_key: opts.extensionPairs?.map((p) => p.key),
|
|
3103
|
+
extension_value: opts.extensionPairs?.map((p) => p.value),
|
|
3104
|
+
sort: opts.sort,
|
|
3105
|
+
direction: opts.direction
|
|
3106
|
+
}
|
|
2920
3107
|
});
|
|
2921
3108
|
}
|
|
2922
3109
|
function getCatalog(ctx, id) {
|
|
@@ -2926,18 +3113,49 @@ function createCatalog(ctx, req) {
|
|
|
2926
3113
|
return request(ctx, `${VEGA_BASE}/catalogs`, {
|
|
2927
3114
|
method: "POST",
|
|
2928
3115
|
body: {
|
|
3116
|
+
...req.id ? { id: req.id } : {},
|
|
2929
3117
|
name: req.name,
|
|
2930
3118
|
connector_type: req.connectorType,
|
|
2931
3119
|
connector_config: req.connectorConfig,
|
|
2932
3120
|
...req.tags ? { tags: req.tags } : {},
|
|
2933
3121
|
...req.description ? { description: req.description } : {},
|
|
2934
|
-
...req.enabled !== void 0 ? { enabled: req.enabled } : {}
|
|
3122
|
+
...req.enabled !== void 0 ? { enabled: req.enabled } : {},
|
|
3123
|
+
...req.internal !== void 0 ? { internal: req.internal } : {},
|
|
3124
|
+
...req.extensions ? { extensions: req.extensions } : {}
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
function updateCatalog(ctx, id, req) {
|
|
3129
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}`, {
|
|
3130
|
+
method: "PUT",
|
|
3131
|
+
body: {
|
|
3132
|
+
...req.id ? { id: req.id } : {},
|
|
3133
|
+
...req.name ? { name: req.name } : {},
|
|
3134
|
+
...req.connectorType ? { connector_type: req.connectorType } : {},
|
|
3135
|
+
...req.connectorConfig !== void 0 ? { connector_config: req.connectorConfig } : {},
|
|
3136
|
+
...req.tags ? { tags: req.tags } : {},
|
|
3137
|
+
...req.description !== void 0 ? { description: req.description } : {},
|
|
3138
|
+
...req.enabled !== void 0 ? { enabled: req.enabled } : {},
|
|
3139
|
+
...req.extensions ? { extensions: req.extensions } : {}
|
|
2935
3140
|
}
|
|
2936
3141
|
});
|
|
2937
3142
|
}
|
|
2938
3143
|
function enableCatalog(ctx, id) {
|
|
2939
3144
|
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/enable`, { method: "POST" });
|
|
2940
3145
|
}
|
|
3146
|
+
function disableCatalog(ctx, id) {
|
|
3147
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/disable`, {
|
|
3148
|
+
method: "POST"
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
function deleteCatalog(ctx, id) {
|
|
3152
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
3153
|
+
}
|
|
3154
|
+
function testCatalogConnection(ctx, id) {
|
|
3155
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/test-connection`, {
|
|
3156
|
+
method: "POST"
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
2941
3159
|
function discoverCatalog(ctx, id, wait = true) {
|
|
2942
3160
|
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/discover`, {
|
|
2943
3161
|
method: "POST",
|
|
@@ -3407,7 +3625,7 @@ async function createFromCatalog(ctx, opts) {
|
|
|
3407
3625
|
}
|
|
3408
3626
|
tablePk[t.name] = res.pk;
|
|
3409
3627
|
}
|
|
3410
|
-
log(`
|
|
3628
|
+
log(`Resolving discovered resources for ${targets.length} table(s)...`);
|
|
3411
3629
|
const viewMap = {};
|
|
3412
3630
|
for (const t of targets) {
|
|
3413
3631
|
const found = asArray(
|
|
@@ -3417,13 +3635,9 @@ async function createFromCatalog(ctx, opts) {
|
|
|
3417
3635
|
if (existingId) {
|
|
3418
3636
|
viewMap[t.name] = existingId;
|
|
3419
3637
|
} else {
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
sourceIdentifier: t.name,
|
|
3424
|
-
fields: t.columns.map((c) => ({ name: c.name, type: c.type }))
|
|
3425
|
-
});
|
|
3426
|
-
viewMap[t.name] = String(created.id ?? "");
|
|
3638
|
+
throw new Error(
|
|
3639
|
+
`Table '${t.name}' has no discovered Vega resource. Run catalog discover and retry.`
|
|
3640
|
+
);
|
|
3427
3641
|
}
|
|
3428
3642
|
}
|
|
3429
3643
|
const knCreated = await createKnowledgeNetwork(ctx, { name: opts.name });
|
|
@@ -3455,12 +3669,14 @@ async function createFromCatalog(ctx, opts) {
|
|
|
3455
3669
|
log("Submitting build tasks...");
|
|
3456
3670
|
for (const t of targets) {
|
|
3457
3671
|
const embedding = opts.embeddingFields?.[t.name];
|
|
3672
|
+
await configureResourceIndex(ctx, viewMap[t.name], {
|
|
3673
|
+
buildKeyFields: [tablePk[t.name]],
|
|
3674
|
+
...embedding && embedding.length > 0 ? { embeddingFields: embedding } : {},
|
|
3675
|
+
...opts.embeddingModel ? { embeddingModel: opts.embeddingModel } : {}
|
|
3676
|
+
});
|
|
3458
3677
|
const task = await createBuildTask(ctx, {
|
|
3459
3678
|
resource_id: viewMap[t.name],
|
|
3460
|
-
mode: "batch"
|
|
3461
|
-
build_key_fields: [tablePk[t.name]],
|
|
3462
|
-
...embedding && embedding.length > 0 ? { embedding_fields: embedding } : {},
|
|
3463
|
-
...opts.embeddingModel ? { embedding_model: opts.embeddingModel } : {}
|
|
3679
|
+
mode: "batch"
|
|
3464
3680
|
});
|
|
3465
3681
|
builds.push({ table: t.name, taskId: String(task.id ?? "") });
|
|
3466
3682
|
}
|
|
@@ -3638,12 +3854,19 @@ function kn(ctx) {
|
|
|
3638
3854
|
const targets = collectIndexTargets(dir);
|
|
3639
3855
|
const buildTasks = [];
|
|
3640
3856
|
for (const t of targets) {
|
|
3857
|
+
if (!t.buildKey) {
|
|
3858
|
+
throw new Error(
|
|
3859
|
+
`Object type '${t.objectType}' declares a vector index but no build key; batch Vega builds require resource index_config.build_key_fields.`
|
|
3860
|
+
);
|
|
3861
|
+
}
|
|
3862
|
+
await configureResourceIndex(ctx, t.resourceId, {
|
|
3863
|
+
buildKeyFields: [t.buildKey],
|
|
3864
|
+
embeddingFields: t.embeddingFields,
|
|
3865
|
+
...t.embeddingModel ?? opts.embeddingModel ? { embeddingModel: t.embeddingModel ?? opts.embeddingModel } : {}
|
|
3866
|
+
});
|
|
3641
3867
|
const task = await createBuildTask(ctx, {
|
|
3642
3868
|
resource_id: t.resourceId,
|
|
3643
|
-
mode: "batch"
|
|
3644
|
-
embedding_fields: t.embeddingFields,
|
|
3645
|
-
...t.buildKey ? { build_key_fields: [t.buildKey] } : {},
|
|
3646
|
-
...t.embeddingModel ?? opts.embeddingModel ? { embedding_model: t.embeddingModel ?? opts.embeddingModel } : {}
|
|
3869
|
+
mode: "batch"
|
|
3647
3870
|
});
|
|
3648
3871
|
buildTasks.push({
|
|
3649
3872
|
objectType: t.objectType,
|
|
@@ -3822,6 +4045,8 @@ function resources(ctx) {
|
|
|
3822
4045
|
list: (opts) => listResources2(ctx, opts),
|
|
3823
4046
|
get: (id) => getResource(ctx, id),
|
|
3824
4047
|
delete: (id) => deleteResource(ctx, id),
|
|
4048
|
+
update: (id, patch) => updateResource(ctx, id, patch),
|
|
4049
|
+
configureIndex: (id, opts) => configureResourceIndex(ctx, id, opts),
|
|
3825
4050
|
find: (name, opts) => findResource(ctx, name, opts),
|
|
3826
4051
|
query: (id, opts) => queryResource(ctx, id, opts)
|
|
3827
4052
|
};
|
|
@@ -4234,7 +4459,7 @@ async function getSpansByConversation(ctx, conversationId, opts = {}) {
|
|
|
4234
4459
|
return (spans.hits?.hits ?? []).map((h) => h._source ?? {});
|
|
4235
4460
|
}
|
|
4236
4461
|
|
|
4237
|
-
// src/trace
|
|
4462
|
+
// src/bkn-trace/claude-judge.ts
|
|
4238
4463
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
|
|
4239
4464
|
var ClaudeJudgeError = class extends Error {
|
|
4240
4465
|
constructor(message, reason) {
|
|
@@ -4316,7 +4541,7 @@ async function judgeJson(prompt, opts = {}) {
|
|
|
4316
4541
|
return JSON.parse(extractJsonObject(text));
|
|
4317
4542
|
}
|
|
4318
4543
|
|
|
4319
|
-
// src/trace
|
|
4544
|
+
// src/bkn-trace/diagnose.ts
|
|
4320
4545
|
var KIND_MAP = {
|
|
4321
4546
|
chat: "llm",
|
|
4322
4547
|
text_completion: "llm",
|
|
@@ -4710,7 +4935,7 @@ function renderReportMarkdown(r) {
|
|
|
4710
4935
|
return lines.join("\n");
|
|
4711
4936
|
}
|
|
4712
4937
|
|
|
4713
|
-
// src/trace
|
|
4938
|
+
// src/bkn-trace/eval-set.ts
|
|
4714
4939
|
function hashId(s) {
|
|
4715
4940
|
let h = 5381;
|
|
4716
4941
|
for (let i = 0; i < s.length; i++) h = h * 33 ^ s.charCodeAt(i);
|
|
@@ -4974,7 +5199,11 @@ function vega(ctx) {
|
|
|
4974
5199
|
catalogs: (opts) => listCatalogs(ctx, opts),
|
|
4975
5200
|
getCatalog: (id) => getCatalog(ctx, id),
|
|
4976
5201
|
createCatalog: (req) => createCatalog(ctx, req),
|
|
5202
|
+
updateCatalog: (id, req) => updateCatalog(ctx, id, req),
|
|
4977
5203
|
enableCatalog: (id) => enableCatalog(ctx, id),
|
|
5204
|
+
disableCatalog: (id) => disableCatalog(ctx, id),
|
|
5205
|
+
deleteCatalog: (id) => deleteCatalog(ctx, id),
|
|
5206
|
+
testCatalogConnection: (id) => testCatalogConnection(ctx, id),
|
|
4978
5207
|
discoverCatalog: (id, wait = false) => discoverCatalog(ctx, id, wait),
|
|
4979
5208
|
catalogResources: (id, category) => listCatalogResources(ctx, id, category),
|
|
4980
5209
|
catalogHealth: (ids) => catalogHealthStatus(ctx, ids),
|
|
@@ -4988,7 +5217,11 @@ function vega(ctx) {
|
|
|
4988
5217
|
if (!opts.wait) return task;
|
|
4989
5218
|
return pollBuildTask(ctx, task.id, opts.timeoutMs ?? 3e5, opts.intervalMs ?? 2e3);
|
|
4990
5219
|
},
|
|
4991
|
-
buildStatus: (taskId) => getBuildTask(ctx, taskId)
|
|
5220
|
+
buildStatus: (taskId) => getBuildTask(ctx, taskId),
|
|
5221
|
+
buildTasks: (opts) => listBuildTasks(ctx, opts),
|
|
5222
|
+
deleteBuildTasks: (ids, opts) => deleteBuildTasks(ctx, ids, opts),
|
|
5223
|
+
startBuildTask: (taskId, opts) => startBuildTask(ctx, taskId, opts),
|
|
5224
|
+
stopBuildTask: (taskId) => stopBuildTask(ctx, taskId)
|
|
4992
5225
|
};
|
|
4993
5226
|
}
|
|
4994
5227
|
async function pollBuildTask(ctx, taskId, timeoutMs, intervalMs) {
|
|
@@ -5346,4 +5579,4 @@ export {
|
|
|
5346
5579
|
exportCreds,
|
|
5347
5580
|
auth_exports
|
|
5348
5581
|
};
|
|
5349
|
-
//# sourceMappingURL=chunk-
|
|
5582
|
+
//# sourceMappingURL=chunk-LCOMMFH7.js.map
|