@openbkn/bkn-sdk 0.1.1-alpha.0 → 0.1.1-alpha.10
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/{chunk-DXA44XWY.js → chunk-GNL6Z5VF.js} +689 -476
- package/dist/chunk-GNL6Z5VF.js.map +1 -0
- package/dist/cli.js +495 -382
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +101 -36
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-DXA44XWY.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,25 @@ interface ClientOptions {
|
|
|
14
14
|
insecure?: boolean;
|
|
15
15
|
}
|
|
16
16
|
/** Fully resolved request context — every field is known. */
|
|
17
|
+
interface RefreshableTokens {
|
|
18
|
+
accessToken: string;
|
|
19
|
+
refreshToken?: string;
|
|
20
|
+
idToken?: string;
|
|
21
|
+
}
|
|
17
22
|
interface RequestContext {
|
|
18
23
|
baseUrl: string;
|
|
19
24
|
token: string;
|
|
20
25
|
businessDomain: string;
|
|
21
26
|
insecure: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Stored-credential refresh: on a 401, swap the refresh token for a fresh
|
|
29
|
+
* access token, persist it, and retry once. Absent for explicit `--token`/env.
|
|
30
|
+
*/
|
|
31
|
+
refresh?: {
|
|
32
|
+
refreshToken: string;
|
|
33
|
+
clientId?: string;
|
|
34
|
+
persist: (tokens: RefreshableTokens) => void;
|
|
35
|
+
};
|
|
22
36
|
}
|
|
23
37
|
declare const DEFAULT_BUSINESS_DOMAIN = "bd_public";
|
|
24
38
|
/** Default list/query limits — see AGENTS.md conventions. */
|
|
@@ -112,42 +126,64 @@ interface AuditListOptions {
|
|
|
112
126
|
}
|
|
113
127
|
type MemberType = "user" | "department" | "group" | "app";
|
|
114
128
|
|
|
115
|
-
/** Build / render a department hierarchy from flat ISF search entries. */
|
|
116
|
-
|
|
117
|
-
interface OrgNode {
|
|
118
|
-
id: string;
|
|
119
|
-
name: string;
|
|
120
|
-
children: OrgNode[];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
129
|
declare function admin(ctx: RequestContext): {
|
|
124
130
|
orgList: (opts?: AdminListOptions) => Promise<unknown>;
|
|
125
131
|
orgGet: (deptId: string) => Promise<unknown>;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
orgTree: (role?: string) => Promise<OrgNode[]>;
|
|
132
|
-
orgCreate: (input: CreateOrgInput) => Promise<unknown>;
|
|
132
|
+
orgTree: (_role?: string) => Promise<unknown[]>;
|
|
133
|
+
orgMembers: (deptId: string, _opts?: unknown) => Promise<unknown>;
|
|
134
|
+
orgCreate: (input: CreateOrgInput) => Promise<{
|
|
135
|
+
id: string;
|
|
136
|
+
}>;
|
|
133
137
|
orgUpdate: (deptId: string, input: UpdateOrgInput) => Promise<unknown>;
|
|
134
|
-
orgDelete: (deptId: string) => Promise<
|
|
138
|
+
orgDelete: (deptId: string) => Promise<{
|
|
139
|
+
ok: true;
|
|
140
|
+
}>;
|
|
135
141
|
userList: (opts?: AdminListOptions) => Promise<unknown>;
|
|
136
142
|
userGet: (userId: string) => Promise<unknown>;
|
|
137
|
-
userRoles: (userId: string) => Promise<
|
|
138
|
-
|
|
143
|
+
userRoles: (userId: string) => Promise<{
|
|
144
|
+
roles: {
|
|
145
|
+
name: string;
|
|
146
|
+
id: string;
|
|
147
|
+
}[];
|
|
148
|
+
}>;
|
|
149
|
+
userCreate: (input: CreateUserInput) => Promise<{
|
|
150
|
+
id: string;
|
|
151
|
+
}>;
|
|
139
152
|
userUpdate: (userId: string, input: UpdateUserInput) => Promise<unknown>;
|
|
140
|
-
userDelete: (userId: string) => Promise<
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
userDelete: (userId: string) => Promise<{
|
|
154
|
+
ok: true;
|
|
155
|
+
}>;
|
|
156
|
+
userResetPassword: (userId: string, newPassword: string) => Promise<{
|
|
157
|
+
ok: true;
|
|
158
|
+
}>;
|
|
159
|
+
roleList: (_opts?: ListRolesOptions) => Promise<unknown>;
|
|
143
160
|
roleGet: (roleId: string) => Promise<unknown>;
|
|
144
|
-
roleMembers: (roleId: string,
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
roleMembers: (roleId: string, _opts?: unknown) => Promise<{
|
|
162
|
+
members: {
|
|
163
|
+
account: string;
|
|
164
|
+
id: string;
|
|
165
|
+
}[];
|
|
166
|
+
}>;
|
|
167
|
+
addRoleMember: (roleId: string, id: string, _type?: MemberType) => Promise<{
|
|
168
|
+
ok: true;
|
|
169
|
+
}>;
|
|
170
|
+
removeRoleMember: (roleId: string, id: string, _type?: MemberType) => Promise<{
|
|
171
|
+
ok: true;
|
|
172
|
+
}>;
|
|
173
|
+
roleCreate: (name: string, description?: string) => Promise<{
|
|
174
|
+
id: string;
|
|
175
|
+
}>;
|
|
176
|
+
roleUpdate: (roleId: string, input: {
|
|
177
|
+
name?: string;
|
|
178
|
+
description?: string;
|
|
147
179
|
}) => Promise<unknown>;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
180
|
+
roleDelete: (roleId: string) => Promise<{
|
|
181
|
+
ok: true;
|
|
182
|
+
}>;
|
|
183
|
+
rolePermission: (roleId: string, grant: boolean, resourceType: string, resourceId: string, operations: string[]) => Promise<{
|
|
184
|
+
ok: true;
|
|
185
|
+
}>;
|
|
186
|
+
auditList: (_opts?: AuditListOptions) => never;
|
|
151
187
|
};
|
|
152
188
|
|
|
153
189
|
interface ChatResult {
|
|
@@ -227,8 +263,10 @@ declare function context(ctx: RequestContext): {
|
|
|
227
263
|
searchSchema: (knId: string, query: string, opts?: SearchSchemaOptions) => Promise<unknown>;
|
|
228
264
|
queryObjectInstance: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
229
265
|
findSkills: (knId: string, objectTypeId: string, topK?: number) => Promise<unknown>;
|
|
266
|
+
info: () => Promise<unknown>;
|
|
230
267
|
tools: (knId: string) => Promise<unknown>;
|
|
231
268
|
toolCall: (knId: string, name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
269
|
+
callMethod: (knId: string, method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
232
270
|
queryInstanceSubgraph: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
233
271
|
logicProperties: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
234
272
|
actionInfo: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
@@ -889,6 +927,8 @@ interface TokenConfig {
|
|
|
889
927
|
expiresAt?: string;
|
|
890
928
|
/** Skip TLS verification for this platform (saved by `auth login -k`). */
|
|
891
929
|
tlsInsecure?: boolean;
|
|
930
|
+
/** Platform has no auth stack (no bkn-safe) — requests carry no token. */
|
|
931
|
+
noAuth?: boolean;
|
|
892
932
|
/** Login name persisted at login time (fallback when JWT lacks claims). */
|
|
893
933
|
username?: string;
|
|
894
934
|
/** Human-readable name from userinfo. */
|
|
@@ -914,11 +954,19 @@ declare function attachToken(baseUrl: string, accessToken: string, opts?: {
|
|
|
914
954
|
refreshToken?: string;
|
|
915
955
|
idToken?: string;
|
|
916
956
|
insecure?: boolean;
|
|
957
|
+
username?: string;
|
|
917
958
|
}): {
|
|
918
959
|
baseUrl: string;
|
|
919
960
|
userId: string;
|
|
920
961
|
username?: string;
|
|
921
962
|
};
|
|
963
|
+
/** Register a no-auth platform session (no token; the platform has no bkn-safe). */
|
|
964
|
+
declare function attachNoAuth(baseUrl: string, opts?: {
|
|
965
|
+
insecure?: boolean;
|
|
966
|
+
}): {
|
|
967
|
+
baseUrl: string;
|
|
968
|
+
noAuth: true;
|
|
969
|
+
};
|
|
922
970
|
interface AuthStatus {
|
|
923
971
|
baseUrl?: string;
|
|
924
972
|
userId?: string;
|
|
@@ -928,7 +976,22 @@ interface AuthStatus {
|
|
|
928
976
|
}
|
|
929
977
|
declare function status(): AuthStatus;
|
|
930
978
|
declare function currentToken(): string;
|
|
931
|
-
|
|
979
|
+
/**
|
|
980
|
+
* Like {@link currentToken} but proactively refreshes an expired access token
|
|
981
|
+
* when a refresh token is stored, persisting the result. API requests already
|
|
982
|
+
* refresh on a 401 (see api/http.ts); this covers the `auth token` getter,
|
|
983
|
+
* whose output is copied out and used elsewhere where no 401 retry can help.
|
|
984
|
+
*/
|
|
985
|
+
declare function currentTokenFresh(): Promise<string>;
|
|
986
|
+
interface WhoamiResult extends JwtClaims {
|
|
987
|
+
/** Platform the active session belongs to. */
|
|
988
|
+
baseUrl?: string;
|
|
989
|
+
/** Stored user id (UUID) for the active session. */
|
|
990
|
+
userId?: string;
|
|
991
|
+
/** Resolved account/login name — what `auth login` looked up and stored. */
|
|
992
|
+
username?: string;
|
|
993
|
+
}
|
|
994
|
+
declare function whoami(): WhoamiResult;
|
|
932
995
|
interface PlatformListItem {
|
|
933
996
|
baseUrl: string;
|
|
934
997
|
userId: string;
|
|
@@ -941,10 +1004,14 @@ declare function listPlatforms(): PlatformListItem[];
|
|
|
941
1004
|
declare function use(baseUrl: string): void;
|
|
942
1005
|
declare function logout(): boolean;
|
|
943
1006
|
declare function deletePlatform(baseUrl: string, userId?: string): boolean;
|
|
944
|
-
/**
|
|
945
|
-
|
|
1007
|
+
/**
|
|
1008
|
+
* Switch the active user for a platform. Accepts a stored user id OR a username
|
|
1009
|
+
* (the account stored at login), so callers need not know the UUID.
|
|
1010
|
+
*/
|
|
1011
|
+
declare function switchUser(baseUrl: string, userOrName: string): {
|
|
946
1012
|
baseUrl: string;
|
|
947
1013
|
userId: string;
|
|
1014
|
+
username?: string;
|
|
948
1015
|
};
|
|
949
1016
|
/** List saved user profiles for one platform. */
|
|
950
1017
|
declare function usersOf(baseUrl: string): PlatformUser[];
|
|
@@ -958,8 +1025,11 @@ declare function exportCreds(): {
|
|
|
958
1025
|
|
|
959
1026
|
type auth_AuthStatus = AuthStatus;
|
|
960
1027
|
type auth_PlatformListItem = PlatformListItem;
|
|
1028
|
+
type auth_WhoamiResult = WhoamiResult;
|
|
1029
|
+
declare const auth_attachNoAuth: typeof attachNoAuth;
|
|
961
1030
|
declare const auth_attachToken: typeof attachToken;
|
|
962
1031
|
declare const auth_currentToken: typeof currentToken;
|
|
1032
|
+
declare const auth_currentTokenFresh: typeof currentTokenFresh;
|
|
963
1033
|
declare const auth_deletePlatform: typeof deletePlatform;
|
|
964
1034
|
declare const auth_exportCreds: typeof exportCreds;
|
|
965
1035
|
declare const auth_hostOf: typeof hostOf;
|
|
@@ -972,14 +1042,9 @@ declare const auth_userIdFromToken: typeof userIdFromToken;
|
|
|
972
1042
|
declare const auth_usersOf: typeof usersOf;
|
|
973
1043
|
declare const auth_whoami: typeof whoami;
|
|
974
1044
|
declare namespace auth {
|
|
975
|
-
export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, auth_attachToken as attachToken, auth_currentToken as currentToken, 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 };
|
|
1045
|
+
export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, type auth_WhoamiResult as WhoamiResult, auth_attachNoAuth as attachNoAuth, 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 };
|
|
976
1046
|
}
|
|
977
1047
|
|
|
978
|
-
/**
|
|
979
|
-
* Thin fetch wrapper: explicit timeout, auth headers, JSON in/out, typed errors.
|
|
980
|
-
* The single choke point for every backend call — resources build on this.
|
|
981
|
-
*/
|
|
982
|
-
|
|
983
1048
|
interface RequestInitEx {
|
|
984
1049
|
method?: string;
|
|
985
1050
|
/** JSON body — serialized and Content-Type set automatically. */
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openbkn/bkn-sdk",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.10",
|
|
4
4
|
"description": "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=18"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
11
|
"openbkn": "./dist/cli.js"
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@clack/prompts": "^0.9.1",
|
|
43
|
+
"@openbkn/bkn-sdk": "^0.1.1-alpha.3",
|
|
43
44
|
"chalk": "^5.4.1",
|
|
44
|
-
"cli-table3": "^0.6.5",
|
|
45
45
|
"commander": "^13.1.0",
|
|
46
46
|
"csv-parse": "^6.2.1",
|
|
47
47
|
"js-yaml": "^4.2.0",
|