@ragable/sdk 0.3.0 → 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 +196 -20
- package/dist/index.d.ts +196 -20
- package/dist/index.js +498 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +490 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -222,6 +222,107 @@ declare class AgentsClient {
|
|
|
222
222
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
223
223
|
}
|
|
224
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
|
+
|
|
225
326
|
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
226
327
|
interface RagableBrowserClientOptions {
|
|
227
328
|
/** Organization id (UUID) — public agent chat URLs. */
|
|
@@ -231,6 +332,10 @@ interface RagableBrowserClientOptions {
|
|
|
231
332
|
* {@link RagableBrowserDatabaseClient}.
|
|
232
333
|
*/
|
|
233
334
|
authGroupId?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Default Backspace SQL instance id for {@link RagableBrowser.from} (Supabase-style table API).
|
|
337
|
+
*/
|
|
338
|
+
databaseInstanceId?: string;
|
|
234
339
|
/**
|
|
235
340
|
* Returns the end-user access JWT (from login/register/refresh).
|
|
236
341
|
* Required for `auth.getMe`, `auth.updateMe`, and `database.query`.
|
|
@@ -256,7 +361,17 @@ interface BrowserAuthTokens {
|
|
|
256
361
|
refreshToken: string;
|
|
257
362
|
expiresIn: string;
|
|
258
363
|
}
|
|
259
|
-
/**
|
|
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 }`. */
|
|
260
375
|
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
261
376
|
private readonly options;
|
|
262
377
|
constructor(options: RagableBrowserClientOptions);
|
|
@@ -264,6 +379,54 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
264
379
|
private toUrl;
|
|
265
380
|
private baseHeaders;
|
|
266
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;
|
|
267
430
|
register(body: {
|
|
268
431
|
email: string;
|
|
269
432
|
password: string;
|
|
@@ -290,8 +453,11 @@ interface BrowserSqlQueryParams {
|
|
|
290
453
|
databaseInstanceId: string;
|
|
291
454
|
sql: string;
|
|
292
455
|
params?: unknown[];
|
|
293
|
-
/**
|
|
294
|
-
|
|
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;
|
|
295
461
|
timeoutMs?: number;
|
|
296
462
|
rowLimit?: number;
|
|
297
463
|
}
|
|
@@ -302,11 +468,8 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
|
|
|
302
468
|
rows: Row[];
|
|
303
469
|
}
|
|
304
470
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* Pass `createBrowserClient<YourDatabase>()` and use `query<Tables<YourDatabase, 't'>>()`
|
|
309
|
-
* for Supabase-style row typing.
|
|
471
|
+
* Raw SQL against linked Postgres (escape hatch). Prefer {@link RagableBrowser.from} for
|
|
472
|
+
* Supabase-style `.select()` / `.insert()` / `.update()` / `.delete()`.
|
|
310
473
|
*/
|
|
311
474
|
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
312
475
|
private readonly options;
|
|
@@ -336,24 +499,28 @@ interface AgentPublicChatParams extends AgentChatParams {
|
|
|
336
499
|
triggerNodeId?: string;
|
|
337
500
|
}
|
|
338
501
|
/**
|
|
339
|
-
* Browser client
|
|
340
|
-
*
|
|
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`.
|
|
341
504
|
*/
|
|
342
505
|
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
343
506
|
readonly agents: RagableBrowserAgentsClient;
|
|
344
507
|
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
345
508
|
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
509
|
+
private readonly options;
|
|
346
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>;
|
|
347
516
|
}
|
|
348
517
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* - {@link RagableBrowser.auth} / {@link RagableBrowser.database} — need `authGroupId` (+ `getAccessToken` for protected calls).
|
|
352
|
-
*
|
|
353
|
-
* Pass schema and user types like Supabase: `createBrowserClient<Database, AuthUser>({ ... })`.
|
|
354
|
-
* For Shift and `/v1/*`, use {@link createClient} on a server.
|
|
518
|
+
* **Supabase-equivalent** browser client factory (no org API key).
|
|
519
|
+
* Same as {@link createRagableBrowserClient}.
|
|
355
520
|
*/
|
|
356
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;
|
|
357
524
|
|
|
358
525
|
/**
|
|
359
526
|
* Shared SSE parsing for `data: {json}` lines (Ragable agent streams).
|
|
@@ -427,10 +594,19 @@ declare class Ragable {
|
|
|
427
594
|
constructor(options: RagableClientOptions);
|
|
428
595
|
}
|
|
429
596
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
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.
|
|
433
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>;
|
|
434
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;
|
|
435
611
|
|
|
436
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, 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 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 Tables, type TablesInsert, type TablesUpdate, createBrowserClient, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -222,6 +222,107 @@ declare class AgentsClient {
|
|
|
222
222
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
223
223
|
}
|
|
224
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
|
+
|
|
225
326
|
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
226
327
|
interface RagableBrowserClientOptions {
|
|
227
328
|
/** Organization id (UUID) — public agent chat URLs. */
|
|
@@ -231,6 +332,10 @@ interface RagableBrowserClientOptions {
|
|
|
231
332
|
* {@link RagableBrowserDatabaseClient}.
|
|
232
333
|
*/
|
|
233
334
|
authGroupId?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Default Backspace SQL instance id for {@link RagableBrowser.from} (Supabase-style table API).
|
|
337
|
+
*/
|
|
338
|
+
databaseInstanceId?: string;
|
|
234
339
|
/**
|
|
235
340
|
* Returns the end-user access JWT (from login/register/refresh).
|
|
236
341
|
* Required for `auth.getMe`, `auth.updateMe`, and `database.query`.
|
|
@@ -256,7 +361,17 @@ interface BrowserAuthTokens {
|
|
|
256
361
|
refreshToken: string;
|
|
257
362
|
expiresIn: string;
|
|
258
363
|
}
|
|
259
|
-
/**
|
|
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 }`. */
|
|
260
375
|
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
261
376
|
private readonly options;
|
|
262
377
|
constructor(options: RagableBrowserClientOptions);
|
|
@@ -264,6 +379,54 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
264
379
|
private toUrl;
|
|
265
380
|
private baseHeaders;
|
|
266
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;
|
|
267
430
|
register(body: {
|
|
268
431
|
email: string;
|
|
269
432
|
password: string;
|
|
@@ -290,8 +453,11 @@ interface BrowserSqlQueryParams {
|
|
|
290
453
|
databaseInstanceId: string;
|
|
291
454
|
sql: string;
|
|
292
455
|
params?: unknown[];
|
|
293
|
-
/**
|
|
294
|
-
|
|
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;
|
|
295
461
|
timeoutMs?: number;
|
|
296
462
|
rowLimit?: number;
|
|
297
463
|
}
|
|
@@ -302,11 +468,8 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
|
|
|
302
468
|
rows: Row[];
|
|
303
469
|
}
|
|
304
470
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* Pass `createBrowserClient<YourDatabase>()` and use `query<Tables<YourDatabase, 't'>>()`
|
|
309
|
-
* for Supabase-style row typing.
|
|
471
|
+
* Raw SQL against linked Postgres (escape hatch). Prefer {@link RagableBrowser.from} for
|
|
472
|
+
* Supabase-style `.select()` / `.insert()` / `.update()` / `.delete()`.
|
|
310
473
|
*/
|
|
311
474
|
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
312
475
|
private readonly options;
|
|
@@ -336,24 +499,28 @@ interface AgentPublicChatParams extends AgentChatParams {
|
|
|
336
499
|
triggerNodeId?: string;
|
|
337
500
|
}
|
|
338
501
|
/**
|
|
339
|
-
* Browser client
|
|
340
|
-
*
|
|
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`.
|
|
341
504
|
*/
|
|
342
505
|
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
343
506
|
readonly agents: RagableBrowserAgentsClient;
|
|
344
507
|
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
345
508
|
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
509
|
+
private readonly options;
|
|
346
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>;
|
|
347
516
|
}
|
|
348
517
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* - {@link RagableBrowser.auth} / {@link RagableBrowser.database} — need `authGroupId` (+ `getAccessToken` for protected calls).
|
|
352
|
-
*
|
|
353
|
-
* Pass schema and user types like Supabase: `createBrowserClient<Database, AuthUser>({ ... })`.
|
|
354
|
-
* For Shift and `/v1/*`, use {@link createClient} on a server.
|
|
518
|
+
* **Supabase-equivalent** browser client factory (no org API key).
|
|
519
|
+
* Same as {@link createRagableBrowserClient}.
|
|
355
520
|
*/
|
|
356
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;
|
|
357
524
|
|
|
358
525
|
/**
|
|
359
526
|
* Shared SSE parsing for `data: {json}` lines (Ragable agent streams).
|
|
@@ -427,10 +594,19 @@ declare class Ragable {
|
|
|
427
594
|
constructor(options: RagableClientOptions);
|
|
428
595
|
}
|
|
429
596
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
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.
|
|
433
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>;
|
|
434
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;
|
|
435
611
|
|
|
436
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, 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 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 Tables, type TablesInsert, type TablesUpdate, createBrowserClient, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
|
|
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 };
|