@openbkn/bkn-sdk 0.1.1-alpha.16 → 0.1.1-alpha.19
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 +202 -132
- package/NOTICE +6 -16
- package/README.md +5 -9
- package/README.zh.md +5 -8
- package/dist/{chunk-SH2KLES5.js → chunk-ISJHU26W.js} +454 -147
- package/dist/cli.js +196 -96
- package/dist/index.d.ts +266 -58
- package/dist/index.js +1 -1
- package/package.json +6 -5
- package/dist/chunk-SH2KLES5.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,12 +59,64 @@ interface RawCallResult {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
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).
|
|
66
69
|
*/
|
|
67
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
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Admin (operator) input shapes — the CLI-facing contract for the `admin`
|
|
111
|
+
* command group. `src/resources/admin.ts` maps each of these onto the bkn-safe
|
|
112
|
+
* client in `./safe.ts`, which is where the requests live.
|
|
113
|
+
*
|
|
114
|
+
* The ISF clients that used to back these types (`/api/user-management/v1`,
|
|
115
|
+
* `/api/authorization/v1`, `/isfweb/api/ShareMgnt`, `/api/eacp/v1`) were removed
|
|
116
|
+
* once ISF was retired — see docs/exec-plans/admin-bkn-safe-migration.md. Some
|
|
117
|
+
* fields here are wider than bkn-safe accepts and are dropped in the mapping;
|
|
118
|
+
* that lossiness is documented in the migration plan.
|
|
119
|
+
*/
|
|
68
120
|
interface AdminListOptions {
|
|
69
121
|
role?: string;
|
|
70
122
|
offset?: number;
|
|
@@ -184,6 +236,17 @@ declare function admin(ctx: RequestContext): {
|
|
|
184
236
|
ok: true;
|
|
185
237
|
}>;
|
|
186
238
|
auditList: (_opts?: AuditListOptions) => never;
|
|
239
|
+
licenseGet: () => Promise<LicenseDetail>;
|
|
240
|
+
licenseImport: (licenseText: string, opts?: {
|
|
241
|
+
receipt?: boolean;
|
|
242
|
+
}) => Promise<LicenseImportResult>;
|
|
243
|
+
licenseActivate: () => Promise<LicenseDetail>;
|
|
244
|
+
licenseRemove: () => Promise<{
|
|
245
|
+
ok: true;
|
|
246
|
+
}>;
|
|
247
|
+
licenseFingerprint: () => Promise<{
|
|
248
|
+
instance_fp: string;
|
|
249
|
+
}>;
|
|
187
250
|
};
|
|
188
251
|
|
|
189
252
|
interface ChatResult {
|
|
@@ -436,7 +499,7 @@ interface CreateFromCatalogOptions {
|
|
|
436
499
|
tables?: string[];
|
|
437
500
|
pkMap?: Record<string, string>;
|
|
438
501
|
build?: boolean;
|
|
439
|
-
/** Per-table resource columns to vectorize (sets
|
|
502
|
+
/** Per-table resource columns to vectorize (sets resource schema index features). */
|
|
440
503
|
embeddingFields?: Record<string, string[]>;
|
|
441
504
|
embeddingModel?: string;
|
|
442
505
|
noRollback?: boolean;
|
|
@@ -587,13 +650,74 @@ declare function models(ctx: RequestContext): {
|
|
|
587
650
|
* Responses passed through as parsed JSON.
|
|
588
651
|
*/
|
|
589
652
|
|
|
653
|
+
interface PropertyFeature {
|
|
654
|
+
name?: string;
|
|
655
|
+
display_name?: string;
|
|
656
|
+
feature_type: "keyword" | "fulltext" | "vector" | string;
|
|
657
|
+
description?: string;
|
|
658
|
+
ref_property?: string;
|
|
659
|
+
is_default?: boolean;
|
|
660
|
+
is_native?: boolean;
|
|
661
|
+
config?: Record<string, unknown>;
|
|
662
|
+
}
|
|
663
|
+
interface ResourceProperty {
|
|
664
|
+
name: string;
|
|
665
|
+
display_name?: string;
|
|
666
|
+
type?: string;
|
|
667
|
+
description?: string;
|
|
668
|
+
original_name?: string;
|
|
669
|
+
original_type?: string;
|
|
670
|
+
original_description?: string;
|
|
671
|
+
features?: PropertyFeature[];
|
|
672
|
+
attributes?: Record<string, unknown>;
|
|
673
|
+
extensions?: Record<string, string>;
|
|
674
|
+
}
|
|
675
|
+
interface ResourceIndexConfig {
|
|
676
|
+
build_key_fields?: string[];
|
|
677
|
+
default_fulltext_analyzer?: string;
|
|
678
|
+
default_embedding_model?: string;
|
|
679
|
+
}
|
|
590
680
|
interface ListResourcesOptions {
|
|
591
681
|
datasourceId?: string;
|
|
592
682
|
name?: string;
|
|
593
683
|
/** Resource category, e.g. table | logicview. */
|
|
594
684
|
category?: string;
|
|
685
|
+
status?: string;
|
|
686
|
+
database?: string;
|
|
595
687
|
limit?: number;
|
|
688
|
+
offset?: number;
|
|
689
|
+
sort?: "name" | "create_time" | "update_time" | string;
|
|
690
|
+
direction?: "asc" | "desc";
|
|
691
|
+
includeExtensions?: boolean;
|
|
692
|
+
includeExtensionKeys?: string;
|
|
693
|
+
extensionPairs?: Array<{
|
|
694
|
+
key: string;
|
|
695
|
+
value: string;
|
|
696
|
+
}>;
|
|
697
|
+
}
|
|
698
|
+
interface UpdateResourceOptions {
|
|
699
|
+
name?: string;
|
|
700
|
+
catalogId?: string;
|
|
701
|
+
tags?: string[];
|
|
702
|
+
description?: string;
|
|
703
|
+
category?: string;
|
|
704
|
+
status?: string;
|
|
705
|
+
database?: string;
|
|
706
|
+
sourceIdentifier?: string;
|
|
707
|
+
sourceMetadata?: Record<string, unknown>;
|
|
708
|
+
schemaDefinition?: ResourceProperty[];
|
|
709
|
+
indexConfig?: ResourceIndexConfig | null;
|
|
710
|
+
logicDefinition?: unknown;
|
|
711
|
+
extensions?: Record<string, string>;
|
|
596
712
|
}
|
|
713
|
+
interface ConfigureResourceIndexOptions {
|
|
714
|
+
buildKeyFields?: string[];
|
|
715
|
+
embeddingFields?: string[];
|
|
716
|
+
embeddingModel?: string;
|
|
717
|
+
fulltextFields?: string[];
|
|
718
|
+
fulltextAnalyzer?: string;
|
|
719
|
+
}
|
|
720
|
+
declare function configureResourceIndex(ctx: RequestContext, id: string, opts: ConfigureResourceIndexOptions): Promise<unknown>;
|
|
597
721
|
interface FindResourceOptions {
|
|
598
722
|
datasourceId?: string;
|
|
599
723
|
/** Exact name match instead of fuzzy. */
|
|
@@ -611,6 +735,8 @@ declare function resources(ctx: RequestContext): {
|
|
|
611
735
|
list: (opts?: ListResourcesOptions) => Promise<unknown>;
|
|
612
736
|
get: (id: string) => Promise<unknown>;
|
|
613
737
|
delete: (id: string) => Promise<unknown>;
|
|
738
|
+
update: (id: string, patch: UpdateResourceOptions) => Promise<unknown>;
|
|
739
|
+
configureIndex: (id: string, opts: Parameters<typeof configureResourceIndex>[2]) => Promise<unknown>;
|
|
614
740
|
find: (name: string, opts?: FindResourceOptions) => Promise<unknown>;
|
|
615
741
|
query: (id: string, opts?: QueryResourceOptions) => Promise<unknown>;
|
|
616
742
|
};
|
|
@@ -833,7 +959,8 @@ declare function trace(ctx: RequestContext): {
|
|
|
833
959
|
|
|
834
960
|
/**
|
|
835
961
|
* Vega backend client — catalog/resource reads + BuildTask (index build).
|
|
836
|
-
* Build config
|
|
962
|
+
* Build config is snapshotted from the Resource's schema_definition/features and
|
|
963
|
+
* index_config when the BuildTask is created.
|
|
837
964
|
*/
|
|
838
965
|
|
|
839
966
|
declare const BuildMode: z.ZodEnum<["batch", "streaming"]>;
|
|
@@ -842,24 +969,15 @@ type BuildMode = z.infer<typeof BuildMode>;
|
|
|
842
969
|
declare const CreateBuildTaskRequest: z.ZodObject<{
|
|
843
970
|
resource_id: z.ZodString;
|
|
844
971
|
mode: z.ZodEnum<["batch", "streaming"]>;
|
|
845
|
-
|
|
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>;
|
|
972
|
+
execute_type: z.ZodOptional<z.ZodEnum<["incremental", "full"]>>;
|
|
849
973
|
}, "strip", z.ZodTypeAny, {
|
|
850
974
|
mode: "batch" | "streaming";
|
|
851
975
|
resource_id: string;
|
|
852
|
-
|
|
853
|
-
build_key_fields?: string[] | undefined;
|
|
854
|
-
embedding_model?: string | undefined;
|
|
855
|
-
model_dimensions?: number | undefined;
|
|
976
|
+
execute_type?: "full" | "incremental" | undefined;
|
|
856
977
|
}, {
|
|
857
978
|
mode: "batch" | "streaming";
|
|
858
979
|
resource_id: string;
|
|
859
|
-
|
|
860
|
-
build_key_fields?: string[] | undefined;
|
|
861
|
-
embedding_model?: string | undefined;
|
|
862
|
-
model_dimensions?: number | undefined;
|
|
980
|
+
execute_type?: "full" | "incremental" | undefined;
|
|
863
981
|
}>;
|
|
864
982
|
type CreateBuildTaskRequest = z.infer<typeof CreateBuildTaskRequest>;
|
|
865
983
|
declare const BuildTask: z.ZodObject<{
|
|
@@ -871,10 +989,21 @@ declare const BuildTask: z.ZodObject<{
|
|
|
871
989
|
total_count: z.ZodOptional<z.ZodNumber>;
|
|
872
990
|
synced_count: z.ZodOptional<z.ZodNumber>;
|
|
873
991
|
vectorized_count: z.ZodOptional<z.ZodNumber>;
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
992
|
+
index_config: z.ZodOptional<z.ZodUnknown>;
|
|
993
|
+
catalog_id: z.ZodOptional<z.ZodString>;
|
|
994
|
+
index_health: z.ZodOptional<z.ZodObject<{
|
|
995
|
+
embedding: z.ZodString;
|
|
996
|
+
fulltext: z.ZodString;
|
|
997
|
+
usable: z.ZodBoolean;
|
|
998
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
999
|
+
embedding: z.ZodString;
|
|
1000
|
+
fulltext: z.ZodString;
|
|
1001
|
+
usable: z.ZodBoolean;
|
|
1002
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1003
|
+
embedding: z.ZodString;
|
|
1004
|
+
fulltext: z.ZodString;
|
|
1005
|
+
usable: z.ZodBoolean;
|
|
1006
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
878
1007
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
879
1008
|
id: z.ZodString;
|
|
880
1009
|
resource_id: z.ZodOptional<z.ZodString>;
|
|
@@ -884,10 +1013,21 @@ declare const BuildTask: z.ZodObject<{
|
|
|
884
1013
|
total_count: z.ZodOptional<z.ZodNumber>;
|
|
885
1014
|
synced_count: z.ZodOptional<z.ZodNumber>;
|
|
886
1015
|
vectorized_count: z.ZodOptional<z.ZodNumber>;
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1016
|
+
index_config: z.ZodOptional<z.ZodUnknown>;
|
|
1017
|
+
catalog_id: z.ZodOptional<z.ZodString>;
|
|
1018
|
+
index_health: z.ZodOptional<z.ZodObject<{
|
|
1019
|
+
embedding: z.ZodString;
|
|
1020
|
+
fulltext: z.ZodString;
|
|
1021
|
+
usable: z.ZodBoolean;
|
|
1022
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1023
|
+
embedding: z.ZodString;
|
|
1024
|
+
fulltext: z.ZodString;
|
|
1025
|
+
usable: z.ZodBoolean;
|
|
1026
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1027
|
+
embedding: z.ZodString;
|
|
1028
|
+
fulltext: z.ZodString;
|
|
1029
|
+
usable: z.ZodBoolean;
|
|
1030
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
891
1031
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
892
1032
|
id: z.ZodString;
|
|
893
1033
|
resource_id: z.ZodOptional<z.ZodString>;
|
|
@@ -897,21 +1037,48 @@ declare const BuildTask: z.ZodObject<{
|
|
|
897
1037
|
total_count: z.ZodOptional<z.ZodNumber>;
|
|
898
1038
|
synced_count: z.ZodOptional<z.ZodNumber>;
|
|
899
1039
|
vectorized_count: z.ZodOptional<z.ZodNumber>;
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1040
|
+
index_config: z.ZodOptional<z.ZodUnknown>;
|
|
1041
|
+
catalog_id: z.ZodOptional<z.ZodString>;
|
|
1042
|
+
index_health: z.ZodOptional<z.ZodObject<{
|
|
1043
|
+
embedding: z.ZodString;
|
|
1044
|
+
fulltext: z.ZodString;
|
|
1045
|
+
usable: z.ZodBoolean;
|
|
1046
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1047
|
+
embedding: z.ZodString;
|
|
1048
|
+
fulltext: z.ZodString;
|
|
1049
|
+
usable: z.ZodBoolean;
|
|
1050
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1051
|
+
embedding: z.ZodString;
|
|
1052
|
+
fulltext: z.ZodString;
|
|
1053
|
+
usable: z.ZodBoolean;
|
|
1054
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
904
1055
|
}, z.ZodTypeAny, "passthrough">>;
|
|
905
1056
|
type BuildTask = z.infer<typeof BuildTask>;
|
|
1057
|
+
interface ListBuildTasksOptions {
|
|
1058
|
+
limit?: number;
|
|
1059
|
+
offset?: number;
|
|
1060
|
+
resourceId?: string;
|
|
1061
|
+
catalogId?: string;
|
|
1062
|
+
status?: string | string[];
|
|
1063
|
+
active?: boolean;
|
|
1064
|
+
mode?: BuildMode;
|
|
1065
|
+
orderBy?: "default" | "created_at" | "updated_at" | "status" | "mode";
|
|
1066
|
+
order?: "asc" | "desc";
|
|
1067
|
+
}
|
|
1068
|
+
interface DeleteBuildTasksOptions {
|
|
1069
|
+
ignoreMissing?: boolean;
|
|
1070
|
+
deleteActiveIndex?: boolean;
|
|
1071
|
+
}
|
|
906
1072
|
interface SqlQueryRequest {
|
|
907
1073
|
/** SQL string (MySQL/MariaDB/PostgreSQL) or an OpenSearch DSL object. */
|
|
908
1074
|
query: string | Record<string, unknown>;
|
|
1075
|
+
/** Query mode. `stream` uses cursor-style paging through `query_id`. */
|
|
1076
|
+
query_type?: "standard" | "stream";
|
|
909
1077
|
/**
|
|
910
|
-
* Source type (mysql | mariadb | postgresql | opensearch …).
|
|
911
|
-
*
|
|
912
|
-
* type from that resource's Catalog connector. Pass it only to override.
|
|
1078
|
+
* Source type (mysql | mariadb | postgresql | opensearch …). Required by the
|
|
1079
|
+
* current vega-backend raw query handler.
|
|
913
1080
|
*/
|
|
914
|
-
resource_type
|
|
1081
|
+
resource_type: string;
|
|
915
1082
|
/** Streaming batch size (100–10000, default server-side). */
|
|
916
1083
|
stream_size?: number;
|
|
917
1084
|
/** Query timeout in seconds (1–3600). */
|
|
@@ -922,6 +1089,19 @@ interface SqlQueryRequest {
|
|
|
922
1089
|
interface ListCatalogsOptions {
|
|
923
1090
|
limit?: number;
|
|
924
1091
|
offset?: number;
|
|
1092
|
+
name?: string;
|
|
1093
|
+
tag?: string;
|
|
1094
|
+
type?: "physical" | "logical" | string;
|
|
1095
|
+
enabled?: boolean;
|
|
1096
|
+
healthCheckStatus?: string;
|
|
1097
|
+
includeExtensions?: boolean;
|
|
1098
|
+
includeExtensionKeys?: string;
|
|
1099
|
+
extensionPairs?: Array<{
|
|
1100
|
+
key: string;
|
|
1101
|
+
value: string;
|
|
1102
|
+
}>;
|
|
1103
|
+
sort?: "name" | "create_time" | "update_time" | string;
|
|
1104
|
+
direction?: "asc" | "desc";
|
|
925
1105
|
}
|
|
926
1106
|
/** POST /catalogs body. `connector_config` shape varies by connector (raw passthrough). */
|
|
927
1107
|
interface CreateCatalogRequest {
|
|
@@ -931,13 +1111,20 @@ interface CreateCatalogRequest {
|
|
|
931
1111
|
tags?: string[];
|
|
932
1112
|
description?: string;
|
|
933
1113
|
enabled?: boolean;
|
|
1114
|
+
id?: string;
|
|
1115
|
+
internal?: boolean;
|
|
1116
|
+
extensions?: Record<string, string>;
|
|
934
1117
|
}
|
|
935
1118
|
|
|
936
1119
|
declare function vega(ctx: RequestContext): {
|
|
937
1120
|
catalogs: (opts?: ListCatalogsOptions) => Promise<unknown>;
|
|
938
1121
|
getCatalog: (id: string) => Promise<unknown>;
|
|
939
1122
|
createCatalog: (req: CreateCatalogRequest) => Promise<unknown>;
|
|
1123
|
+
updateCatalog: (id: string, req: Partial<CreateCatalogRequest>) => Promise<unknown>;
|
|
940
1124
|
enableCatalog: (id: string) => Promise<unknown>;
|
|
1125
|
+
disableCatalog: (id: string) => Promise<unknown>;
|
|
1126
|
+
deleteCatalog: (id: string) => Promise<unknown>;
|
|
1127
|
+
testCatalogConnection: (id: string) => Promise<unknown>;
|
|
941
1128
|
discoverCatalog: (id: string, wait?: boolean) => Promise<unknown>;
|
|
942
1129
|
catalogResources: (id: string, category?: string) => Promise<unknown>;
|
|
943
1130
|
catalogHealth: (ids: string[]) => Promise<unknown>;
|
|
@@ -960,11 +1147,28 @@ declare function vega(ctx: RequestContext): {
|
|
|
960
1147
|
total_count: zod.ZodOptional<zod.ZodNumber>;
|
|
961
1148
|
synced_count: zod.ZodOptional<zod.ZodNumber>;
|
|
962
1149
|
vectorized_count: zod.ZodOptional<zod.ZodNumber>;
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1150
|
+
index_config: zod.ZodOptional<zod.ZodUnknown>;
|
|
1151
|
+
catalog_id: zod.ZodOptional<zod.ZodString>;
|
|
1152
|
+
index_health: zod.ZodOptional<zod.ZodObject<{
|
|
1153
|
+
embedding: zod.ZodString;
|
|
1154
|
+
fulltext: zod.ZodString;
|
|
1155
|
+
usable: zod.ZodBoolean;
|
|
1156
|
+
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
1157
|
+
embedding: zod.ZodString;
|
|
1158
|
+
fulltext: zod.ZodString;
|
|
1159
|
+
usable: zod.ZodBoolean;
|
|
1160
|
+
}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
|
|
1161
|
+
embedding: zod.ZodString;
|
|
1162
|
+
fulltext: zod.ZodString;
|
|
1163
|
+
usable: zod.ZodBoolean;
|
|
1164
|
+
}, zod.ZodTypeAny, "passthrough">>>;
|
|
967
1165
|
}, zod.ZodTypeAny, "passthrough">>;
|
|
1166
|
+
buildTasks: (opts?: ListBuildTasksOptions) => Promise<unknown>;
|
|
1167
|
+
deleteBuildTasks: (ids: string[], opts?: DeleteBuildTasksOptions) => Promise<unknown>;
|
|
1168
|
+
startBuildTask: (taskId: string, opts?: {
|
|
1169
|
+
reset?: boolean;
|
|
1170
|
+
}) => Promise<unknown>;
|
|
1171
|
+
stopBuildTask: (taskId: string) => Promise<unknown>;
|
|
968
1172
|
};
|
|
969
1173
|
|
|
970
1174
|
interface BknClient {
|
|
@@ -1025,16 +1229,20 @@ interface TokenConfig {
|
|
|
1025
1229
|
refreshToken?: string;
|
|
1026
1230
|
idToken?: string;
|
|
1027
1231
|
expiresAt?: string;
|
|
1028
|
-
/** Skip TLS verification for this platform (saved by `auth login -k`). */
|
|
1029
|
-
tlsInsecure?: boolean;
|
|
1030
|
-
/** Platform has no auth stack (no bkn-safe) — requests carry no token. */
|
|
1031
|
-
noAuth?: boolean;
|
|
1032
1232
|
/** Login name persisted at login time (fallback when JWT lacks claims). */
|
|
1033
1233
|
username?: string;
|
|
1034
1234
|
/** Human-readable name from userinfo. */
|
|
1035
1235
|
displayName?: string;
|
|
1036
1236
|
}
|
|
1037
|
-
/**
|
|
1237
|
+
/**
|
|
1238
|
+
* userId from the token's JWT `sub` (id_token first), else "default".
|
|
1239
|
+
*
|
|
1240
|
+
* The `sub` is attacker-supplied — the JWT is never signature-checked — and it
|
|
1241
|
+
* becomes a path segment under `userDir`. An unconstrained one escapes the
|
|
1242
|
+
* store: `sub: "../../<other-platform>/users/default"` overwrites another
|
|
1243
|
+
* platform's saved token, so the victim's later commands there authenticate as
|
|
1244
|
+
* whoever issued this token. Constrain it the way BKN_PROFILE is constrained.
|
|
1245
|
+
*/
|
|
1038
1246
|
declare function userIdFromToken(token: TokenConfig): string;
|
|
1039
1247
|
interface PlatformUser {
|
|
1040
1248
|
userId: string;
|
|
@@ -1053,20 +1261,12 @@ declare function hostOf(baseUrl: string): string;
|
|
|
1053
1261
|
declare function attachToken(baseUrl: string, accessToken: string, opts?: {
|
|
1054
1262
|
refreshToken?: string;
|
|
1055
1263
|
idToken?: string;
|
|
1056
|
-
insecure?: boolean;
|
|
1057
1264
|
username?: string;
|
|
1058
1265
|
}): {
|
|
1059
1266
|
baseUrl: string;
|
|
1060
1267
|
userId: string;
|
|
1061
1268
|
username?: string;
|
|
1062
1269
|
};
|
|
1063
|
-
/** Register a no-auth platform session (no token; the platform has no bkn-safe). */
|
|
1064
|
-
declare function attachNoAuth(baseUrl: string, opts?: {
|
|
1065
|
-
insecure?: boolean;
|
|
1066
|
-
}): {
|
|
1067
|
-
baseUrl: string;
|
|
1068
|
-
noAuth: true;
|
|
1069
|
-
};
|
|
1070
1270
|
interface AuthStatus {
|
|
1071
1271
|
baseUrl?: string;
|
|
1072
1272
|
userId?: string;
|
|
@@ -1074,15 +1274,22 @@ interface AuthStatus {
|
|
|
1074
1274
|
username?: string;
|
|
1075
1275
|
expired?: boolean;
|
|
1076
1276
|
}
|
|
1077
|
-
declare function status(
|
|
1078
|
-
|
|
1277
|
+
declare function status(opts?: {
|
|
1278
|
+
user?: string;
|
|
1279
|
+
}): AuthStatus;
|
|
1280
|
+
declare function currentToken(opts?: {
|
|
1281
|
+
user?: string;
|
|
1282
|
+
}): string;
|
|
1079
1283
|
/**
|
|
1080
1284
|
* Like {@link currentToken} but proactively refreshes an expired access token
|
|
1081
1285
|
* when a refresh token is stored, persisting the result. API requests already
|
|
1082
1286
|
* refresh on a 401 (see api/http.ts); this covers the `auth token` getter,
|
|
1083
1287
|
* whose output is copied out and used elsewhere where no 401 retry can help.
|
|
1084
1288
|
*/
|
|
1085
|
-
declare function currentTokenFresh(
|
|
1289
|
+
declare function currentTokenFresh(opts?: {
|
|
1290
|
+
insecure?: boolean;
|
|
1291
|
+
user?: string;
|
|
1292
|
+
}): Promise<string>;
|
|
1086
1293
|
interface WhoamiResult extends JwtClaims {
|
|
1087
1294
|
/** Platform the active session belongs to. */
|
|
1088
1295
|
baseUrl?: string;
|
|
@@ -1091,7 +1298,9 @@ interface WhoamiResult extends JwtClaims {
|
|
|
1091
1298
|
/** Resolved account/login name — what `auth login` looked up and stored. */
|
|
1092
1299
|
username?: string;
|
|
1093
1300
|
}
|
|
1094
|
-
declare function whoami(
|
|
1301
|
+
declare function whoami(opts?: {
|
|
1302
|
+
user?: string;
|
|
1303
|
+
}): WhoamiResult;
|
|
1095
1304
|
interface PlatformListItem {
|
|
1096
1305
|
baseUrl: string;
|
|
1097
1306
|
userId: string;
|
|
@@ -1126,7 +1335,6 @@ declare function exportCreds(): {
|
|
|
1126
1335
|
type auth_AuthStatus = AuthStatus;
|
|
1127
1336
|
type auth_PlatformListItem = PlatformListItem;
|
|
1128
1337
|
type auth_WhoamiResult = WhoamiResult;
|
|
1129
|
-
declare const auth_attachNoAuth: typeof attachNoAuth;
|
|
1130
1338
|
declare const auth_attachToken: typeof attachToken;
|
|
1131
1339
|
declare const auth_currentToken: typeof currentToken;
|
|
1132
1340
|
declare const auth_currentTokenFresh: typeof currentTokenFresh;
|
|
@@ -1142,7 +1350,7 @@ declare const auth_userIdFromToken: typeof userIdFromToken;
|
|
|
1142
1350
|
declare const auth_usersOf: typeof usersOf;
|
|
1143
1351
|
declare const auth_whoami: typeof whoami;
|
|
1144
1352
|
declare namespace auth {
|
|
1145
|
-
export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, type auth_WhoamiResult as WhoamiResult,
|
|
1353
|
+
export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, type auth_WhoamiResult as WhoamiResult, auth_attachToken as attachToken, auth_currentToken as currentToken, auth_currentTokenFresh as currentTokenFresh, auth_deletePlatform as deletePlatform, auth_exportCreds as exportCreds, auth_hostOf as hostOf, auth_listPlatforms as listPlatforms, auth_logout as logout, auth_status as status, auth_switchUser as switchUser, auth_use as use, auth_userIdFromToken as userIdFromToken, auth_usersOf as usersOf, auth_whoami as whoami };
|
|
1146
1354
|
}
|
|
1147
1355
|
|
|
1148
1356
|
interface RequestInitEx {
|
|
@@ -1150,7 +1358,7 @@ interface RequestInitEx {
|
|
|
1150
1358
|
/** JSON body — serialized and Content-Type set automatically. */
|
|
1151
1359
|
body?: unknown;
|
|
1152
1360
|
/** Query params appended to the path. */
|
|
1153
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
1361
|
+
query?: Record<string, string | number | boolean | Array<string | number | boolean> | undefined>;
|
|
1154
1362
|
headers?: Record<string, string>;
|
|
1155
1363
|
/** Per-request timeout; defaults to 30s. */
|
|
1156
1364
|
timeoutMs?: number;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openbkn/bkn-sdk",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.19",
|
|
4
4
|
"description": "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=18"
|
|
9
9
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"import": "./dist/index.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"files": ["dist", "README.md", "README.zh.md", "LICENSE", "NOTICE"],
|
|
21
|
+
"files": ["dist", "!dist/**/*.map", "README.md", "README.zh.md", "LICENSE", "NOTICE"],
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"build": "tsup",
|
|
32
32
|
"dev": "tsup --watch",
|
|
33
33
|
"typecheck": "tsc --noEmit",
|
|
34
|
-
"
|
|
34
|
+
"check:deps": "node scripts/check-no-self-dep.mjs",
|
|
35
|
+
"lint": "npm run check:deps && biome check . && tsc --noEmit",
|
|
35
36
|
"format": "biome format --write .",
|
|
36
37
|
"test": "vitest run",
|
|
37
38
|
"test:cover": "vitest run --coverage",
|
|
@@ -40,12 +41,12 @@
|
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@clack/prompts": "^0.9.1",
|
|
43
|
-
"@openbkn/bkn-sdk": "^0.1.1-alpha.3",
|
|
44
44
|
"chalk": "^5.4.1",
|
|
45
45
|
"commander": "^13.1.0",
|
|
46
46
|
"csv-parse": "^6.2.1",
|
|
47
47
|
"js-yaml": "^4.2.0",
|
|
48
48
|
"jszip": "^3.10.1",
|
|
49
|
+
"undici": "^8.7.0",
|
|
49
50
|
"zod": "^3.24.1"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|