@ragable/sdk 0.0.3 → 0.4.0
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.mts +383 -1
- package/dist/index.d.ts +383 -1
- package/dist/index.js +769 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +752 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase-style schema types for `createBrowserClient<Database>()`.
|
|
3
|
+
* Define `Row` (and optionally `Insert` / `Update`) per table, then use
|
|
4
|
+
* `Tables<Database, 'my_table'>` with `database.query<...>()`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://supabase.com/docs/reference/javascript/typescript-support
|
|
7
|
+
*/
|
|
8
|
+
/** JSON-serializable values (matches common Supabase `Json` definition). */
|
|
9
|
+
type Json = string | number | boolean | null | {
|
|
10
|
+
[key: string]: Json | undefined;
|
|
11
|
+
} | Json[];
|
|
12
|
+
/** One table’s type bundle — at minimum provide `Row`. */
|
|
13
|
+
type RagableTableDefinition<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> = {
|
|
14
|
+
Row: Row;
|
|
15
|
+
Insert?: Insert;
|
|
16
|
+
Update?: Update;
|
|
17
|
+
Relationships?: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Top-level database shape (Supabase `Database` pattern).
|
|
21
|
+
* Consumers extend `public.Tables` with table names → {@link RagableTableDefinition}.
|
|
22
|
+
*/
|
|
23
|
+
interface RagableDatabase {
|
|
24
|
+
public: {
|
|
25
|
+
Tables: Record<string, RagableTableDefinition>;
|
|
26
|
+
Views?: Record<string, {
|
|
27
|
+
Row: Record<string, unknown>;
|
|
28
|
+
}>;
|
|
29
|
+
Enums?: Record<string, string>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Default schema when no generic is passed to `createBrowserClient`.
|
|
34
|
+
* `Record<string, never>` for `Tables` is assignable to `Record<string, RagableTableDefinition>`;
|
|
35
|
+
* use `database.query<YourRow>()` or pass a concrete `Database` generic.
|
|
36
|
+
*/
|
|
37
|
+
interface DefaultRagableDatabase extends RagableDatabase {
|
|
38
|
+
public: {
|
|
39
|
+
Tables: Record<string, never>;
|
|
40
|
+
Views: Record<string, never>;
|
|
41
|
+
Enums: Record<string, never>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Row type for a table name (Supabase `Tables<'x'>` pattern). */
|
|
45
|
+
type Tables<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
46
|
+
Row: infer R;
|
|
47
|
+
} ? R extends Record<string, unknown> ? R : Record<string, unknown> : Record<string, unknown>;
|
|
48
|
+
/** Insert payload type when declared; otherwise a partial of `Row`. */
|
|
49
|
+
type TablesInsert<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
50
|
+
Insert: infer I;
|
|
51
|
+
} ? I extends Record<string, unknown> ? I : Record<string, unknown> : Partial<Tables<D, TableName>>;
|
|
52
|
+
/** Update payload type when declared; otherwise partial `Row`. */
|
|
53
|
+
type TablesUpdate<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
54
|
+
Update: infer U;
|
|
55
|
+
} ? U extends Record<string, unknown> ? U : Record<string, unknown> : Partial<Tables<D, TableName>>;
|
|
56
|
+
|
|
1
57
|
interface RagableClientOptions {
|
|
2
58
|
apiKey: string;
|
|
3
59
|
baseUrl?: string;
|
|
@@ -166,6 +222,318 @@ declare class AgentsClient {
|
|
|
166
222
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
167
223
|
}
|
|
168
224
|
|
|
225
|
+
/** Shared with {@link RagableBrowserDatabaseClient.query} — duplicated to avoid circular imports. */
|
|
226
|
+
interface BrowserSqlExecParams {
|
|
227
|
+
databaseInstanceId: string;
|
|
228
|
+
sql: string;
|
|
229
|
+
params?: unknown[];
|
|
230
|
+
readOnly?: boolean;
|
|
231
|
+
timeoutMs?: number;
|
|
232
|
+
rowLimit?: number;
|
|
233
|
+
}
|
|
234
|
+
interface BrowserSqlExecResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
235
|
+
command: string;
|
|
236
|
+
rowCount: number;
|
|
237
|
+
truncated: boolean;
|
|
238
|
+
rows: Row[];
|
|
239
|
+
}
|
|
240
|
+
type PostgrestResult<T> = {
|
|
241
|
+
data: T;
|
|
242
|
+
error: null;
|
|
243
|
+
} | {
|
|
244
|
+
data: null;
|
|
245
|
+
error: RagableError;
|
|
246
|
+
};
|
|
247
|
+
/** Map async throws to `{ data, error }` like Supabase JS client. */
|
|
248
|
+
declare function asPostgrestResponse<T>(fn: () => Promise<T>): Promise<PostgrestResult<T>>;
|
|
249
|
+
type RunQuery = <R extends Record<string, unknown> = Record<string, unknown>>(p: BrowserSqlExecParams) => Promise<BrowserSqlExecResult<R>>;
|
|
250
|
+
/** Supabase/PostgREST-style read builder: `.from('t').select().eq().single()` */
|
|
251
|
+
declare class PostgrestSelectBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
252
|
+
private readonly run;
|
|
253
|
+
private readonly databaseInstanceId;
|
|
254
|
+
private readonly table;
|
|
255
|
+
private readonly columns;
|
|
256
|
+
private filters;
|
|
257
|
+
private _limit?;
|
|
258
|
+
private _order?;
|
|
259
|
+
constructor(run: RunQuery, databaseInstanceId: string, table: string, columns: string);
|
|
260
|
+
eq(column: string, value: unknown): this;
|
|
261
|
+
neq(column: string, value: unknown): this;
|
|
262
|
+
gt(column: string, value: unknown): this;
|
|
263
|
+
gte(column: string, value: unknown): this;
|
|
264
|
+
lt(column: string, value: unknown): this;
|
|
265
|
+
lte(column: string, value: unknown): this;
|
|
266
|
+
like(column: string, value: unknown): this;
|
|
267
|
+
ilike(column: string, value: unknown): this;
|
|
268
|
+
limit(n: number): this;
|
|
269
|
+
order(column: string, options?: {
|
|
270
|
+
ascending?: boolean;
|
|
271
|
+
}): this;
|
|
272
|
+
/** @param includeUserLimit when false, omit `.limit()` (for `.single()` / `.maybeSingle()`). */
|
|
273
|
+
private buildSelectCore;
|
|
274
|
+
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
275
|
+
private executeMany;
|
|
276
|
+
single(): Promise<PostgrestResult<Row>>;
|
|
277
|
+
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
278
|
+
}
|
|
279
|
+
declare class PostgrestInsertBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
280
|
+
private readonly run;
|
|
281
|
+
private readonly databaseInstanceId;
|
|
282
|
+
private readonly table;
|
|
283
|
+
private readonly rows;
|
|
284
|
+
private returning;
|
|
285
|
+
constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[]);
|
|
286
|
+
select(columns?: string): this;
|
|
287
|
+
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
288
|
+
private execute;
|
|
289
|
+
}
|
|
290
|
+
declare class PostgrestUpdateBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
291
|
+
private readonly run;
|
|
292
|
+
private readonly databaseInstanceId;
|
|
293
|
+
private readonly table;
|
|
294
|
+
private readonly patch;
|
|
295
|
+
private filters;
|
|
296
|
+
private returning;
|
|
297
|
+
constructor(run: RunQuery, databaseInstanceId: string, table: string, patch: Record<string, unknown>);
|
|
298
|
+
eq(column: string, value: unknown): this;
|
|
299
|
+
select(columns?: string): this;
|
|
300
|
+
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
301
|
+
private execute;
|
|
302
|
+
}
|
|
303
|
+
declare class PostgrestDeleteBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
304
|
+
private readonly run;
|
|
305
|
+
private readonly databaseInstanceId;
|
|
306
|
+
private readonly table;
|
|
307
|
+
private filters;
|
|
308
|
+
private returning;
|
|
309
|
+
constructor(run: RunQuery, databaseInstanceId: string, table: string);
|
|
310
|
+
eq(column: string, value: unknown): this;
|
|
311
|
+
select(columns?: string): this;
|
|
312
|
+
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
313
|
+
private execute;
|
|
314
|
+
}
|
|
315
|
+
declare class PostgrestTableApi<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
316
|
+
private readonly run;
|
|
317
|
+
private readonly databaseInstanceId;
|
|
318
|
+
private readonly table;
|
|
319
|
+
constructor(run: RunQuery, databaseInstanceId: string, table: string);
|
|
320
|
+
select(columns?: string): PostgrestSelectBuilder<Row>;
|
|
321
|
+
insert(values: Record<string, unknown> | Record<string, unknown>[]): PostgrestInsertBuilder<Row>;
|
|
322
|
+
update(patch: Record<string, unknown>): PostgrestUpdateBuilder<Row>;
|
|
323
|
+
delete(): PostgrestDeleteBuilder<Row>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
327
|
+
interface RagableBrowserClientOptions {
|
|
328
|
+
/** Organization id (UUID) — public agent chat URLs. */
|
|
329
|
+
organizationId: string;
|
|
330
|
+
/**
|
|
331
|
+
* Authentication group id when using {@link RagableBrowserAuthClient} or
|
|
332
|
+
* {@link RagableBrowserDatabaseClient}.
|
|
333
|
+
*/
|
|
334
|
+
authGroupId?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Default Backspace SQL instance id for {@link RagableBrowser.from} (Supabase-style table API).
|
|
337
|
+
*/
|
|
338
|
+
databaseInstanceId?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Returns the end-user access JWT (from login/register/refresh).
|
|
341
|
+
* Required for `auth.getMe`, `auth.updateMe`, and `database.query`.
|
|
342
|
+
*/
|
|
343
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
344
|
+
/**
|
|
345
|
+
* API base URL including `/api`, e.g. `https://api.example.com/api`.
|
|
346
|
+
* @default "http://localhost:8080/api"
|
|
347
|
+
*/
|
|
348
|
+
baseUrl?: string;
|
|
349
|
+
fetch?: typeof fetch;
|
|
350
|
+
headers?: HeadersInit;
|
|
351
|
+
}
|
|
352
|
+
/** Successful register/login response (typed `user` via `AuthUser` generic). */
|
|
353
|
+
interface BrowserAuthSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
354
|
+
user: AuthUser;
|
|
355
|
+
accessToken: string;
|
|
356
|
+
refreshToken: string;
|
|
357
|
+
expiresIn: string;
|
|
358
|
+
}
|
|
359
|
+
interface BrowserAuthTokens {
|
|
360
|
+
accessToken: string;
|
|
361
|
+
refreshToken: string;
|
|
362
|
+
expiresIn: string;
|
|
363
|
+
}
|
|
364
|
+
/** Supabase-compatible session shape (snake_case tokens). */
|
|
365
|
+
interface SupabaseCompatSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
366
|
+
access_token: string;
|
|
367
|
+
refresh_token: string;
|
|
368
|
+
/** Best-effort seconds from Ragable `expiresIn` (e.g. `7d`, `3600`). */
|
|
369
|
+
expires_in: number;
|
|
370
|
+
token_type: "bearer";
|
|
371
|
+
user: AuthUser;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** End-user auth — Ragable names + Supabase/Firebase-style aliases returning `{ data, error }`. */
|
|
375
|
+
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
376
|
+
private readonly options;
|
|
377
|
+
constructor(options: RagableBrowserClientOptions);
|
|
378
|
+
private get fetchImpl();
|
|
379
|
+
private toUrl;
|
|
380
|
+
private baseHeaders;
|
|
381
|
+
private authPrefix;
|
|
382
|
+
/** Supabase: `signUp` → `{ data: { user, session }, error }` */
|
|
383
|
+
signUp(credentials: {
|
|
384
|
+
email: string;
|
|
385
|
+
password: string;
|
|
386
|
+
options?: {
|
|
387
|
+
data?: Record<string, unknown>;
|
|
388
|
+
};
|
|
389
|
+
}): Promise<PostgrestResult<{
|
|
390
|
+
user: AuthUser;
|
|
391
|
+
session: SupabaseCompatSession<AuthUser>;
|
|
392
|
+
}>>;
|
|
393
|
+
/** Supabase: `signInWithPassword` */
|
|
394
|
+
signInWithPassword(credentials: {
|
|
395
|
+
email: string;
|
|
396
|
+
password: string;
|
|
397
|
+
}): Promise<PostgrestResult<{
|
|
398
|
+
user: AuthUser;
|
|
399
|
+
session: SupabaseCompatSession<AuthUser>;
|
|
400
|
+
}>>;
|
|
401
|
+
/** Supabase: `refreshSession` */
|
|
402
|
+
refreshSession(refreshToken: string): Promise<PostgrestResult<{
|
|
403
|
+
session: SupabaseCompatSession<AuthUser>;
|
|
404
|
+
user: AuthUser;
|
|
405
|
+
}>>;
|
|
406
|
+
/** Supabase: `getUser()` — needs `getAccessToken` on the client */
|
|
407
|
+
getUser(): Promise<PostgrestResult<{
|
|
408
|
+
user: AuthUser;
|
|
409
|
+
}>>;
|
|
410
|
+
/** Supabase: `updateUser` */
|
|
411
|
+
updateUser(attributes: {
|
|
412
|
+
email?: string;
|
|
413
|
+
password?: string;
|
|
414
|
+
data?: {
|
|
415
|
+
name?: string | null;
|
|
416
|
+
};
|
|
417
|
+
}): Promise<PostgrestResult<{
|
|
418
|
+
user: AuthUser;
|
|
419
|
+
}>>;
|
|
420
|
+
/**
|
|
421
|
+
* Supabase/Firebase: no server call — clear tokens in your app.
|
|
422
|
+
* Returns `{ error: null }` for API compatibility.
|
|
423
|
+
*/
|
|
424
|
+
signOut(_options?: {
|
|
425
|
+
scope?: "global" | "local";
|
|
426
|
+
}): Promise<{
|
|
427
|
+
error: null;
|
|
428
|
+
}>;
|
|
429
|
+
private getUserFromToken;
|
|
430
|
+
register(body: {
|
|
431
|
+
email: string;
|
|
432
|
+
password: string;
|
|
433
|
+
name?: string;
|
|
434
|
+
}): Promise<BrowserAuthSession<AuthUser>>;
|
|
435
|
+
login(body: {
|
|
436
|
+
email: string;
|
|
437
|
+
password: string;
|
|
438
|
+
}): Promise<BrowserAuthSession<AuthUser>>;
|
|
439
|
+
refresh(body: {
|
|
440
|
+
refreshToken: string;
|
|
441
|
+
}): Promise<BrowserAuthTokens>;
|
|
442
|
+
getMe(): Promise<{
|
|
443
|
+
user: AuthUser;
|
|
444
|
+
}>;
|
|
445
|
+
updateMe(body: {
|
|
446
|
+
name?: string | null;
|
|
447
|
+
password?: string;
|
|
448
|
+
}): Promise<{
|
|
449
|
+
user: AuthUser;
|
|
450
|
+
}>;
|
|
451
|
+
}
|
|
452
|
+
interface BrowserSqlQueryParams {
|
|
453
|
+
databaseInstanceId: string;
|
|
454
|
+
sql: string;
|
|
455
|
+
params?: unknown[];
|
|
456
|
+
/**
|
|
457
|
+
* Default `true`. When `false`, the API allows INSERT/UPDATE/DELETE (and existing safe reads);
|
|
458
|
+
* DDL (`CREATE`/`DROP`/`ALTER`/…) and privilege changes remain blocked.
|
|
459
|
+
*/
|
|
460
|
+
readOnly?: boolean;
|
|
461
|
+
timeoutMs?: number;
|
|
462
|
+
rowLimit?: number;
|
|
463
|
+
}
|
|
464
|
+
interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
465
|
+
command: string;
|
|
466
|
+
rowCount: number;
|
|
467
|
+
truncated: boolean;
|
|
468
|
+
rows: Row[];
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Raw SQL against linked Postgres (escape hatch). Prefer {@link RagableBrowser.from} for
|
|
472
|
+
* Supabase-style `.select()` / `.insert()` / `.update()` / `.delete()`.
|
|
473
|
+
*/
|
|
474
|
+
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
475
|
+
private readonly options;
|
|
476
|
+
constructor(options: RagableBrowserClientOptions);
|
|
477
|
+
private get fetchImpl();
|
|
478
|
+
private toUrl;
|
|
479
|
+
query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
|
|
480
|
+
private baseHeaders;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Browser-safe client: **no org API key**. Uses public routes and end-user JWTs
|
|
484
|
+
* from {@link RagableBrowserAuthClient}.
|
|
485
|
+
*/
|
|
486
|
+
declare class RagableBrowserAgentsClient {
|
|
487
|
+
private readonly options;
|
|
488
|
+
constructor(options: RagableBrowserClientOptions);
|
|
489
|
+
private get fetchImpl();
|
|
490
|
+
private toUrl;
|
|
491
|
+
/**
|
|
492
|
+
* Stream agent execution as SSE (`POST /public/organizations/:orgId/agents/:agentId/chat/stream`).
|
|
493
|
+
*/
|
|
494
|
+
chatStream(agentId: string, params: AgentPublicChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
495
|
+
}
|
|
496
|
+
/** Public chat params — same shape as {@link AgentChatParams} plus optional trigger fields. */
|
|
497
|
+
interface AgentPublicChatParams extends AgentChatParams {
|
|
498
|
+
triggerSubtype?: string;
|
|
499
|
+
triggerNodeId?: string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Browser client: mirrors **Supabase JS** (`createClient`, `.from()`, `.auth.signInWithPassword`, `{ data, error }`)
|
|
503
|
+
* plus Ragable **`agents.chatStream`**. Server secrets: {@link createRagableServerClient} / {@link createClient} with `apiKey`.
|
|
504
|
+
*/
|
|
505
|
+
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
506
|
+
readonly agents: RagableBrowserAgentsClient;
|
|
507
|
+
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
508
|
+
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
509
|
+
private readonly options;
|
|
510
|
+
constructor(options: RagableBrowserClientOptions);
|
|
511
|
+
/**
|
|
512
|
+
* Supabase-style table API: `.from('items').select().eq('id', 1).single()`.
|
|
513
|
+
* Pass `databaseInstanceId` here or set `databaseInstanceId` on the client options.
|
|
514
|
+
*/
|
|
515
|
+
from<Row extends Record<string, unknown> = Record<string, unknown>>(table: string, databaseInstanceId?: string): PostgrestTableApi<Row>;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* **Supabase-equivalent** browser client factory (no org API key).
|
|
519
|
+
* Same as {@link createRagableBrowserClient}.
|
|
520
|
+
*/
|
|
521
|
+
declare function createBrowserClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
522
|
+
/** Alias for {@link createBrowserClient} — matches Supabase `createClient` naming. */
|
|
523
|
+
declare const createRagableBrowserClient: typeof createBrowserClient;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Shared SSE parsing for `data: {json}` lines (Ragable agent streams).
|
|
527
|
+
*/
|
|
528
|
+
type SseJsonEvent = Record<string, unknown> & {
|
|
529
|
+
type: string;
|
|
530
|
+
};
|
|
531
|
+
declare function parseSseDataLine(line: string): SseJsonEvent | null;
|
|
532
|
+
/**
|
|
533
|
+
* Read an SSE body and yield parsed `data:` JSON objects (double-newline framed).
|
|
534
|
+
*/
|
|
535
|
+
declare function readSseStream(body: ReadableStream<Uint8Array>): AsyncGenerator<SseJsonEvent, void, undefined>;
|
|
536
|
+
|
|
169
537
|
/** Minimal client surface for {@link createRagPipeline} (implemented by {@link Ragable}). */
|
|
170
538
|
interface RagClientForPipeline {
|
|
171
539
|
shift: {
|
|
@@ -225,6 +593,20 @@ declare class Ragable {
|
|
|
225
593
|
};
|
|
226
594
|
constructor(options: RagableClientOptions);
|
|
227
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* **Supabase-style overloads**
|
|
598
|
+
* - `createClient(RAGABLE_URL, { organizationId, authGroupId, … })` — browser (no API key)
|
|
599
|
+
* - `createClient({ apiKey, baseUrl })` — server / Engine (secret key)
|
|
600
|
+
*
|
|
601
|
+
* Prefer {@link createRagableServerClient} in backend code if the dual overload is confusing.
|
|
602
|
+
*/
|
|
603
|
+
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(url: string, options: Omit<RagableBrowserClientOptions, "baseUrl">): RagableBrowser<Database, AuthUser>;
|
|
228
604
|
declare function createClient(options: RagableClientOptions): Ragable;
|
|
605
|
+
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
606
|
+
/**
|
|
607
|
+
* Explicit **server** factory — same as `createClient({ apiKey, baseUrl })`.
|
|
608
|
+
* Use in the Engine; never import alongside browser `createClient(url, …)` if you want tree-shaking clarity.
|
|
609
|
+
*/
|
|
610
|
+
declare function createRagableServerClient(options: RagableClientOptions): Ragable;
|
|
229
611
|
|
|
230
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentStreamEvent, type AgentSummary, AgentsClient, type FormatContextOptions, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, type RagableClientOptions, RagableError, RagableRequestClient, type RequestOptions, type RetrieveParams, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext };
|
|
612
|
+
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, PostgrestDeleteBuilder, PostgrestInsertBuilder, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableRequestClient, type RagableTableDefinition, type RequestOptions, type RetrieveParams, type RunQuery, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type Tables, type TablesInsert, type TablesUpdate, asPostgrestResponse, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
|