@ragable/sdk 0.5.1 → 0.6.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 +399 -190
- package/dist/index.d.ts +399 -190
- package/dist/index.js +1297 -466
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1283 -466
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,10 @@ type TableRow<D extends RagableDatabase, T extends RagableTableNames<D>> = [keyo
|
|
|
66
66
|
type TableInsertRow<D extends RagableDatabase, T extends RagableTableNames<D>> = [keyof D["public"]["Tables"]] extends [never] ? Record<string, unknown> : T extends keyof D["public"]["Tables"] ? TablesInsert<D, T> : Record<string, unknown>;
|
|
67
67
|
/** Update patch for typed `from(table).update(...)`. */
|
|
68
68
|
type TableUpdatePatch<D extends RagableDatabase, T extends RagableTableNames<D>> = [keyof D["public"]["Tables"]] extends [never] ? Record<string, unknown> : T extends keyof D["public"]["Tables"] ? TablesUpdate<D, T> : Record<string, unknown>;
|
|
69
|
+
/** Column name union for a given table (keys of `Row`). Falls back to `string` when untyped. */
|
|
70
|
+
type ColumnName<D extends RagableDatabase, T extends RagableTableNames<D>> = [keyof D["public"]["Tables"]] extends [never] ? string : T extends keyof D["public"]["Tables"] ? Extract<keyof TableRow<D, T>, string> : string;
|
|
71
|
+
/** Value type for a specific column. Falls back to `unknown` when untyped. */
|
|
72
|
+
type ColumnValue<D extends RagableDatabase, T extends RagableTableNames<D>, C extends ColumnName<D, T>> = [keyof D["public"]["Tables"]] extends [never] ? unknown : T extends keyof D["public"]["Tables"] ? C extends keyof TableRow<D, T> ? TableRow<D, T>[C] : unknown : unknown;
|
|
69
73
|
|
|
70
74
|
/**
|
|
71
75
|
* Native `fetch` must not be called as a detached reference (`const f = fetch; f(url)`),
|
|
@@ -83,11 +87,32 @@ interface RagableClientOptions {
|
|
|
83
87
|
type RequestOptions = Omit<RequestInit, "body"> & {
|
|
84
88
|
body?: unknown;
|
|
85
89
|
};
|
|
86
|
-
declare class
|
|
90
|
+
declare abstract class RagableSdkError extends Error {
|
|
91
|
+
abstract readonly __type: string;
|
|
92
|
+
constructor(message: string);
|
|
93
|
+
}
|
|
94
|
+
declare class RagableError extends RagableSdkError {
|
|
95
|
+
readonly __type: "RagableError";
|
|
87
96
|
readonly status: number;
|
|
88
97
|
readonly body: unknown;
|
|
98
|
+
readonly code: string | undefined;
|
|
99
|
+
readonly details: string | undefined;
|
|
89
100
|
constructor(message: string, status: number, body: unknown);
|
|
90
101
|
}
|
|
102
|
+
declare class RagableNetworkError extends RagableSdkError {
|
|
103
|
+
readonly __type: "RagableNetworkError";
|
|
104
|
+
readonly cause: unknown;
|
|
105
|
+
constructor(message: string, cause?: unknown);
|
|
106
|
+
}
|
|
107
|
+
declare class RagableAbortError extends RagableSdkError {
|
|
108
|
+
readonly __type: "RagableAbortError";
|
|
109
|
+
constructor(message?: string);
|
|
110
|
+
}
|
|
111
|
+
declare class RagableTimeoutError extends RagableSdkError {
|
|
112
|
+
readonly __type: "RagableTimeoutError";
|
|
113
|
+
readonly timeoutMs: number;
|
|
114
|
+
constructor(timeoutMs: number);
|
|
115
|
+
}
|
|
91
116
|
declare function extractErrorMessage(payload: unknown, fallback: string): string;
|
|
92
117
|
declare class RagableRequestClient {
|
|
93
118
|
private readonly apiKey;
|
|
@@ -242,7 +267,7 @@ declare class AgentsClient {
|
|
|
242
267
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
243
268
|
}
|
|
244
269
|
|
|
245
|
-
/**
|
|
270
|
+
/** @deprecated Kept for backward compat with `database.query()`. Not used by PostgREST path. */
|
|
246
271
|
interface BrowserSqlExecParams {
|
|
247
272
|
databaseInstanceId: string;
|
|
248
273
|
sql: string;
|
|
@@ -251,18 +276,26 @@ interface BrowserSqlExecParams {
|
|
|
251
276
|
timeoutMs?: number;
|
|
252
277
|
rowLimit?: number;
|
|
253
278
|
}
|
|
279
|
+
/** @deprecated Kept for backward compat with `database.query()`. Not used by PostgREST path. */
|
|
254
280
|
interface BrowserSqlExecResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
255
281
|
command: string;
|
|
256
282
|
rowCount: number;
|
|
257
283
|
truncated: boolean;
|
|
258
284
|
rows: Row[];
|
|
259
285
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
286
|
+
/** @deprecated Use PostgRESTFetch instead. Kept for `database.query()` backward compat. */
|
|
287
|
+
type RunQuery = <R extends Record<string, unknown> = Record<string, unknown>>(p: BrowserSqlExecParams) => Promise<BrowserSqlExecResult<R>>;
|
|
288
|
+
interface PostgRESTFetchParams {
|
|
289
|
+
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
290
|
+
table: string;
|
|
291
|
+
searchParams: URLSearchParams;
|
|
292
|
+
body?: unknown;
|
|
293
|
+
headers?: Record<string, string>;
|
|
294
|
+
databaseInstanceId: string;
|
|
295
|
+
signal?: AbortSignal;
|
|
296
|
+
idempotencyKey?: string;
|
|
265
297
|
}
|
|
298
|
+
type PostgRESTFetch = (params: PostgRESTFetchParams) => Promise<Response>;
|
|
266
299
|
type PostgrestResult<T> = {
|
|
267
300
|
data: T;
|
|
268
301
|
error: null;
|
|
@@ -270,161 +303,167 @@ type PostgrestResult<T> = {
|
|
|
270
303
|
data: null;
|
|
271
304
|
error: RagableError;
|
|
272
305
|
};
|
|
273
|
-
/** Map async throws to `{ data, error }` like Supabase JS client. */
|
|
274
306
|
declare function asPostgrestResponse<T>(fn: () => Promise<T>): Promise<PostgrestResult<T>>;
|
|
275
|
-
type
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
307
|
+
type FilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "is" | "in";
|
|
308
|
+
interface Filter {
|
|
309
|
+
op: FilterOp;
|
|
310
|
+
column: string;
|
|
311
|
+
value: unknown;
|
|
312
|
+
}
|
|
313
|
+
declare class PostgrestSelectBuilder<Row extends Record<string, unknown> = Record<string, unknown>, D extends RagableDatabase = DefaultRagableDatabase, T extends RagableTableNames<D> = RagableTableNames<D>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
314
|
+
private readonly pgFetch;
|
|
279
315
|
private readonly databaseInstanceId;
|
|
280
316
|
private readonly table;
|
|
281
317
|
private readonly columns;
|
|
282
|
-
|
|
318
|
+
filters: Filter[];
|
|
283
319
|
private _limit?;
|
|
320
|
+
private _offset?;
|
|
284
321
|
private _order?;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
322
|
+
private _signal?;
|
|
323
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, columns: string);
|
|
324
|
+
eq<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
325
|
+
neq<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
326
|
+
gt<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
327
|
+
gte<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
328
|
+
lt<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
329
|
+
lte<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
330
|
+
like<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
331
|
+
ilike<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
332
|
+
is<C extends ColumnName<D, T>>(column: C, value: null | boolean): this;
|
|
333
|
+
in<C extends ColumnName<D, T>>(column: C, values: ColumnValue<D, T, C>[]): this;
|
|
334
|
+
match(query: Partial<TableRow<D, T>>): this;
|
|
294
335
|
limit(n: number): this;
|
|
295
|
-
|
|
336
|
+
offset(n: number): this;
|
|
337
|
+
range(from: number, to: number): this;
|
|
338
|
+
order(column: ColumnName<D, T>, options?: {
|
|
296
339
|
ascending?: boolean;
|
|
340
|
+
nullsFirst?: boolean;
|
|
297
341
|
}): this;
|
|
298
|
-
|
|
342
|
+
abortSignal(signal: AbortSignal): this;
|
|
343
|
+
private buildSearchParams;
|
|
299
344
|
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
300
345
|
private executeMany;
|
|
301
346
|
single(): Promise<PostgrestResult<Row>>;
|
|
302
347
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
303
348
|
}
|
|
304
|
-
/** After `.insert()`: await without `.select()` → `{ data: null }` (Supabase default). */
|
|
305
349
|
declare class PostgrestInsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
|
|
306
|
-
private readonly
|
|
350
|
+
private readonly pgFetch;
|
|
307
351
|
private readonly databaseInstanceId;
|
|
308
352
|
private readonly table;
|
|
309
353
|
private readonly rows;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
* Return inserted rows (Supabase: chain `.select()` to get data).
|
|
313
|
-
* @see https://supabase.com/docs/reference/javascript/insert
|
|
314
|
-
*/
|
|
354
|
+
private _signal?;
|
|
355
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, rows: Record<string, unknown>[]);
|
|
315
356
|
select(columns?: string): PostgrestInsertReturningBuilder<Row>;
|
|
357
|
+
abortSignal(signal: AbortSignal): this;
|
|
316
358
|
then<TResult1 = PostgrestResult<null>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<null>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
317
359
|
private executeNoReturn;
|
|
318
360
|
}
|
|
319
361
|
declare class PostgrestInsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
320
|
-
private readonly
|
|
362
|
+
private readonly pgFetch;
|
|
321
363
|
private readonly databaseInstanceId;
|
|
322
364
|
private readonly table;
|
|
323
365
|
private readonly rows;
|
|
324
366
|
private readonly returning;
|
|
325
|
-
|
|
367
|
+
private readonly _signal?;
|
|
368
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], returning: string, _signal?: AbortSignal | undefined);
|
|
326
369
|
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
327
370
|
private executeMany;
|
|
328
371
|
single(): Promise<PostgrestResult<Row>>;
|
|
329
372
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
330
373
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
private readonly run;
|
|
374
|
+
declare class PostgrestUpdateRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>, D extends RagableDatabase = DefaultRagableDatabase, T extends RagableTableNames<D> = RagableTableNames<D>> implements PromiseLike<PostgrestResult<null>> {
|
|
375
|
+
private readonly pgFetch;
|
|
334
376
|
private readonly databaseInstanceId;
|
|
335
377
|
private readonly table;
|
|
336
378
|
private readonly patch;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
379
|
+
filters: Filter[];
|
|
380
|
+
private _signal?;
|
|
381
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, patch: Record<string, unknown>);
|
|
382
|
+
eq<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
383
|
+
neq<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
384
|
+
gt<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
385
|
+
gte<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
386
|
+
lt<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
387
|
+
lte<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
388
|
+
like<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
389
|
+
ilike<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
390
|
+
is<C extends ColumnName<D, T>>(column: C, value: null | boolean): this;
|
|
391
|
+
in<C extends ColumnName<D, T>>(column: C, values: ColumnValue<D, T, C>[]): this;
|
|
392
|
+
match(query: Partial<TableRow<D, T>>): this;
|
|
351
393
|
select(columns?: string): PostgrestUpdateReturningBuilder<Row>;
|
|
394
|
+
abortSignal(signal: AbortSignal): this;
|
|
352
395
|
then<TResult1 = PostgrestResult<null>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<null>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
396
|
+
private buildSearchParams;
|
|
353
397
|
private executeNoReturn;
|
|
354
398
|
}
|
|
355
399
|
declare class PostgrestUpdateReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
356
|
-
private readonly
|
|
400
|
+
private readonly pgFetch;
|
|
357
401
|
private readonly databaseInstanceId;
|
|
358
402
|
private readonly table;
|
|
359
403
|
private readonly patch;
|
|
360
404
|
private readonly filters;
|
|
361
405
|
private readonly returning;
|
|
362
|
-
|
|
406
|
+
private readonly _signal?;
|
|
407
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, patch: Record<string, unknown>, filters: Filter[], returning: string, _signal?: AbortSignal | undefined);
|
|
363
408
|
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
364
409
|
private executeMany;
|
|
365
410
|
single(): Promise<PostgrestResult<Row>>;
|
|
366
411
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
367
412
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
private readonly run;
|
|
413
|
+
declare class PostgrestDeleteRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>, D extends RagableDatabase = DefaultRagableDatabase, T extends RagableTableNames<D> = RagableTableNames<D>> implements PromiseLike<PostgrestResult<null>> {
|
|
414
|
+
private readonly pgFetch;
|
|
371
415
|
private readonly databaseInstanceId;
|
|
372
416
|
private readonly table;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
417
|
+
filters: Filter[];
|
|
418
|
+
private _signal?;
|
|
419
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string);
|
|
420
|
+
eq<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
421
|
+
neq<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
422
|
+
gt<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
423
|
+
gte<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
424
|
+
lt<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
425
|
+
lte<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
426
|
+
like<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
427
|
+
ilike<C extends ColumnName<D, T>>(column: C, value: ColumnValue<D, T, C>): this;
|
|
428
|
+
is<C extends ColumnName<D, T>>(column: C, value: null | boolean): this;
|
|
429
|
+
in<C extends ColumnName<D, T>>(column: C, values: ColumnValue<D, T, C>[]): this;
|
|
430
|
+
match(query: Partial<TableRow<D, T>>): this;
|
|
387
431
|
select(columns?: string): PostgrestDeleteReturningBuilder<Row>;
|
|
432
|
+
abortSignal(signal: AbortSignal): this;
|
|
388
433
|
then<TResult1 = PostgrestResult<null>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<null>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
389
434
|
private executeNoReturn;
|
|
390
435
|
}
|
|
391
436
|
declare class PostgrestDeleteReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
392
|
-
private readonly
|
|
437
|
+
private readonly pgFetch;
|
|
393
438
|
private readonly databaseInstanceId;
|
|
394
439
|
private readonly table;
|
|
395
440
|
private readonly filters;
|
|
396
441
|
private readonly returning;
|
|
397
|
-
|
|
442
|
+
private readonly _signal?;
|
|
443
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, filters: Filter[], returning: string, _signal?: AbortSignal | undefined);
|
|
398
444
|
then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
399
445
|
private executeMany;
|
|
400
446
|
single(): Promise<PostgrestResult<Row>>;
|
|
401
447
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
402
448
|
}
|
|
403
449
|
interface PostgrestUpsertOptions {
|
|
404
|
-
/** Column(s) for `ON CONFLICT` — single name or comma-separated, e.g. `"id"` or `"org_id,user_id"`. */
|
|
405
450
|
onConflict: string;
|
|
406
|
-
/** When true, `ON CONFLICT DO NOTHING` (no update of existing rows). */
|
|
407
451
|
ignoreDuplicates?: boolean;
|
|
408
452
|
}
|
|
409
|
-
/** Upsert without `.select()` → `{ data: null }`. */
|
|
410
453
|
declare class PostgrestUpsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
|
|
411
|
-
private readonly
|
|
454
|
+
private readonly pgFetch;
|
|
412
455
|
private readonly databaseInstanceId;
|
|
413
456
|
private readonly table;
|
|
414
457
|
private readonly rows;
|
|
458
|
+
private readonly onConflict;
|
|
415
459
|
private readonly ignoreDuplicates;
|
|
416
|
-
private
|
|
417
|
-
constructor(
|
|
418
|
-
/**
|
|
419
|
-
* Return upserted rows (Supabase: `.upsert().select()`).
|
|
420
|
-
* @see https://supabase.com/docs/reference/javascript/upsert
|
|
421
|
-
*/
|
|
460
|
+
private _signal?;
|
|
461
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], onConflict: string, ignoreDuplicates: boolean);
|
|
422
462
|
select(columns?: string): PostgrestUpsertReturningBuilder<Row>;
|
|
463
|
+
abortSignal(signal: AbortSignal): this;
|
|
423
464
|
then<TResult1 = PostgrestResult<null>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<null>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
424
465
|
private executeNoReturn;
|
|
425
|
-
|
|
426
|
-
/** Used by returning builder */
|
|
427
|
-
runWithReturning(returning: string): Promise<BrowserSqlExecResult<Row>>;
|
|
466
|
+
runUpsert(prefer: string, selectCols: string | null): Promise<Row[]>;
|
|
428
467
|
}
|
|
429
468
|
declare class PostgrestUpsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
430
469
|
private readonly root;
|
|
@@ -436,67 +475,282 @@ declare class PostgrestUpsertReturningBuilder<Row extends Record<string, unknown
|
|
|
436
475
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
437
476
|
}
|
|
438
477
|
declare class PostgrestTableApi<Database extends RagableDatabase = DefaultRagableDatabase, TableName extends RagableTableNames<Database> = RagableTableNames<Database>> {
|
|
439
|
-
private readonly
|
|
478
|
+
private readonly pgFetch;
|
|
440
479
|
private readonly databaseInstanceId;
|
|
441
480
|
private readonly table;
|
|
442
|
-
constructor(
|
|
443
|
-
select(columns?: string): PostgrestSelectBuilder<TableRow<Database, TableName
|
|
481
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: TableName extends string ? string : string);
|
|
482
|
+
select(columns?: string): PostgrestSelectBuilder<TableRow<Database, TableName>, Database, TableName>;
|
|
444
483
|
insert(values: TableInsertRow<Database, TableName> | TableInsertRow<Database, TableName>[]): PostgrestInsertRootBuilder<TableRow<Database, TableName>>;
|
|
445
|
-
update(patch: TableUpdatePatch<Database, TableName>): PostgrestUpdateRootBuilder<TableRow<Database, TableName
|
|
446
|
-
delete(): PostgrestDeleteRootBuilder<TableRow<Database, TableName
|
|
447
|
-
/**
|
|
448
|
-
* `INSERT ... ON CONFLICT ... DO UPDATE` (or `DO NOTHING` with `ignoreDuplicates`).
|
|
449
|
-
* @see https://supabase.com/docs/reference/javascript/upsert
|
|
450
|
-
*/
|
|
484
|
+
update(patch: TableUpdatePatch<Database, TableName>): PostgrestUpdateRootBuilder<TableRow<Database, TableName>, Database, TableName>;
|
|
485
|
+
delete(): PostgrestDeleteRootBuilder<TableRow<Database, TableName>, Database, TableName>;
|
|
451
486
|
upsert(values: TableInsertRow<Database, TableName> | TableInsertRow<Database, TableName>[], options: PostgrestUpsertOptions): PostgrestUpsertRootBuilder<TableRow<Database, TableName>>;
|
|
452
487
|
}
|
|
453
488
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
489
|
+
interface SessionStorage {
|
|
490
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
491
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
492
|
+
removeItem(key: string): void | Promise<void>;
|
|
493
|
+
}
|
|
494
|
+
declare class LocalStorageAdapter implements SessionStorage {
|
|
495
|
+
getItem(key: string): string | null;
|
|
496
|
+
setItem(key: string, value: string): void;
|
|
497
|
+
removeItem(key: string): void;
|
|
498
|
+
}
|
|
499
|
+
declare class SessionStorageAdapter implements SessionStorage {
|
|
500
|
+
getItem(key: string): string | null;
|
|
501
|
+
setItem(key: string, value: string): void;
|
|
502
|
+
removeItem(key: string): void;
|
|
503
|
+
}
|
|
504
|
+
declare class MemoryStorageAdapter implements SessionStorage {
|
|
505
|
+
private store;
|
|
506
|
+
getItem(key: string): string | null;
|
|
507
|
+
setItem(key: string, value: string): void;
|
|
508
|
+
removeItem(key: string): void;
|
|
509
|
+
}
|
|
510
|
+
declare class CookieStorageAdapter implements SessionStorage {
|
|
511
|
+
private readonly maxAge;
|
|
512
|
+
private readonly path;
|
|
513
|
+
private readonly sameSite;
|
|
514
|
+
constructor(maxAge?: number, path?: string, sameSite?: "Lax" | "Strict" | "None");
|
|
515
|
+
getItem(key: string): string | null;
|
|
516
|
+
setItem(key: string, value: string): void;
|
|
517
|
+
removeItem(key: string): void;
|
|
518
|
+
}
|
|
519
|
+
declare function detectStorage(): SessionStorage;
|
|
520
|
+
type AuthBroadcastMessage = {
|
|
521
|
+
type: "SESSION_UPDATED";
|
|
522
|
+
payload: string;
|
|
523
|
+
} | {
|
|
524
|
+
type: "SESSION_REMOVED";
|
|
525
|
+
};
|
|
526
|
+
declare class AuthBroadcastChannel {
|
|
527
|
+
private channel;
|
|
528
|
+
constructor(channelName: string);
|
|
529
|
+
onMessage(cb: (msg: AuthBroadcastMessage) => void): void;
|
|
530
|
+
postSessionUpdated(serialized: string): void;
|
|
531
|
+
postSessionRemoved(): void;
|
|
532
|
+
close(): void;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
type AuthChangeEvent = "INITIAL_SESSION" | "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
|
|
536
|
+
interface AuthSession<U extends Record<string, unknown> = Record<string, unknown>> {
|
|
537
|
+
access_token: string;
|
|
538
|
+
refresh_token: string;
|
|
539
|
+
expires_in: number;
|
|
540
|
+
expires_at: number;
|
|
541
|
+
token_type: "bearer";
|
|
542
|
+
user: U;
|
|
543
|
+
}
|
|
544
|
+
interface AuthOptions {
|
|
545
|
+
persistSession?: boolean;
|
|
546
|
+
autoRefreshToken?: boolean;
|
|
547
|
+
storage?: SessionStorage;
|
|
548
|
+
storageKey?: string;
|
|
549
|
+
refreshSkewSeconds?: number;
|
|
550
|
+
debug?: boolean;
|
|
551
|
+
}
|
|
552
|
+
interface RagableAuthConfig {
|
|
553
|
+
baseUrl: string;
|
|
554
|
+
authGroupId: string;
|
|
555
|
+
fetch?: typeof fetch;
|
|
556
|
+
headers?: HeadersInit;
|
|
557
|
+
auth?: AuthOptions;
|
|
558
|
+
}
|
|
559
|
+
type AuthListener<U extends Record<string, unknown>> = (event: AuthChangeEvent, session: AuthSession<U> | null) => void;
|
|
560
|
+
interface Subscription {
|
|
561
|
+
id: string;
|
|
562
|
+
unsubscribe: () => void;
|
|
563
|
+
}
|
|
564
|
+
declare class RagableAuth<U extends Record<string, unknown> = Record<string, unknown>> {
|
|
565
|
+
private readonly fetchImpl;
|
|
566
|
+
private readonly baseUrl;
|
|
567
|
+
private readonly authGroupId;
|
|
568
|
+
private readonly defaultHeaders;
|
|
569
|
+
private readonly persistSession;
|
|
570
|
+
private readonly autoRefreshToken;
|
|
571
|
+
private readonly storage;
|
|
572
|
+
private readonly storageKey;
|
|
573
|
+
private readonly refreshSkewSeconds;
|
|
574
|
+
private readonly debug;
|
|
575
|
+
private currentSession;
|
|
576
|
+
private refreshTimer;
|
|
577
|
+
private refreshPromise;
|
|
578
|
+
private listeners;
|
|
579
|
+
private broadcast;
|
|
580
|
+
private visibilityHandler;
|
|
581
|
+
private initialized;
|
|
582
|
+
constructor(config: RagableAuthConfig);
|
|
583
|
+
private log;
|
|
584
|
+
initialize(): Promise<AuthSession<U> | null>;
|
|
585
|
+
signUp(credentials: {
|
|
586
|
+
email: string;
|
|
587
|
+
password: string;
|
|
588
|
+
options?: {
|
|
589
|
+
data?: Record<string, unknown>;
|
|
590
|
+
};
|
|
591
|
+
}): Promise<PostgrestResult<{
|
|
592
|
+
user: U;
|
|
593
|
+
session: AuthSession<U>;
|
|
594
|
+
}>>;
|
|
595
|
+
signInWithPassword(credentials: {
|
|
596
|
+
email: string;
|
|
597
|
+
password: string;
|
|
598
|
+
}): Promise<PostgrestResult<{
|
|
599
|
+
user: U;
|
|
600
|
+
session: AuthSession<U>;
|
|
601
|
+
}>>;
|
|
602
|
+
signOut(_options?: {
|
|
603
|
+
scope?: "global" | "local";
|
|
604
|
+
}): Promise<{
|
|
605
|
+
error: null;
|
|
606
|
+
}>;
|
|
607
|
+
refreshSession(refreshToken?: string): Promise<PostgrestResult<{
|
|
608
|
+
session: AuthSession<U>;
|
|
609
|
+
user: U;
|
|
610
|
+
}>>;
|
|
611
|
+
getSession(): Promise<PostgrestResult<{
|
|
612
|
+
session: AuthSession<U> | null;
|
|
613
|
+
}>>;
|
|
614
|
+
getUser(): Promise<PostgrestResult<{
|
|
615
|
+
user: U;
|
|
616
|
+
}>>;
|
|
617
|
+
setSession(tokens: {
|
|
618
|
+
access_token: string;
|
|
619
|
+
refresh_token: string;
|
|
620
|
+
}): Promise<PostgrestResult<{
|
|
621
|
+
session: AuthSession<U>;
|
|
622
|
+
user: U;
|
|
623
|
+
}>>;
|
|
624
|
+
updateUser(attributes: {
|
|
625
|
+
email?: string;
|
|
626
|
+
password?: string;
|
|
627
|
+
data?: {
|
|
628
|
+
name?: string | null;
|
|
629
|
+
};
|
|
630
|
+
}): Promise<PostgrestResult<{
|
|
631
|
+
user: U;
|
|
632
|
+
}>>;
|
|
633
|
+
onAuthStateChange(callback: AuthListener<U>): {
|
|
634
|
+
data: {
|
|
635
|
+
subscription: Subscription;
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
getAccessToken(): string | null;
|
|
639
|
+
getCurrentSession(): AuthSession<U> | null;
|
|
640
|
+
register(body: {
|
|
641
|
+
email: string;
|
|
642
|
+
password: string;
|
|
643
|
+
name?: string;
|
|
644
|
+
}): Promise<{
|
|
645
|
+
user: U;
|
|
646
|
+
accessToken: string;
|
|
647
|
+
refreshToken: string;
|
|
648
|
+
expiresIn: string;
|
|
649
|
+
}>;
|
|
650
|
+
login(body: {
|
|
651
|
+
email: string;
|
|
652
|
+
password: string;
|
|
653
|
+
}): Promise<{
|
|
654
|
+
user: U;
|
|
655
|
+
accessToken: string;
|
|
656
|
+
refreshToken: string;
|
|
657
|
+
expiresIn: string;
|
|
658
|
+
}>;
|
|
659
|
+
refresh(body: {
|
|
660
|
+
refreshToken: string;
|
|
661
|
+
}): Promise<{
|
|
662
|
+
accessToken: string;
|
|
663
|
+
refreshToken: string;
|
|
664
|
+
expiresIn: string;
|
|
665
|
+
}>;
|
|
666
|
+
getMe(): Promise<{
|
|
667
|
+
user: U;
|
|
668
|
+
}>;
|
|
669
|
+
updateMe(body: {
|
|
670
|
+
name?: string | null;
|
|
671
|
+
password?: string;
|
|
672
|
+
}): Promise<{
|
|
673
|
+
user: U;
|
|
674
|
+
}>;
|
|
675
|
+
destroy(): void;
|
|
676
|
+
private authPrefix;
|
|
677
|
+
private toUrl;
|
|
678
|
+
private baseHeaders;
|
|
679
|
+
private fetchAuth;
|
|
680
|
+
private fetchAuthWithBearer;
|
|
681
|
+
private rawToSession;
|
|
682
|
+
private setSessionInternal;
|
|
683
|
+
private persistCurrentSession;
|
|
684
|
+
private emit;
|
|
685
|
+
private scheduleRefresh;
|
|
686
|
+
private clearRefreshTimer;
|
|
687
|
+
singleFlightRefresh(refreshToken: string): Promise<AuthSession<U> | null>;
|
|
688
|
+
private _doRefresh;
|
|
689
|
+
private setupVisibilityListener;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
type HttpMethod = "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD";
|
|
693
|
+
interface RetryOptions {
|
|
694
|
+
maxRetries: number;
|
|
695
|
+
baseDelayMs: number;
|
|
696
|
+
maxDelayMs: number;
|
|
697
|
+
retryOn: number[];
|
|
698
|
+
respectRetryAfter: boolean;
|
|
699
|
+
}
|
|
700
|
+
interface TransportOptions {
|
|
701
|
+
fetch?: typeof fetch;
|
|
702
|
+
headers?: HeadersInit;
|
|
703
|
+
retry?: Partial<RetryOptions>;
|
|
704
|
+
timeoutMs?: number;
|
|
705
|
+
onRequest?: (req: TransportRequest) => void;
|
|
706
|
+
onResponse?: (req: TransportRequest, res: Response, durationMs: number) => void;
|
|
707
|
+
onRetry?: (req: TransportRequest, attempt: number, delayMs: number, reason: string) => void;
|
|
708
|
+
}
|
|
709
|
+
interface TransportRequest {
|
|
710
|
+
url: string;
|
|
711
|
+
method: HttpMethod;
|
|
712
|
+
headers: Headers;
|
|
713
|
+
body?: BodyInit;
|
|
714
|
+
signal?: AbortSignal;
|
|
715
|
+
idempotencyKey?: string;
|
|
716
|
+
retry?: Partial<RetryOptions>;
|
|
717
|
+
timeoutMs?: number;
|
|
718
|
+
}
|
|
719
|
+
declare function generateIdempotencyKey(): string;
|
|
720
|
+
declare class Transport {
|
|
721
|
+
private readonly fetchImpl;
|
|
722
|
+
private readonly defaultHeaders;
|
|
723
|
+
private readonly defaultRetry;
|
|
724
|
+
private readonly defaultTimeoutMs;
|
|
725
|
+
private readonly onRequest?;
|
|
726
|
+
private readonly onResponse?;
|
|
727
|
+
private readonly onRetry?;
|
|
728
|
+
private readonly inflightGets;
|
|
729
|
+
private _refreshHandler;
|
|
730
|
+
constructor(options?: TransportOptions);
|
|
731
|
+
setRefreshHandler(handler: (() => Promise<string | null>) | null): void;
|
|
732
|
+
execute(req: TransportRequest): Promise<Response>;
|
|
733
|
+
private _executeWithRetry;
|
|
734
|
+
private _singleFetch;
|
|
735
|
+
}
|
|
736
|
+
declare function parseTransportResponse<T>(response: Response): Promise<T>;
|
|
737
|
+
|
|
458
738
|
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
459
|
-
/** How {@link RagableBrowserDatabaseClient.query} and `.from()` send `Authorization`. */
|
|
460
739
|
type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
|
|
461
740
|
interface RagableBrowserClientOptions {
|
|
462
|
-
/** Organization id (UUID) — public agent chat URLs. */
|
|
463
741
|
organizationId: string;
|
|
464
|
-
/**
|
|
465
|
-
* Authentication group id when using {@link RagableBrowserAuthClient} or
|
|
466
|
-
* {@link RagableBrowserDatabaseClient}.
|
|
467
|
-
*/
|
|
468
742
|
authGroupId?: string;
|
|
469
|
-
/**
|
|
470
|
-
* Default Backspace SQL instance id for {@link RagableBrowser.from} (Supabase-style table API).
|
|
471
|
-
*/
|
|
472
743
|
databaseInstanceId?: string;
|
|
473
|
-
/**
|
|
474
|
-
* Database SQL auth. Default `user`: Bearer = JWT from {@link getAccessToken}.
|
|
475
|
-
* `publicAnon`: Bearer = public anon key (read-only SQL only). `admin`: Bearer = data admin key
|
|
476
|
-
* (same SQL rules as a logged-in user; **never** expose in browser bundles).
|
|
477
|
-
*/
|
|
478
744
|
dataAuth?: BrowserDataAuthMode;
|
|
479
|
-
/**
|
|
480
|
-
* Static key when {@link dataAuth} is `publicAnon` or `admin` (e.g. `import.meta.env.VITE_…`).
|
|
481
|
-
* Ignored when {@link getDataStaticKey} returns a non-empty string.
|
|
482
|
-
*/
|
|
483
745
|
dataStaticKey?: string;
|
|
484
|
-
/** Load anon/admin key at runtime; wins over {@link dataStaticKey} when non-empty. */
|
|
485
746
|
getDataStaticKey?: () => string | null | Promise<string | null>;
|
|
486
|
-
/**
|
|
487
|
-
* Returns the end-user access JWT (from login/register/refresh).
|
|
488
|
-
* Required for `auth.getMe`, `auth.updateMe`, and for `database.query` when {@link dataAuth} is `user` (default).
|
|
489
|
-
*/
|
|
490
747
|
getAccessToken?: () => string | null | Promise<string | null>;
|
|
491
|
-
/**
|
|
492
|
-
* API base URL including `/api`, e.g. `https://api.example.com/api`.
|
|
493
|
-
* @default `https://ragable-341305259977.asia-southeast1.run.app/api` ({@link DEFAULT_RAGABLE_API_BASE})
|
|
494
|
-
*/
|
|
495
748
|
baseUrl?: string;
|
|
496
749
|
fetch?: typeof fetch;
|
|
497
750
|
headers?: HeadersInit;
|
|
751
|
+
auth?: AuthOptions;
|
|
752
|
+
transport?: Partial<TransportOptions>;
|
|
498
753
|
}
|
|
499
|
-
/** Successful register/login response (typed `user` via `AuthUser` generic). */
|
|
500
754
|
interface BrowserAuthSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
501
755
|
user: AuthUser;
|
|
502
756
|
accessToken: string;
|
|
@@ -508,25 +762,18 @@ interface BrowserAuthTokens {
|
|
|
508
762
|
refreshToken: string;
|
|
509
763
|
expiresIn: string;
|
|
510
764
|
}
|
|
511
|
-
/** Supabase-compatible session shape (snake_case tokens). */
|
|
512
765
|
interface SupabaseCompatSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
513
766
|
access_token: string;
|
|
514
767
|
refresh_token: string;
|
|
515
|
-
/** Best-effort seconds from Ragable `expiresIn` (e.g. `7d`, `3600`). */
|
|
516
768
|
expires_in: number;
|
|
517
769
|
token_type: "bearer";
|
|
518
770
|
user: AuthUser;
|
|
519
771
|
}
|
|
520
772
|
|
|
521
|
-
/** End-user auth — Ragable names + Supabase/Firebase-style aliases returning `{ data, error }`. */
|
|
522
773
|
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
523
|
-
private readonly
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
private toUrl;
|
|
527
|
-
private baseHeaders;
|
|
528
|
-
private authPrefix;
|
|
529
|
-
/** Supabase: `signUp` → `{ data: { user, session }, error }` */
|
|
774
|
+
private readonly ragableAuth;
|
|
775
|
+
constructor(_options: RagableBrowserClientOptions, ragableAuth?: RagableAuth<AuthUser> | null);
|
|
776
|
+
private get auth();
|
|
530
777
|
signUp(credentials: {
|
|
531
778
|
email: string;
|
|
532
779
|
password: string;
|
|
@@ -537,7 +784,6 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
537
784
|
user: AuthUser;
|
|
538
785
|
session: SupabaseCompatSession<AuthUser>;
|
|
539
786
|
}>>;
|
|
540
|
-
/** Supabase: `signInWithPassword` */
|
|
541
787
|
signInWithPassword(credentials: {
|
|
542
788
|
email: string;
|
|
543
789
|
password: string;
|
|
@@ -545,16 +791,13 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
545
791
|
user: AuthUser;
|
|
546
792
|
session: SupabaseCompatSession<AuthUser>;
|
|
547
793
|
}>>;
|
|
548
|
-
/** Supabase: `refreshSession` */
|
|
549
794
|
refreshSession(refreshToken: string): Promise<PostgrestResult<{
|
|
550
795
|
session: SupabaseCompatSession<AuthUser>;
|
|
551
796
|
user: AuthUser;
|
|
552
797
|
}>>;
|
|
553
|
-
/** Supabase: `getUser()` — needs `getAccessToken` on the client */
|
|
554
798
|
getUser(): Promise<PostgrestResult<{
|
|
555
799
|
user: AuthUser;
|
|
556
800
|
}>>;
|
|
557
|
-
/** Supabase: `updateUser` */
|
|
558
801
|
updateUser(attributes: {
|
|
559
802
|
email?: string;
|
|
560
803
|
password?: string;
|
|
@@ -564,16 +807,11 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
564
807
|
}): Promise<PostgrestResult<{
|
|
565
808
|
user: AuthUser;
|
|
566
809
|
}>>;
|
|
567
|
-
/**
|
|
568
|
-
* Supabase/Firebase: no server call — clear tokens in your app.
|
|
569
|
-
* Returns `{ error: null }` for API compatibility.
|
|
570
|
-
*/
|
|
571
810
|
signOut(_options?: {
|
|
572
811
|
scope?: "global" | "local";
|
|
573
812
|
}): Promise<{
|
|
574
813
|
error: null;
|
|
575
814
|
}>;
|
|
576
|
-
private getUserFromToken;
|
|
577
815
|
register(body: {
|
|
578
816
|
email: string;
|
|
579
817
|
password: string;
|
|
@@ -595,19 +833,22 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
595
833
|
}): Promise<{
|
|
596
834
|
user: AuthUser;
|
|
597
835
|
}>;
|
|
836
|
+
onAuthStateChange(callback: (event: AuthChangeEvent, session: AuthSession<AuthUser> | null) => void): {
|
|
837
|
+
data: {
|
|
838
|
+
subscription: {
|
|
839
|
+
id: string;
|
|
840
|
+
unsubscribe: () => void;
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
};
|
|
844
|
+
getSession(): Promise<PostgrestResult<{
|
|
845
|
+
session: AuthSession<AuthUser> | null;
|
|
846
|
+
}>>;
|
|
598
847
|
}
|
|
599
848
|
interface BrowserSqlQueryParams {
|
|
600
|
-
/**
|
|
601
|
-
* Defaults to `databaseInstanceId` on {@link RagableBrowserClientOptions} when set
|
|
602
|
-
* (so you can configure it once on `createBrowserClient`).
|
|
603
|
-
*/
|
|
604
849
|
databaseInstanceId?: string;
|
|
605
850
|
sql: string;
|
|
606
851
|
params?: unknown[];
|
|
607
|
-
/**
|
|
608
|
-
* Default `true`. When `false`, the API allows INSERT/UPDATE/DELETE (and existing safe reads);
|
|
609
|
-
* DDL (`CREATE`/`DROP`/`ALTER`/…) and privilege changes remain blocked.
|
|
610
|
-
*/
|
|
611
852
|
readOnly?: boolean;
|
|
612
853
|
timeoutMs?: number;
|
|
613
854
|
rowLimit?: number;
|
|
@@ -618,59 +859,38 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
|
|
|
618
859
|
truncated: boolean;
|
|
619
860
|
rows: Row[];
|
|
620
861
|
}
|
|
621
|
-
/**
|
|
622
|
-
* Raw SQL against linked Postgres (escape hatch). Prefer {@link RagableBrowser.from} for
|
|
623
|
-
* Supabase-style `.select()` / `.insert()` / `.update()` / `.delete()`.
|
|
624
|
-
*/
|
|
625
862
|
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
626
863
|
private readonly options;
|
|
864
|
+
private readonly ragableAuth;
|
|
627
865
|
private readonly fetchImpl;
|
|
628
|
-
constructor(options: RagableBrowserClientOptions);
|
|
866
|
+
constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
|
|
629
867
|
private toUrl;
|
|
630
868
|
query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
|
|
631
869
|
private baseHeaders;
|
|
632
870
|
}
|
|
633
|
-
/**
|
|
634
|
-
* Browser-safe client: **no org API key**. Uses public routes and end-user JWTs
|
|
635
|
-
* from {@link RagableBrowserAuthClient}.
|
|
636
|
-
*/
|
|
637
871
|
declare class RagableBrowserAgentsClient {
|
|
638
872
|
private readonly options;
|
|
639
873
|
private readonly fetchImpl;
|
|
640
874
|
constructor(options: RagableBrowserClientOptions);
|
|
641
875
|
private toUrl;
|
|
642
|
-
/**
|
|
643
|
-
* Stream agent execution as SSE (`POST /public/organizations/:orgId/agents/:agentId/chat/stream`).
|
|
644
|
-
*/
|
|
645
876
|
chatStream(agentId: string, params: AgentPublicChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
646
877
|
}
|
|
647
|
-
/** Public chat params — same shape as {@link AgentChatParams} plus optional trigger fields. */
|
|
648
878
|
interface AgentPublicChatParams extends AgentChatParams {
|
|
649
879
|
triggerSubtype?: string;
|
|
650
880
|
triggerNodeId?: string;
|
|
651
881
|
}
|
|
652
|
-
/**
|
|
653
|
-
* Browser client: mirrors **Supabase JS** (`createClient`, `.from()`, `.auth.signInWithPassword`, `{ data, error }`)
|
|
654
|
-
* plus Ragable **`agents.chatStream`**. Server secrets: {@link createRagableServerClient} / {@link createClient} with `apiKey`.
|
|
655
|
-
*/
|
|
656
882
|
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
657
883
|
readonly agents: RagableBrowserAgentsClient;
|
|
658
884
|
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
659
885
|
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
886
|
+
readonly transport: Transport;
|
|
660
887
|
private readonly options;
|
|
888
|
+
private readonly _ragableAuth;
|
|
661
889
|
constructor(options: RagableBrowserClientOptions);
|
|
662
|
-
/**
|
|
663
|
-
* Supabase-style table API: `.from('items').select().eq('id', 1).single()`.
|
|
664
|
-
* Pass `databaseInstanceId` here or set `databaseInstanceId` on the client options.
|
|
665
|
-
*/
|
|
666
890
|
from<TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string): PostgrestTableApi<Database, TableName>;
|
|
891
|
+
destroy(): void;
|
|
667
892
|
}
|
|
668
|
-
/**
|
|
669
|
-
* **Supabase-equivalent** browser client factory (no org API key).
|
|
670
|
-
* Same as {@link createRagableBrowserClient}.
|
|
671
|
-
*/
|
|
672
893
|
declare function createBrowserClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
673
|
-
/** Alias for {@link createBrowserClient} — matches Supabase `createClient` naming. */
|
|
674
894
|
declare const createRagableBrowserClient: typeof createBrowserClient;
|
|
675
895
|
|
|
676
896
|
/**
|
|
@@ -744,20 +964,9 @@ declare class Ragable {
|
|
|
744
964
|
};
|
|
745
965
|
constructor(options: RagableClientOptions);
|
|
746
966
|
}
|
|
747
|
-
/**
|
|
748
|
-
* **Supabase-style overloads**
|
|
749
|
-
* - `createClient(RAGABLE_URL, { organizationId, authGroupId, … })` — browser (no API key)
|
|
750
|
-
* - `createClient({ apiKey, baseUrl })` — server / Engine (secret key)
|
|
751
|
-
*
|
|
752
|
-
* Prefer {@link createRagableServerClient} in backend code if the dual overload is confusing.
|
|
753
|
-
*/
|
|
754
967
|
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(url: string, options: Omit<RagableBrowserClientOptions, "baseUrl">): RagableBrowser<Database, AuthUser>;
|
|
755
968
|
declare function createClient(options: RagableClientOptions): Ragable;
|
|
756
969
|
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
757
|
-
/**
|
|
758
|
-
* Explicit **server** factory — same as `createClient({ apiKey, baseUrl })`.
|
|
759
|
-
* Use in the Engine; never import alongside browser `createClient(url, …)` if you want tree-shaking clarity.
|
|
760
|
-
*/
|
|
761
970
|
declare function createRagableServerClient(options: RagableClientOptions): Ragable;
|
|
762
971
|
|
|
763
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserDataAuthMode, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, DEFAULT_RAGABLE_API_BASE, type DefaultRagableDatabase, type FormatContextOptions, type Json, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableRequestClient, type RagableTableDefinition, type RagableTableNames, 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 TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
|
|
972
|
+
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type BrowserAuthSession, type BrowserAuthTokens, type BrowserDataAuthMode, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, 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 TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, extractErrorMessage, formatRetrievalContext, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
|