@openbkn/bkn-sdk 0.1.1-alpha.1 → 0.1.1-alpha.3

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
@@ -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
- orgMembers: (deptId: string, opts?: {
127
- role?: string;
128
- offset?: number;
129
- limit?: number;
130
- }) => Promise<unknown>;
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<unknown>;
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<unknown>;
138
- userCreate: (input: CreateUserInput) => Promise<unknown>;
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<unknown>;
141
- userResetPassword: (userId: string, newPassword: string) => Promise<unknown>;
142
- roleList: (opts?: ListRolesOptions) => Promise<unknown>;
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, opts?: {
145
- keyword?: string;
146
- limit?: number;
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
- addRoleMember: (roleId: string, id: string, type?: MemberType) => Promise<unknown>;
149
- removeRoleMember: (roleId: string, id: string, type?: MemberType) => Promise<unknown>;
150
- auditList: (opts?: AuditListOptions) => Promise<unknown>;
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 {
@@ -889,6 +925,8 @@ interface TokenConfig {
889
925
  expiresAt?: string;
890
926
  /** Skip TLS verification for this platform (saved by `auth login -k`). */
891
927
  tlsInsecure?: boolean;
928
+ /** Platform has no auth stack (no bkn-safe) — requests carry no token. */
929
+ noAuth?: boolean;
892
930
  /** Login name persisted at login time (fallback when JWT lacks claims). */
893
931
  username?: string;
894
932
  /** Human-readable name from userinfo. */
@@ -914,11 +952,19 @@ declare function attachToken(baseUrl: string, accessToken: string, opts?: {
914
952
  refreshToken?: string;
915
953
  idToken?: string;
916
954
  insecure?: boolean;
955
+ username?: string;
917
956
  }): {
918
957
  baseUrl: string;
919
958
  userId: string;
920
959
  username?: string;
921
960
  };
961
+ /** Register a no-auth platform session (no token; the platform has no bkn-safe). */
962
+ declare function attachNoAuth(baseUrl: string, opts?: {
963
+ insecure?: boolean;
964
+ }): {
965
+ baseUrl: string;
966
+ noAuth: true;
967
+ };
922
968
  interface AuthStatus {
923
969
  baseUrl?: string;
924
970
  userId?: string;
@@ -941,10 +987,14 @@ declare function listPlatforms(): PlatformListItem[];
941
987
  declare function use(baseUrl: string): void;
942
988
  declare function logout(): boolean;
943
989
  declare function deletePlatform(baseUrl: string, userId?: string): boolean;
944
- /** Switch the active user for a platform (token must already be saved). */
945
- declare function switchUser(baseUrl: string, userId: string): {
990
+ /**
991
+ * Switch the active user for a platform. Accepts a stored user id OR a username
992
+ * (the account stored at login), so callers need not know the UUID.
993
+ */
994
+ declare function switchUser(baseUrl: string, userOrName: string): {
946
995
  baseUrl: string;
947
996
  userId: string;
997
+ username?: string;
948
998
  };
949
999
  /** List saved user profiles for one platform. */
950
1000
  declare function usersOf(baseUrl: string): PlatformUser[];
@@ -958,6 +1008,7 @@ declare function exportCreds(): {
958
1008
 
959
1009
  type auth_AuthStatus = AuthStatus;
960
1010
  type auth_PlatformListItem = PlatformListItem;
1011
+ declare const auth_attachNoAuth: typeof attachNoAuth;
961
1012
  declare const auth_attachToken: typeof attachToken;
962
1013
  declare const auth_currentToken: typeof currentToken;
963
1014
  declare const auth_deletePlatform: typeof deletePlatform;
@@ -972,14 +1023,9 @@ declare const auth_userIdFromToken: typeof userIdFromToken;
972
1023
  declare const auth_usersOf: typeof usersOf;
973
1024
  declare const auth_whoami: typeof whoami;
974
1025
  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 };
1026
+ export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, auth_attachNoAuth as attachNoAuth, 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 };
976
1027
  }
977
1028
 
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
1029
  interface RequestInitEx {
984
1030
  method?: string;
985
1031
  /** JSON body — serialized and Content-Type set automatically. */
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  toolboxes,
20
20
  trace,
21
21
  vega
22
- } from "./chunk-ADZ23DPF.js";
22
+ } from "./chunk-APJNRHLS.js";
23
23
  export {
24
24
  DEFAULT_BUSINESS_DOMAIN,
25
25
  DEFAULT_LIST_LIMIT,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@openbkn/bkn-sdk",
3
- "version": "0.1.1-alpha.1",
3
+ "version": "0.1.1-alpha.3",
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": ">=22"
8
+ "node": ">=18"
9
9
  },
10
10
  "bin": {
11
11
  "openbkn": "./dist/cli.js"