@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/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 {
@@ -436,7 +495,7 @@ interface CreateFromCatalogOptions {
436
495
  tables?: string[];
437
496
  pkMap?: Record<string, string>;
438
497
  build?: boolean;
439
- /** 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). */
440
499
  embeddingFields?: Record<string, string[]>;
441
500
  embeddingModel?: string;
442
501
  noRollback?: boolean;
@@ -587,13 +646,74 @@ declare function models(ctx: RequestContext): {
587
646
  * Responses passed through as parsed JSON.
588
647
  */
589
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
+ }
590
676
  interface ListResourcesOptions {
591
677
  datasourceId?: string;
592
678
  name?: string;
593
679
  /** Resource category, e.g. table | logicview. */
594
680
  category?: string;
681
+ status?: string;
682
+ database?: string;
595
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;
596
715
  }
716
+ declare function configureResourceIndex(ctx: RequestContext, id: string, opts: ConfigureResourceIndexOptions): Promise<unknown>;
597
717
  interface FindResourceOptions {
598
718
  datasourceId?: string;
599
719
  /** Exact name match instead of fuzzy. */
@@ -611,6 +731,8 @@ declare function resources(ctx: RequestContext): {
611
731
  list: (opts?: ListResourcesOptions) => Promise<unknown>;
612
732
  get: (id: string) => Promise<unknown>;
613
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>;
614
736
  find: (name: string, opts?: FindResourceOptions) => Promise<unknown>;
615
737
  query: (id: string, opts?: QueryResourceOptions) => Promise<unknown>;
616
738
  };
@@ -833,7 +955,8 @@ declare function trace(ctx: RequestContext): {
833
955
 
834
956
  /**
835
957
  * Vega backend client — catalog/resource reads + BuildTask (index build).
836
- * 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.
837
960
  */
838
961
 
839
962
  declare const BuildMode: z.ZodEnum<["batch", "streaming"]>;
@@ -842,24 +965,15 @@ type BuildMode = z.infer<typeof BuildMode>;
842
965
  declare const CreateBuildTaskRequest: z.ZodObject<{
843
966
  resource_id: z.ZodString;
844
967
  mode: z.ZodEnum<["batch", "streaming"]>;
845
- embedding_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
846
- build_key_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
847
- embedding_model: z.ZodOptional<z.ZodString>;
848
- model_dimensions: z.ZodOptional<z.ZodNumber>;
968
+ execute_type: z.ZodOptional<z.ZodEnum<["incremental", "full"]>>;
849
969
  }, "strip", z.ZodTypeAny, {
850
970
  mode: "batch" | "streaming";
851
971
  resource_id: string;
852
- embedding_fields?: string[] | undefined;
853
- build_key_fields?: string[] | undefined;
854
- embedding_model?: string | undefined;
855
- model_dimensions?: number | undefined;
972
+ execute_type?: "full" | "incremental" | undefined;
856
973
  }, {
857
974
  mode: "batch" | "streaming";
858
975
  resource_id: string;
859
- embedding_fields?: string[] | undefined;
860
- build_key_fields?: string[] | undefined;
861
- embedding_model?: string | undefined;
862
- model_dimensions?: number | undefined;
976
+ execute_type?: "full" | "incremental" | undefined;
863
977
  }>;
864
978
  type CreateBuildTaskRequest = z.infer<typeof CreateBuildTaskRequest>;
865
979
  declare const BuildTask: z.ZodObject<{
@@ -871,10 +985,21 @@ declare const BuildTask: z.ZodObject<{
871
985
  total_count: z.ZodOptional<z.ZodNumber>;
872
986
  synced_count: z.ZodOptional<z.ZodNumber>;
873
987
  vectorized_count: z.ZodOptional<z.ZodNumber>;
874
- embedding_fields: z.ZodOptional<z.ZodString>;
875
- build_key_fields: z.ZodOptional<z.ZodString>;
876
- embedding_model: z.ZodOptional<z.ZodString>;
877
- 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">>>;
878
1003
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
879
1004
  id: z.ZodString;
880
1005
  resource_id: z.ZodOptional<z.ZodString>;
@@ -884,10 +1009,21 @@ declare const BuildTask: z.ZodObject<{
884
1009
  total_count: z.ZodOptional<z.ZodNumber>;
885
1010
  synced_count: z.ZodOptional<z.ZodNumber>;
886
1011
  vectorized_count: z.ZodOptional<z.ZodNumber>;
887
- embedding_fields: z.ZodOptional<z.ZodString>;
888
- build_key_fields: z.ZodOptional<z.ZodString>;
889
- embedding_model: z.ZodOptional<z.ZodString>;
890
- 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">>>;
891
1027
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
892
1028
  id: z.ZodString;
893
1029
  resource_id: z.ZodOptional<z.ZodString>;
@@ -897,21 +1033,48 @@ declare const BuildTask: z.ZodObject<{
897
1033
  total_count: z.ZodOptional<z.ZodNumber>;
898
1034
  synced_count: z.ZodOptional<z.ZodNumber>;
899
1035
  vectorized_count: z.ZodOptional<z.ZodNumber>;
900
- embedding_fields: z.ZodOptional<z.ZodString>;
901
- build_key_fields: z.ZodOptional<z.ZodString>;
902
- embedding_model: z.ZodOptional<z.ZodString>;
903
- 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">>>;
904
1051
  }, z.ZodTypeAny, "passthrough">>;
905
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
+ }
906
1068
  interface SqlQueryRequest {
907
1069
  /** SQL string (MySQL/MariaDB/PostgreSQL) or an OpenSearch DSL object. */
908
1070
  query: string | Record<string, unknown>;
1071
+ /** Query mode. `stream` uses cursor-style paging through `query_id`. */
1072
+ query_type?: "standard" | "stream";
909
1073
  /**
910
- * Source type (mysql | mariadb | postgresql | opensearch …). Optional — when
911
- * the query carries a `{{<resource-id>}}` placeholder the backend infers the
912
- * 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.
913
1076
  */
914
- resource_type?: string;
1077
+ resource_type: string;
915
1078
  /** Streaming batch size (100–10000, default server-side). */
916
1079
  stream_size?: number;
917
1080
  /** Query timeout in seconds (1–3600). */
@@ -922,6 +1085,19 @@ interface SqlQueryRequest {
922
1085
  interface ListCatalogsOptions {
923
1086
  limit?: number;
924
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";
925
1101
  }
926
1102
  /** POST /catalogs body. `connector_config` shape varies by connector (raw passthrough). */
927
1103
  interface CreateCatalogRequest {
@@ -931,13 +1107,20 @@ interface CreateCatalogRequest {
931
1107
  tags?: string[];
932
1108
  description?: string;
933
1109
  enabled?: boolean;
1110
+ id?: string;
1111
+ internal?: boolean;
1112
+ extensions?: Record<string, string>;
934
1113
  }
935
1114
 
936
1115
  declare function vega(ctx: RequestContext): {
937
1116
  catalogs: (opts?: ListCatalogsOptions) => Promise<unknown>;
938
1117
  getCatalog: (id: string) => Promise<unknown>;
939
1118
  createCatalog: (req: CreateCatalogRequest) => Promise<unknown>;
1119
+ updateCatalog: (id: string, req: Partial<CreateCatalogRequest>) => Promise<unknown>;
940
1120
  enableCatalog: (id: string) => Promise<unknown>;
1121
+ disableCatalog: (id: string) => Promise<unknown>;
1122
+ deleteCatalog: (id: string) => Promise<unknown>;
1123
+ testCatalogConnection: (id: string) => Promise<unknown>;
941
1124
  discoverCatalog: (id: string, wait?: boolean) => Promise<unknown>;
942
1125
  catalogResources: (id: string, category?: string) => Promise<unknown>;
943
1126
  catalogHealth: (ids: string[]) => Promise<unknown>;
@@ -960,11 +1143,28 @@ declare function vega(ctx: RequestContext): {
960
1143
  total_count: zod.ZodOptional<zod.ZodNumber>;
961
1144
  synced_count: zod.ZodOptional<zod.ZodNumber>;
962
1145
  vectorized_count: zod.ZodOptional<zod.ZodNumber>;
963
- embedding_fields: zod.ZodOptional<zod.ZodString>;
964
- build_key_fields: zod.ZodOptional<zod.ZodString>;
965
- embedding_model: zod.ZodOptional<zod.ZodString>;
966
- 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">>>;
967
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>;
968
1168
  };
969
1169
 
970
1170
  interface BknClient {
@@ -1150,7 +1350,7 @@ interface RequestInitEx {
1150
1350
  /** JSON body — serialized and Content-Type set automatically. */
1151
1351
  body?: unknown;
1152
1352
  /** Query params appended to the path. */
1153
- query?: Record<string, string | number | boolean | undefined>;
1353
+ query?: Record<string, string | number | boolean | Array<string | number | boolean> | undefined>;
1154
1354
  headers?: Record<string, string>;
1155
1355
  /** Per-request timeout; defaults to 30s. */
1156
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-SH2KLES5.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.16",
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",