@openbkn/bkn-sdk 0.1.1-alpha.10 → 0.1.1-alpha.12

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
@@ -245,6 +245,63 @@ declare function agents(ctx: RequestContext): {
245
245
  }) => Promise<ChatResult>;
246
246
  };
247
247
 
248
+ /**
249
+ * AppKey API (`/api/safe/v1/{me,admin}/api-keys`, OAuth-token-gated). AppKeys
250
+ * are user-issued long-lived credentials (prefix `bak_`) that authenticate AS
251
+ * their owner — downstream authorization is identical to that owner's OAuth
252
+ * token. Issuing/managing them needs a real OAuth session (an AppKey itself
253
+ * cannot mint AppKeys). The plaintext `key` is returned ONCE, on create.
254
+ * Usage of an AppKey is drop-in: pass it as the bearer `--token` against the
255
+ * Context Loader (agent-retrieval) MCP/REST surface. See issue #75.
256
+ */
257
+
258
+ /** A key's public metadata — never carries the secret. */
259
+ interface ApiKey {
260
+ id: string;
261
+ key_id: string;
262
+ name: string;
263
+ /** Masked preview for display, e.g. `bak_b3ff****b234` — safe to show in lists. */
264
+ masked: string;
265
+ enabled: boolean;
266
+ /** `null` = never expires. */
267
+ expires_at: string | null;
268
+ /** `null` = never used (zombie-key signal). */
269
+ last_used_at: string | null;
270
+ created_at: string;
271
+ /** Present only on the admin list. */
272
+ owner_user_id?: string;
273
+ }
274
+ /** Create response — `key` is the full plaintext, shown only this once. */
275
+ interface CreatedApiKey extends ApiKey {
276
+ key: string;
277
+ }
278
+ interface CreateApiKeyInput {
279
+ name: string;
280
+ /** RFC3339; omit = backend default (1 year). Must be in the future. */
281
+ expiresAt?: string;
282
+ /** `true` = never expire (wins over `expiresAt`). */
283
+ neverExpire?: boolean;
284
+ }
285
+
286
+ declare function appKeys(ctx: RequestContext): {
287
+ /** List the caller's own keys (no secrets). */
288
+ list: () => Promise<{
289
+ keys: ApiKey[];
290
+ }>;
291
+ /** Issue a key — the result's `key` is the plaintext, shown only once. */
292
+ create: (input: CreateApiKeyInput) => Promise<CreatedApiKey>;
293
+ /** Revoke one of the caller's keys (immediate). */
294
+ revoke: (id: string) => Promise<void>;
295
+ /** Rotate a key in place — new plaintext (shown once); old secret dies now. */
296
+ regenerate: (id: string) => Promise<CreatedApiKey>;
297
+ /** Admin: list all keys, or one owner's (adds `owner_user_id`). */
298
+ adminList: (ownerId?: string) => Promise<{
299
+ keys: ApiKey[];
300
+ }>;
301
+ /** Admin: revoke any key. */
302
+ adminRevoke: (id: string) => Promise<void>;
303
+ };
304
+
248
305
  /**
249
306
  * Context-loader client over the agent-retrieval MCP endpoint (JSON-RPC).
250
307
  * Reimplemented slim from kweaver-sdk: initialize → session id →
@@ -828,6 +885,22 @@ declare const BuildTask: z.ZodObject<{
828
885
  model_dimensions: z.ZodOptional<z.ZodNumber>;
829
886
  }, z.ZodTypeAny, "passthrough">>;
830
887
  type BuildTask = z.infer<typeof BuildTask>;
888
+ interface SqlQueryRequest {
889
+ /** SQL string (MySQL/MariaDB/PostgreSQL) or an OpenSearch DSL object. */
890
+ query: string | Record<string, unknown>;
891
+ /**
892
+ * Source type (mysql | mariadb | postgresql | opensearch …). Optional — when
893
+ * the query carries a `{{<resource-id>}}` placeholder the backend infers the
894
+ * type from that resource's Catalog connector. Pass it only to override.
895
+ */
896
+ resource_type?: string;
897
+ /** Streaming batch size (100–10000, default server-side). */
898
+ stream_size?: number;
899
+ /** Query timeout in seconds (1–3600). */
900
+ query_timeout?: number;
901
+ /** Cursor session id for paged streaming. */
902
+ query_id?: string;
903
+ }
831
904
  interface ListCatalogsOptions {
832
905
  limit?: number;
833
906
  offset?: number;
@@ -852,6 +925,8 @@ declare function vega(ctx: RequestContext): {
852
925
  catalogHealth: (ids: string[]) => Promise<unknown>;
853
926
  connectorTypes: () => Promise<unknown>;
854
927
  connectorType: (type: string) => Promise<unknown>;
928
+ /** Run SQL / OpenSearch DSL directly against a data source. */
929
+ sql: (body: SqlQueryRequest) => Promise<unknown>;
855
930
  /** Build a resource's index. With `wait`, polls until terminal. */
856
931
  build: (req: CreateBuildTaskRequest, opts?: {
857
932
  wait?: boolean;
@@ -886,6 +961,7 @@ interface BknClient {
886
961
  readonly toolboxes: ReturnType<typeof toolboxes>;
887
962
  readonly trace: ReturnType<typeof trace>;
888
963
  readonly admin: ReturnType<typeof admin>;
964
+ readonly appKeys: ReturnType<typeof appKeys>;
889
965
  readonly vega: ReturnType<typeof vega>;
890
966
  /** Raw API passthrough (the `call` escape hatch). */
891
967
  call(path: string, opts?: RawCallOptions): Promise<RawCallResult>;
@@ -898,7 +974,9 @@ declare class HttpError extends Error {
898
974
  readonly status: number;
899
975
  readonly statusText: string;
900
976
  readonly body: string;
901
- constructor(status: number, statusText: string, body: string);
977
+ /** Optional next-step guidance, overriding the status default (e.g. AppKey re-issue). */
978
+ readonly hint?: string;
979
+ constructor(status: number, statusText: string, body: string, hint?: string);
902
980
  }
903
981
  /** Raised for bad CLI/SDK input before any request is made. */
904
982
  declare class InputError extends Error {
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  toolboxes,
20
20
  trace,
21
21
  vega
22
- } from "./chunk-GNL6Z5VF.js";
22
+ } from "./chunk-3FVB6VFQ.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.10",
3
+ "version": "0.1.1-alpha.12",
4
4
  "description": "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",