@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/dist/index.d.ts CHANGED
@@ -58,6 +58,54 @@ interface RawCallResult {
58
58
  body: string;
59
59
  }
60
60
 
61
+ /**
62
+ * bkn-safe admin API (`/api/safe/v1/admin/*`, token-gated; the gateway-exposed
63
+ * replacement for the retired ISF UserManagement / Authorization / EACP). The
64
+ * logged-in user must be an admin: 401 = no/invalid token, 403 = not an admin.
65
+ * Only `audit list` has no endpoint (login-log retired by design). Response
66
+ * shapes: `{users|roles|departments, total}`; department `parent_id` (not the
67
+ * ISF `parent_deps[]`). See docs/exec-plans/admin-bkn-safe-migration.md.
68
+ * Also carries the cluster license hub (`/admin/license/*`, issue #224).
69
+ */
70
+
71
+ /** licverify judgement states. `invalid` also covers "no license installed". */
72
+ type LicenseState = "valid" | "grace" | "fallback_community" | "invalid";
73
+ /** GET /admin/license response (admin detail view). */
74
+ interface LicenseDetail {
75
+ state: LicenseState;
76
+ /** Whether the installed license is fingerprint-bound to this instance. */
77
+ activated: boolean;
78
+ /** This cluster's machine code (present even with no license installed). */
79
+ instance_fp: string;
80
+ error?: string;
81
+ /** Background auto-renew failure — license itself may still be valid. */
82
+ renew_error?: string;
83
+ edition?: string;
84
+ lic_id?: string;
85
+ customer?: {
86
+ name?: string;
87
+ [k: string]: unknown;
88
+ };
89
+ /** Unix seconds; expires_at 0 = never expires (community). */
90
+ issued_at?: number;
91
+ expires_at?: number;
92
+ contract_expires_at?: number;
93
+ /** Only present in `grace` state. */
94
+ grace_remaining_days?: number;
95
+ features?: string[];
96
+ limits?: Record<string, number>;
97
+ }
98
+ /**
99
+ * Import outcome. Plain success = the stored license's detail. `stored: true`
100
+ * = the .lic was verified and stored, but issuer activation failed (HTTP
101
+ * 409/502) — both facts matter, the import is not lost.
102
+ */
103
+ type LicenseImportResult = LicenseDetail | {
104
+ stored: true;
105
+ error: string;
106
+ license: LicenseDetail;
107
+ };
108
+
61
109
  /**
62
110
  * Admin (operator) client — user-management + authorization.
63
111
  * Reads and writes (org/user create/update/delete +
@@ -184,6 +232,17 @@ declare function admin(ctx: RequestContext): {
184
232
  ok: true;
185
233
  }>;
186
234
  auditList: (_opts?: AuditListOptions) => never;
235
+ licenseGet: () => Promise<LicenseDetail>;
236
+ licenseImport: (licenseText: string, opts?: {
237
+ receipt?: boolean;
238
+ }) => Promise<LicenseImportResult>;
239
+ licenseActivate: () => Promise<LicenseDetail>;
240
+ licenseRemove: () => Promise<{
241
+ ok: true;
242
+ }>;
243
+ licenseFingerprint: () => Promise<{
244
+ instance_fp: string;
245
+ }>;
187
246
  };
188
247
 
189
248
  interface ChatResult {
@@ -320,6 +379,8 @@ interface SearchSchemaOptions {
320
379
  searchScope?: string[];
321
380
  maxConcepts?: number;
322
381
  }
382
+ /** Progressive KN-detail disclosure level: `summary` (skeleton + property names) | `full`. */
383
+ type DetailLevel = "summary" | "full";
323
384
 
324
385
  /** Context-loader resource surface (MCP over agent-retrieval). */
325
386
 
@@ -327,6 +388,9 @@ declare function context(ctx: RequestContext): {
327
388
  searchSchema: (knId: string, query: string, opts?: SearchSchemaOptions) => Promise<unknown>;
328
389
  queryObjectInstance: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
329
390
  findSkills: (knId: string, objectTypeId: string, topK?: number) => Promise<unknown>;
391
+ knDetail: (knId: string, detailLevel?: DetailLevel) => Promise<unknown>;
392
+ objectTypes: (knId: string, ids: string[]) => Promise<unknown>;
393
+ relationTypes: (knId: string, ids: string[]) => Promise<unknown>;
330
394
  info: () => Promise<unknown>;
331
395
  tools: (knId: string) => Promise<unknown>;
332
396
  toolCall: (knId: string, name: string, args: Record<string, unknown>) => Promise<unknown>;
@@ -431,7 +495,7 @@ interface CreateFromCatalogOptions {
431
495
  tables?: string[];
432
496
  pkMap?: Record<string, string>;
433
497
  build?: boolean;
434
- /** Per-table resource columns to vectorize (sets the build task's embedding_fields). */
498
+ /** Per-table resource columns to vectorize (sets resource schema index features). */
435
499
  embeddingFields?: Record<string, string[]>;
436
500
  embeddingModel?: string;
437
501
  noRollback?: boolean;
@@ -582,13 +646,74 @@ declare function models(ctx: RequestContext): {
582
646
  * Responses passed through as parsed JSON.
583
647
  */
584
648
 
649
+ interface PropertyFeature {
650
+ name?: string;
651
+ display_name?: string;
652
+ feature_type: "keyword" | "fulltext" | "vector" | string;
653
+ description?: string;
654
+ ref_property?: string;
655
+ is_default?: boolean;
656
+ is_native?: boolean;
657
+ config?: Record<string, unknown>;
658
+ }
659
+ interface ResourceProperty {
660
+ name: string;
661
+ display_name?: string;
662
+ type?: string;
663
+ description?: string;
664
+ original_name?: string;
665
+ original_type?: string;
666
+ original_description?: string;
667
+ features?: PropertyFeature[];
668
+ attributes?: Record<string, unknown>;
669
+ extensions?: Record<string, string>;
670
+ }
671
+ interface ResourceIndexConfig {
672
+ build_key_fields?: string[];
673
+ default_fulltext_analyzer?: string;
674
+ default_embedding_model?: string;
675
+ }
585
676
  interface ListResourcesOptions {
586
677
  datasourceId?: string;
587
678
  name?: string;
588
679
  /** Resource category, e.g. table | logicview. */
589
680
  category?: string;
681
+ status?: string;
682
+ database?: string;
590
683
  limit?: number;
684
+ offset?: number;
685
+ sort?: "name" | "create_time" | "update_time" | string;
686
+ direction?: "asc" | "desc";
687
+ includeExtensions?: boolean;
688
+ includeExtensionKeys?: string;
689
+ extensionPairs?: Array<{
690
+ key: string;
691
+ value: string;
692
+ }>;
693
+ }
694
+ interface UpdateResourceOptions {
695
+ name?: string;
696
+ catalogId?: string;
697
+ tags?: string[];
698
+ description?: string;
699
+ category?: string;
700
+ status?: string;
701
+ database?: string;
702
+ sourceIdentifier?: string;
703
+ sourceMetadata?: Record<string, unknown>;
704
+ schemaDefinition?: ResourceProperty[];
705
+ indexConfig?: ResourceIndexConfig | null;
706
+ logicDefinition?: unknown;
707
+ extensions?: Record<string, string>;
708
+ }
709
+ interface ConfigureResourceIndexOptions {
710
+ buildKeyFields?: string[];
711
+ embeddingFields?: string[];
712
+ embeddingModel?: string;
713
+ fulltextFields?: string[];
714
+ fulltextAnalyzer?: string;
591
715
  }
716
+ declare function configureResourceIndex(ctx: RequestContext, id: string, opts: ConfigureResourceIndexOptions): Promise<unknown>;
592
717
  interface FindResourceOptions {
593
718
  datasourceId?: string;
594
719
  /** Exact name match instead of fuzzy. */
@@ -606,6 +731,8 @@ declare function resources(ctx: RequestContext): {
606
731
  list: (opts?: ListResourcesOptions) => Promise<unknown>;
607
732
  get: (id: string) => Promise<unknown>;
608
733
  delete: (id: string) => Promise<unknown>;
734
+ update: (id: string, patch: UpdateResourceOptions) => Promise<unknown>;
735
+ configureIndex: (id: string, opts: Parameters<typeof configureResourceIndex>[2]) => Promise<unknown>;
609
736
  find: (name: string, opts?: FindResourceOptions) => Promise<unknown>;
610
737
  query: (id: string, opts?: QueryResourceOptions) => Promise<unknown>;
611
738
  };
@@ -828,7 +955,8 @@ declare function trace(ctx: RequestContext): {
828
955
 
829
956
  /**
830
957
  * Vega backend client — catalog/resource reads + BuildTask (index build).
831
- * Build config lives on the task (CreateBuildTaskRequest), per the platform model.
958
+ * Build config is snapshotted from the Resource's schema_definition/features and
959
+ * index_config when the BuildTask is created.
832
960
  */
833
961
 
834
962
  declare const BuildMode: z.ZodEnum<["batch", "streaming"]>;
@@ -837,24 +965,15 @@ type BuildMode = z.infer<typeof BuildMode>;
837
965
  declare const CreateBuildTaskRequest: z.ZodObject<{
838
966
  resource_id: z.ZodString;
839
967
  mode: z.ZodEnum<["batch", "streaming"]>;
840
- embedding_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
841
- build_key_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
842
- embedding_model: z.ZodOptional<z.ZodString>;
843
- model_dimensions: z.ZodOptional<z.ZodNumber>;
968
+ execute_type: z.ZodOptional<z.ZodEnum<["incremental", "full"]>>;
844
969
  }, "strip", z.ZodTypeAny, {
845
970
  mode: "batch" | "streaming";
846
971
  resource_id: string;
847
- embedding_fields?: string[] | undefined;
848
- build_key_fields?: string[] | undefined;
849
- embedding_model?: string | undefined;
850
- model_dimensions?: number | undefined;
972
+ execute_type?: "full" | "incremental" | undefined;
851
973
  }, {
852
974
  mode: "batch" | "streaming";
853
975
  resource_id: string;
854
- embedding_fields?: string[] | undefined;
855
- build_key_fields?: string[] | undefined;
856
- embedding_model?: string | undefined;
857
- model_dimensions?: number | undefined;
976
+ execute_type?: "full" | "incremental" | undefined;
858
977
  }>;
859
978
  type CreateBuildTaskRequest = z.infer<typeof CreateBuildTaskRequest>;
860
979
  declare const BuildTask: z.ZodObject<{
@@ -866,10 +985,21 @@ declare const BuildTask: z.ZodObject<{
866
985
  total_count: z.ZodOptional<z.ZodNumber>;
867
986
  synced_count: z.ZodOptional<z.ZodNumber>;
868
987
  vectorized_count: z.ZodOptional<z.ZodNumber>;
869
- embedding_fields: z.ZodOptional<z.ZodString>;
870
- build_key_fields: z.ZodOptional<z.ZodString>;
871
- embedding_model: z.ZodOptional<z.ZodString>;
872
- model_dimensions: z.ZodOptional<z.ZodNumber>;
988
+ index_config: z.ZodOptional<z.ZodUnknown>;
989
+ catalog_id: z.ZodOptional<z.ZodString>;
990
+ index_health: z.ZodOptional<z.ZodObject<{
991
+ embedding: z.ZodString;
992
+ fulltext: z.ZodString;
993
+ usable: z.ZodBoolean;
994
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
995
+ embedding: z.ZodString;
996
+ fulltext: z.ZodString;
997
+ usable: z.ZodBoolean;
998
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
999
+ embedding: z.ZodString;
1000
+ fulltext: z.ZodString;
1001
+ usable: z.ZodBoolean;
1002
+ }, z.ZodTypeAny, "passthrough">>>;
873
1003
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
874
1004
  id: z.ZodString;
875
1005
  resource_id: z.ZodOptional<z.ZodString>;
@@ -879,10 +1009,21 @@ declare const BuildTask: z.ZodObject<{
879
1009
  total_count: z.ZodOptional<z.ZodNumber>;
880
1010
  synced_count: z.ZodOptional<z.ZodNumber>;
881
1011
  vectorized_count: z.ZodOptional<z.ZodNumber>;
882
- embedding_fields: z.ZodOptional<z.ZodString>;
883
- build_key_fields: z.ZodOptional<z.ZodString>;
884
- embedding_model: z.ZodOptional<z.ZodString>;
885
- model_dimensions: z.ZodOptional<z.ZodNumber>;
1012
+ index_config: z.ZodOptional<z.ZodUnknown>;
1013
+ catalog_id: z.ZodOptional<z.ZodString>;
1014
+ index_health: z.ZodOptional<z.ZodObject<{
1015
+ embedding: z.ZodString;
1016
+ fulltext: z.ZodString;
1017
+ usable: z.ZodBoolean;
1018
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
1019
+ embedding: z.ZodString;
1020
+ fulltext: z.ZodString;
1021
+ usable: z.ZodBoolean;
1022
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
1023
+ embedding: z.ZodString;
1024
+ fulltext: z.ZodString;
1025
+ usable: z.ZodBoolean;
1026
+ }, z.ZodTypeAny, "passthrough">>>;
886
1027
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
887
1028
  id: z.ZodString;
888
1029
  resource_id: z.ZodOptional<z.ZodString>;
@@ -892,21 +1033,48 @@ declare const BuildTask: z.ZodObject<{
892
1033
  total_count: z.ZodOptional<z.ZodNumber>;
893
1034
  synced_count: z.ZodOptional<z.ZodNumber>;
894
1035
  vectorized_count: z.ZodOptional<z.ZodNumber>;
895
- embedding_fields: z.ZodOptional<z.ZodString>;
896
- build_key_fields: z.ZodOptional<z.ZodString>;
897
- embedding_model: z.ZodOptional<z.ZodString>;
898
- model_dimensions: z.ZodOptional<z.ZodNumber>;
1036
+ index_config: z.ZodOptional<z.ZodUnknown>;
1037
+ catalog_id: z.ZodOptional<z.ZodString>;
1038
+ index_health: z.ZodOptional<z.ZodObject<{
1039
+ embedding: z.ZodString;
1040
+ fulltext: z.ZodString;
1041
+ usable: z.ZodBoolean;
1042
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
1043
+ embedding: z.ZodString;
1044
+ fulltext: z.ZodString;
1045
+ usable: z.ZodBoolean;
1046
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
1047
+ embedding: z.ZodString;
1048
+ fulltext: z.ZodString;
1049
+ usable: z.ZodBoolean;
1050
+ }, z.ZodTypeAny, "passthrough">>>;
899
1051
  }, z.ZodTypeAny, "passthrough">>;
900
1052
  type BuildTask = z.infer<typeof BuildTask>;
1053
+ interface ListBuildTasksOptions {
1054
+ limit?: number;
1055
+ offset?: number;
1056
+ resourceId?: string;
1057
+ catalogId?: string;
1058
+ status?: string | string[];
1059
+ active?: boolean;
1060
+ mode?: BuildMode;
1061
+ orderBy?: "default" | "created_at" | "updated_at" | "status" | "mode";
1062
+ order?: "asc" | "desc";
1063
+ }
1064
+ interface DeleteBuildTasksOptions {
1065
+ ignoreMissing?: boolean;
1066
+ deleteActiveIndex?: boolean;
1067
+ }
901
1068
  interface SqlQueryRequest {
902
1069
  /** SQL string (MySQL/MariaDB/PostgreSQL) or an OpenSearch DSL object. */
903
1070
  query: string | Record<string, unknown>;
1071
+ /** Query mode. `stream` uses cursor-style paging through `query_id`. */
1072
+ query_type?: "standard" | "stream";
904
1073
  /**
905
- * Source type (mysql | mariadb | postgresql | opensearch …). Optional — when
906
- * the query carries a `{{<resource-id>}}` placeholder the backend infers the
907
- * type from that resource's Catalog connector. Pass it only to override.
1074
+ * Source type (mysql | mariadb | postgresql | opensearch …). Required by the
1075
+ * current vega-backend raw query handler.
908
1076
  */
909
- resource_type?: string;
1077
+ resource_type: string;
910
1078
  /** Streaming batch size (100–10000, default server-side). */
911
1079
  stream_size?: number;
912
1080
  /** Query timeout in seconds (1–3600). */
@@ -917,6 +1085,19 @@ interface SqlQueryRequest {
917
1085
  interface ListCatalogsOptions {
918
1086
  limit?: number;
919
1087
  offset?: number;
1088
+ name?: string;
1089
+ tag?: string;
1090
+ type?: "physical" | "logical" | string;
1091
+ enabled?: boolean;
1092
+ healthCheckStatus?: string;
1093
+ includeExtensions?: boolean;
1094
+ includeExtensionKeys?: string;
1095
+ extensionPairs?: Array<{
1096
+ key: string;
1097
+ value: string;
1098
+ }>;
1099
+ sort?: "name" | "create_time" | "update_time" | string;
1100
+ direction?: "asc" | "desc";
920
1101
  }
921
1102
  /** POST /catalogs body. `connector_config` shape varies by connector (raw passthrough). */
922
1103
  interface CreateCatalogRequest {
@@ -926,13 +1107,20 @@ interface CreateCatalogRequest {
926
1107
  tags?: string[];
927
1108
  description?: string;
928
1109
  enabled?: boolean;
1110
+ id?: string;
1111
+ internal?: boolean;
1112
+ extensions?: Record<string, string>;
929
1113
  }
930
1114
 
931
1115
  declare function vega(ctx: RequestContext): {
932
1116
  catalogs: (opts?: ListCatalogsOptions) => Promise<unknown>;
933
1117
  getCatalog: (id: string) => Promise<unknown>;
934
1118
  createCatalog: (req: CreateCatalogRequest) => Promise<unknown>;
1119
+ updateCatalog: (id: string, req: Partial<CreateCatalogRequest>) => Promise<unknown>;
935
1120
  enableCatalog: (id: string) => Promise<unknown>;
1121
+ disableCatalog: (id: string) => Promise<unknown>;
1122
+ deleteCatalog: (id: string) => Promise<unknown>;
1123
+ testCatalogConnection: (id: string) => Promise<unknown>;
936
1124
  discoverCatalog: (id: string, wait?: boolean) => Promise<unknown>;
937
1125
  catalogResources: (id: string, category?: string) => Promise<unknown>;
938
1126
  catalogHealth: (ids: string[]) => Promise<unknown>;
@@ -955,11 +1143,28 @@ declare function vega(ctx: RequestContext): {
955
1143
  total_count: zod.ZodOptional<zod.ZodNumber>;
956
1144
  synced_count: zod.ZodOptional<zod.ZodNumber>;
957
1145
  vectorized_count: zod.ZodOptional<zod.ZodNumber>;
958
- embedding_fields: zod.ZodOptional<zod.ZodString>;
959
- build_key_fields: zod.ZodOptional<zod.ZodString>;
960
- embedding_model: zod.ZodOptional<zod.ZodString>;
961
- model_dimensions: zod.ZodOptional<zod.ZodNumber>;
1146
+ index_config: zod.ZodOptional<zod.ZodUnknown>;
1147
+ catalog_id: zod.ZodOptional<zod.ZodString>;
1148
+ index_health: zod.ZodOptional<zod.ZodObject<{
1149
+ embedding: zod.ZodString;
1150
+ fulltext: zod.ZodString;
1151
+ usable: zod.ZodBoolean;
1152
+ }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
1153
+ embedding: zod.ZodString;
1154
+ fulltext: zod.ZodString;
1155
+ usable: zod.ZodBoolean;
1156
+ }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
1157
+ embedding: zod.ZodString;
1158
+ fulltext: zod.ZodString;
1159
+ usable: zod.ZodBoolean;
1160
+ }, zod.ZodTypeAny, "passthrough">>>;
962
1161
  }, zod.ZodTypeAny, "passthrough">>;
1162
+ buildTasks: (opts?: ListBuildTasksOptions) => Promise<unknown>;
1163
+ deleteBuildTasks: (ids: string[], opts?: DeleteBuildTasksOptions) => Promise<unknown>;
1164
+ startBuildTask: (taskId: string, opts?: {
1165
+ reset?: boolean;
1166
+ }) => Promise<unknown>;
1167
+ stopBuildTask: (taskId: string) => Promise<unknown>;
963
1168
  };
964
1169
 
965
1170
  interface BknClient {
@@ -1145,7 +1350,7 @@ interface RequestInitEx {
1145
1350
  /** JSON body — serialized and Content-Type set automatically. */
1146
1351
  body?: unknown;
1147
1352
  /** Query params appended to the path. */
1148
- query?: Record<string, string | number | boolean | undefined>;
1353
+ query?: Record<string, string | number | boolean | Array<string | number | boolean> | undefined>;
1149
1354
  headers?: Record<string, string>;
1150
1355
  /** Per-request timeout; defaults to 30s. */
1151
1356
  timeoutMs?: number;
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  toolboxes,
20
20
  trace,
21
21
  vega
22
- } from "./chunk-KF3J46WL.js";
22
+ } from "./chunk-LCOMMFH7.js";
23
23
  export {
24
24
  DEFAULT_BUSINESS_DOMAIN,
25
25
  DEFAULT_LIST_LIMIT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openbkn/bkn-sdk",
3
- "version": "0.1.1-alpha.15",
3
+ "version": "0.1.1-alpha.18",
4
4
  "description": "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -18,7 +18,7 @@
18
18
  "import": "./dist/index.js"
19
19
  }
20
20
  },
21
- "files": ["dist", "README.md", "README.zh.md", "LICENSE"],
21
+ "files": ["dist", "README.md", "README.zh.md", "LICENSE", "NOTICE"],
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },