@openbkn/bkn-sdk 0.1.1-alpha.0 → 0.1.1-alpha.2

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 {
@@ -914,6 +950,7 @@ declare function attachToken(baseUrl: string, accessToken: string, opts?: {
914
950
  refreshToken?: string;
915
951
  idToken?: string;
916
952
  insecure?: boolean;
953
+ username?: string;
917
954
  }): {
918
955
  baseUrl: string;
919
956
  userId: string;
@@ -941,10 +978,14 @@ declare function listPlatforms(): PlatformListItem[];
941
978
  declare function use(baseUrl: string): void;
942
979
  declare function logout(): boolean;
943
980
  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): {
981
+ /**
982
+ * Switch the active user for a platform. Accepts a stored user id OR a username
983
+ * (the account stored at login), so callers need not know the UUID.
984
+ */
985
+ declare function switchUser(baseUrl: string, userOrName: string): {
946
986
  baseUrl: string;
947
987
  userId: string;
988
+ username?: string;
948
989
  };
949
990
  /** List saved user profiles for one platform. */
950
991
  declare function usersOf(baseUrl: string): PlatformUser[];
@@ -975,11 +1016,6 @@ declare namespace auth {
975
1016
  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 };
976
1017
  }
977
1018
 
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
1019
  interface RequestInitEx {
984
1020
  method?: string;
985
1021
  /** 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-DXA44XWY.js";
22
+ } from "./chunk-5MOIXIMJ.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.0",
3
+ "version": "0.1.1-alpha.2",
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"
@@ -41,7 +41,6 @@
41
41
  "dependencies": {
42
42
  "@clack/prompts": "^0.9.1",
43
43
  "chalk": "^5.4.1",
44
- "cli-table3": "^0.6.5",
45
44
  "commander": "^13.1.0",
46
45
  "csv-parse": "^6.2.1",
47
46
  "js-yaml": "^4.2.0",