@ragable/sdk 0.5.0 → 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 +405 -175
- package/dist/index.d.ts +405 -175
- package/dist/index.js +1305 -455
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1290 -455
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -66,12 +66,18 @@ 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)`),
|
|
72
76
|
* or the browser throws **Illegal invocation**. Use this for defaults and for `options.fetch`.
|
|
73
77
|
*/
|
|
74
78
|
declare function bindFetch(custom?: typeof fetch): typeof fetch;
|
|
79
|
+
/** Default hosted API (`…/api`) when `baseUrl` is omitted (browser + server clients). */
|
|
80
|
+
declare const DEFAULT_RAGABLE_API_BASE = "https://ragable-341305259977.asia-southeast1.run.app/api";
|
|
75
81
|
interface RagableClientOptions {
|
|
76
82
|
apiKey: string;
|
|
77
83
|
baseUrl?: string;
|
|
@@ -81,11 +87,32 @@ interface RagableClientOptions {
|
|
|
81
87
|
type RequestOptions = Omit<RequestInit, "body"> & {
|
|
82
88
|
body?: unknown;
|
|
83
89
|
};
|
|
84
|
-
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";
|
|
85
96
|
readonly status: number;
|
|
86
97
|
readonly body: unknown;
|
|
98
|
+
readonly code: string | undefined;
|
|
99
|
+
readonly details: string | undefined;
|
|
87
100
|
constructor(message: string, status: number, body: unknown);
|
|
88
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
|
+
}
|
|
89
116
|
declare function extractErrorMessage(payload: unknown, fallback: string): string;
|
|
90
117
|
declare class RagableRequestClient {
|
|
91
118
|
private readonly apiKey;
|
|
@@ -240,7 +267,7 @@ declare class AgentsClient {
|
|
|
240
267
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
241
268
|
}
|
|
242
269
|
|
|
243
|
-
/**
|
|
270
|
+
/** @deprecated Kept for backward compat with `database.query()`. Not used by PostgREST path. */
|
|
244
271
|
interface BrowserSqlExecParams {
|
|
245
272
|
databaseInstanceId: string;
|
|
246
273
|
sql: string;
|
|
@@ -249,18 +276,26 @@ interface BrowserSqlExecParams {
|
|
|
249
276
|
timeoutMs?: number;
|
|
250
277
|
rowLimit?: number;
|
|
251
278
|
}
|
|
279
|
+
/** @deprecated Kept for backward compat with `database.query()`. Not used by PostgREST path. */
|
|
252
280
|
interface BrowserSqlExecResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
253
281
|
command: string;
|
|
254
282
|
rowCount: number;
|
|
255
283
|
truncated: boolean;
|
|
256
284
|
rows: Row[];
|
|
257
285
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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;
|
|
263
297
|
}
|
|
298
|
+
type PostgRESTFetch = (params: PostgRESTFetchParams) => Promise<Response>;
|
|
264
299
|
type PostgrestResult<T> = {
|
|
265
300
|
data: T;
|
|
266
301
|
error: null;
|
|
@@ -268,161 +303,167 @@ type PostgrestResult<T> = {
|
|
|
268
303
|
data: null;
|
|
269
304
|
error: RagableError;
|
|
270
305
|
};
|
|
271
|
-
/** Map async throws to `{ data, error }` like Supabase JS client. */
|
|
272
306
|
declare function asPostgrestResponse<T>(fn: () => Promise<T>): Promise<PostgrestResult<T>>;
|
|
273
|
-
type
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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;
|
|
277
315
|
private readonly databaseInstanceId;
|
|
278
316
|
private readonly table;
|
|
279
317
|
private readonly columns;
|
|
280
|
-
|
|
318
|
+
filters: Filter[];
|
|
281
319
|
private _limit?;
|
|
320
|
+
private _offset?;
|
|
282
321
|
private _order?;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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;
|
|
292
335
|
limit(n: number): this;
|
|
293
|
-
|
|
336
|
+
offset(n: number): this;
|
|
337
|
+
range(from: number, to: number): this;
|
|
338
|
+
order(column: ColumnName<D, T>, options?: {
|
|
294
339
|
ascending?: boolean;
|
|
340
|
+
nullsFirst?: boolean;
|
|
295
341
|
}): this;
|
|
296
|
-
|
|
342
|
+
abortSignal(signal: AbortSignal): this;
|
|
343
|
+
private buildSearchParams;
|
|
297
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>;
|
|
298
345
|
private executeMany;
|
|
299
346
|
single(): Promise<PostgrestResult<Row>>;
|
|
300
347
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
301
348
|
}
|
|
302
|
-
/** After `.insert()`: await without `.select()` → `{ data: null }` (Supabase default). */
|
|
303
349
|
declare class PostgrestInsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
|
|
304
|
-
private readonly
|
|
350
|
+
private readonly pgFetch;
|
|
305
351
|
private readonly databaseInstanceId;
|
|
306
352
|
private readonly table;
|
|
307
353
|
private readonly rows;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
* Return inserted rows (Supabase: chain `.select()` to get data).
|
|
311
|
-
* @see https://supabase.com/docs/reference/javascript/insert
|
|
312
|
-
*/
|
|
354
|
+
private _signal?;
|
|
355
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, rows: Record<string, unknown>[]);
|
|
313
356
|
select(columns?: string): PostgrestInsertReturningBuilder<Row>;
|
|
357
|
+
abortSignal(signal: AbortSignal): this;
|
|
314
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>;
|
|
315
359
|
private executeNoReturn;
|
|
316
360
|
}
|
|
317
361
|
declare class PostgrestInsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
318
|
-
private readonly
|
|
362
|
+
private readonly pgFetch;
|
|
319
363
|
private readonly databaseInstanceId;
|
|
320
364
|
private readonly table;
|
|
321
365
|
private readonly rows;
|
|
322
366
|
private readonly returning;
|
|
323
|
-
|
|
367
|
+
private readonly _signal?;
|
|
368
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], returning: string, _signal?: AbortSignal | undefined);
|
|
324
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>;
|
|
325
370
|
private executeMany;
|
|
326
371
|
single(): Promise<PostgrestResult<Row>>;
|
|
327
372
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
328
373
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
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;
|
|
332
376
|
private readonly databaseInstanceId;
|
|
333
377
|
private readonly table;
|
|
334
378
|
private readonly patch;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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;
|
|
349
393
|
select(columns?: string): PostgrestUpdateReturningBuilder<Row>;
|
|
394
|
+
abortSignal(signal: AbortSignal): this;
|
|
350
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;
|
|
351
397
|
private executeNoReturn;
|
|
352
398
|
}
|
|
353
399
|
declare class PostgrestUpdateReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
354
|
-
private readonly
|
|
400
|
+
private readonly pgFetch;
|
|
355
401
|
private readonly databaseInstanceId;
|
|
356
402
|
private readonly table;
|
|
357
403
|
private readonly patch;
|
|
358
404
|
private readonly filters;
|
|
359
405
|
private readonly returning;
|
|
360
|
-
|
|
406
|
+
private readonly _signal?;
|
|
407
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, patch: Record<string, unknown>, filters: Filter[], returning: string, _signal?: AbortSignal | undefined);
|
|
361
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>;
|
|
362
409
|
private executeMany;
|
|
363
410
|
single(): Promise<PostgrestResult<Row>>;
|
|
364
411
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
365
412
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
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;
|
|
369
415
|
private readonly databaseInstanceId;
|
|
370
416
|
private readonly table;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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;
|
|
385
431
|
select(columns?: string): PostgrestDeleteReturningBuilder<Row>;
|
|
432
|
+
abortSignal(signal: AbortSignal): this;
|
|
386
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>;
|
|
387
434
|
private executeNoReturn;
|
|
388
435
|
}
|
|
389
436
|
declare class PostgrestDeleteReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
390
|
-
private readonly
|
|
437
|
+
private readonly pgFetch;
|
|
391
438
|
private readonly databaseInstanceId;
|
|
392
439
|
private readonly table;
|
|
393
440
|
private readonly filters;
|
|
394
441
|
private readonly returning;
|
|
395
|
-
|
|
442
|
+
private readonly _signal?;
|
|
443
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, filters: Filter[], returning: string, _signal?: AbortSignal | undefined);
|
|
396
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>;
|
|
397
445
|
private executeMany;
|
|
398
446
|
single(): Promise<PostgrestResult<Row>>;
|
|
399
447
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
400
448
|
}
|
|
401
449
|
interface PostgrestUpsertOptions {
|
|
402
|
-
/** Column(s) for `ON CONFLICT` — single name or comma-separated, e.g. `"id"` or `"org_id,user_id"`. */
|
|
403
450
|
onConflict: string;
|
|
404
|
-
/** When true, `ON CONFLICT DO NOTHING` (no update of existing rows). */
|
|
405
451
|
ignoreDuplicates?: boolean;
|
|
406
452
|
}
|
|
407
|
-
/** Upsert without `.select()` → `{ data: null }`. */
|
|
408
453
|
declare class PostgrestUpsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
|
|
409
|
-
private readonly
|
|
454
|
+
private readonly pgFetch;
|
|
410
455
|
private readonly databaseInstanceId;
|
|
411
456
|
private readonly table;
|
|
412
457
|
private readonly rows;
|
|
458
|
+
private readonly onConflict;
|
|
413
459
|
private readonly ignoreDuplicates;
|
|
414
|
-
private
|
|
415
|
-
constructor(
|
|
416
|
-
/**
|
|
417
|
-
* Return upserted rows (Supabase: `.upsert().select()`).
|
|
418
|
-
* @see https://supabase.com/docs/reference/javascript/upsert
|
|
419
|
-
*/
|
|
460
|
+
private _signal?;
|
|
461
|
+
constructor(pgFetch: PostgRESTFetch, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], onConflict: string, ignoreDuplicates: boolean);
|
|
420
462
|
select(columns?: string): PostgrestUpsertReturningBuilder<Row>;
|
|
463
|
+
abortSignal(signal: AbortSignal): this;
|
|
421
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>;
|
|
422
465
|
private executeNoReturn;
|
|
423
|
-
|
|
424
|
-
/** Used by returning builder */
|
|
425
|
-
runWithReturning(returning: string): Promise<BrowserSqlExecResult<Row>>;
|
|
466
|
+
runUpsert(prefer: string, selectCols: string | null): Promise<Row[]>;
|
|
426
467
|
}
|
|
427
468
|
declare class PostgrestUpsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
|
|
428
469
|
private readonly root;
|
|
@@ -434,48 +475,282 @@ declare class PostgrestUpsertReturningBuilder<Row extends Record<string, unknown
|
|
|
434
475
|
maybeSingle(): Promise<PostgrestResult<Row | null>>;
|
|
435
476
|
}
|
|
436
477
|
declare class PostgrestTableApi<Database extends RagableDatabase = DefaultRagableDatabase, TableName extends RagableTableNames<Database> = RagableTableNames<Database>> {
|
|
437
|
-
private readonly
|
|
478
|
+
private readonly pgFetch;
|
|
438
479
|
private readonly databaseInstanceId;
|
|
439
480
|
private readonly table;
|
|
440
|
-
constructor(
|
|
441
|
-
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>;
|
|
442
483
|
insert(values: TableInsertRow<Database, TableName> | TableInsertRow<Database, TableName>[]): PostgrestInsertRootBuilder<TableRow<Database, TableName>>;
|
|
443
|
-
update(patch: TableUpdatePatch<Database, TableName>): PostgrestUpdateRootBuilder<TableRow<Database, TableName
|
|
444
|
-
delete(): PostgrestDeleteRootBuilder<TableRow<Database, TableName
|
|
445
|
-
/**
|
|
446
|
-
* `INSERT ... ON CONFLICT ... DO UPDATE` (or `DO NOTHING` with `ignoreDuplicates`).
|
|
447
|
-
* @see https://supabase.com/docs/reference/javascript/upsert
|
|
448
|
-
*/
|
|
484
|
+
update(patch: TableUpdatePatch<Database, TableName>): PostgrestUpdateRootBuilder<TableRow<Database, TableName>, Database, TableName>;
|
|
485
|
+
delete(): PostgrestDeleteRootBuilder<TableRow<Database, TableName>, Database, TableName>;
|
|
449
486
|
upsert(values: TableInsertRow<Database, TableName> | TableInsertRow<Database, TableName>[], options: PostgrestUpsertOptions): PostgrestUpsertRootBuilder<TableRow<Database, TableName>>;
|
|
450
487
|
}
|
|
451
488
|
|
|
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
|
+
|
|
452
738
|
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
739
|
+
type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
|
|
453
740
|
interface RagableBrowserClientOptions {
|
|
454
|
-
/** Organization id (UUID) — public agent chat URLs. */
|
|
455
741
|
organizationId: string;
|
|
456
|
-
/**
|
|
457
|
-
* Authentication group id when using {@link RagableBrowserAuthClient} or
|
|
458
|
-
* {@link RagableBrowserDatabaseClient}.
|
|
459
|
-
*/
|
|
460
742
|
authGroupId?: string;
|
|
461
|
-
/**
|
|
462
|
-
* Default Backspace SQL instance id for {@link RagableBrowser.from} (Supabase-style table API).
|
|
463
|
-
*/
|
|
464
743
|
databaseInstanceId?: string;
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
*/
|
|
744
|
+
dataAuth?: BrowserDataAuthMode;
|
|
745
|
+
dataStaticKey?: string;
|
|
746
|
+
getDataStaticKey?: () => string | null | Promise<string | null>;
|
|
469
747
|
getAccessToken?: () => string | null | Promise<string | null>;
|
|
470
|
-
/**
|
|
471
|
-
* API base URL including `/api`, e.g. `https://api.example.com/api`.
|
|
472
|
-
* @default "http://localhost:8080/api"
|
|
473
|
-
*/
|
|
474
748
|
baseUrl?: string;
|
|
475
749
|
fetch?: typeof fetch;
|
|
476
750
|
headers?: HeadersInit;
|
|
751
|
+
auth?: AuthOptions;
|
|
752
|
+
transport?: Partial<TransportOptions>;
|
|
477
753
|
}
|
|
478
|
-
/** Successful register/login response (typed `user` via `AuthUser` generic). */
|
|
479
754
|
interface BrowserAuthSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
480
755
|
user: AuthUser;
|
|
481
756
|
accessToken: string;
|
|
@@ -487,25 +762,18 @@ interface BrowserAuthTokens {
|
|
|
487
762
|
refreshToken: string;
|
|
488
763
|
expiresIn: string;
|
|
489
764
|
}
|
|
490
|
-
/** Supabase-compatible session shape (snake_case tokens). */
|
|
491
765
|
interface SupabaseCompatSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
492
766
|
access_token: string;
|
|
493
767
|
refresh_token: string;
|
|
494
|
-
/** Best-effort seconds from Ragable `expiresIn` (e.g. `7d`, `3600`). */
|
|
495
768
|
expires_in: number;
|
|
496
769
|
token_type: "bearer";
|
|
497
770
|
user: AuthUser;
|
|
498
771
|
}
|
|
499
772
|
|
|
500
|
-
/** End-user auth — Ragable names + Supabase/Firebase-style aliases returning `{ data, error }`. */
|
|
501
773
|
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
502
|
-
private readonly
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
private toUrl;
|
|
506
|
-
private baseHeaders;
|
|
507
|
-
private authPrefix;
|
|
508
|
-
/** Supabase: `signUp` → `{ data: { user, session }, error }` */
|
|
774
|
+
private readonly ragableAuth;
|
|
775
|
+
constructor(_options: RagableBrowserClientOptions, ragableAuth?: RagableAuth<AuthUser> | null);
|
|
776
|
+
private get auth();
|
|
509
777
|
signUp(credentials: {
|
|
510
778
|
email: string;
|
|
511
779
|
password: string;
|
|
@@ -516,7 +784,6 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
516
784
|
user: AuthUser;
|
|
517
785
|
session: SupabaseCompatSession<AuthUser>;
|
|
518
786
|
}>>;
|
|
519
|
-
/** Supabase: `signInWithPassword` */
|
|
520
787
|
signInWithPassword(credentials: {
|
|
521
788
|
email: string;
|
|
522
789
|
password: string;
|
|
@@ -524,16 +791,13 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
524
791
|
user: AuthUser;
|
|
525
792
|
session: SupabaseCompatSession<AuthUser>;
|
|
526
793
|
}>>;
|
|
527
|
-
/** Supabase: `refreshSession` */
|
|
528
794
|
refreshSession(refreshToken: string): Promise<PostgrestResult<{
|
|
529
795
|
session: SupabaseCompatSession<AuthUser>;
|
|
530
796
|
user: AuthUser;
|
|
531
797
|
}>>;
|
|
532
|
-
/** Supabase: `getUser()` — needs `getAccessToken` on the client */
|
|
533
798
|
getUser(): Promise<PostgrestResult<{
|
|
534
799
|
user: AuthUser;
|
|
535
800
|
}>>;
|
|
536
|
-
/** Supabase: `updateUser` */
|
|
537
801
|
updateUser(attributes: {
|
|
538
802
|
email?: string;
|
|
539
803
|
password?: string;
|
|
@@ -543,16 +807,11 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
543
807
|
}): Promise<PostgrestResult<{
|
|
544
808
|
user: AuthUser;
|
|
545
809
|
}>>;
|
|
546
|
-
/**
|
|
547
|
-
* Supabase/Firebase: no server call — clear tokens in your app.
|
|
548
|
-
* Returns `{ error: null }` for API compatibility.
|
|
549
|
-
*/
|
|
550
810
|
signOut(_options?: {
|
|
551
811
|
scope?: "global" | "local";
|
|
552
812
|
}): Promise<{
|
|
553
813
|
error: null;
|
|
554
814
|
}>;
|
|
555
|
-
private getUserFromToken;
|
|
556
815
|
register(body: {
|
|
557
816
|
email: string;
|
|
558
817
|
password: string;
|
|
@@ -574,19 +833,22 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
|
|
|
574
833
|
}): Promise<{
|
|
575
834
|
user: AuthUser;
|
|
576
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
|
+
}>>;
|
|
577
847
|
}
|
|
578
848
|
interface BrowserSqlQueryParams {
|
|
579
|
-
/**
|
|
580
|
-
* Defaults to `databaseInstanceId` on {@link RagableBrowserClientOptions} when set
|
|
581
|
-
* (so you can configure it once on `createBrowserClient`).
|
|
582
|
-
*/
|
|
583
849
|
databaseInstanceId?: string;
|
|
584
850
|
sql: string;
|
|
585
851
|
params?: unknown[];
|
|
586
|
-
/**
|
|
587
|
-
* Default `true`. When `false`, the API allows INSERT/UPDATE/DELETE (and existing safe reads);
|
|
588
|
-
* DDL (`CREATE`/`DROP`/`ALTER`/…) and privilege changes remain blocked.
|
|
589
|
-
*/
|
|
590
852
|
readOnly?: boolean;
|
|
591
853
|
timeoutMs?: number;
|
|
592
854
|
rowLimit?: number;
|
|
@@ -597,59 +859,38 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
|
|
|
597
859
|
truncated: boolean;
|
|
598
860
|
rows: Row[];
|
|
599
861
|
}
|
|
600
|
-
/**
|
|
601
|
-
* Raw SQL against linked Postgres (escape hatch). Prefer {@link RagableBrowser.from} for
|
|
602
|
-
* Supabase-style `.select()` / `.insert()` / `.update()` / `.delete()`.
|
|
603
|
-
*/
|
|
604
862
|
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
605
863
|
private readonly options;
|
|
864
|
+
private readonly ragableAuth;
|
|
606
865
|
private readonly fetchImpl;
|
|
607
|
-
constructor(options: RagableBrowserClientOptions);
|
|
866
|
+
constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
|
|
608
867
|
private toUrl;
|
|
609
868
|
query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
|
|
610
869
|
private baseHeaders;
|
|
611
870
|
}
|
|
612
|
-
/**
|
|
613
|
-
* Browser-safe client: **no org API key**. Uses public routes and end-user JWTs
|
|
614
|
-
* from {@link RagableBrowserAuthClient}.
|
|
615
|
-
*/
|
|
616
871
|
declare class RagableBrowserAgentsClient {
|
|
617
872
|
private readonly options;
|
|
618
873
|
private readonly fetchImpl;
|
|
619
874
|
constructor(options: RagableBrowserClientOptions);
|
|
620
875
|
private toUrl;
|
|
621
|
-
/**
|
|
622
|
-
* Stream agent execution as SSE (`POST /public/organizations/:orgId/agents/:agentId/chat/stream`).
|
|
623
|
-
*/
|
|
624
876
|
chatStream(agentId: string, params: AgentPublicChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
625
877
|
}
|
|
626
|
-
/** Public chat params — same shape as {@link AgentChatParams} plus optional trigger fields. */
|
|
627
878
|
interface AgentPublicChatParams extends AgentChatParams {
|
|
628
879
|
triggerSubtype?: string;
|
|
629
880
|
triggerNodeId?: string;
|
|
630
881
|
}
|
|
631
|
-
/**
|
|
632
|
-
* Browser client: mirrors **Supabase JS** (`createClient`, `.from()`, `.auth.signInWithPassword`, `{ data, error }`)
|
|
633
|
-
* plus Ragable **`agents.chatStream`**. Server secrets: {@link createRagableServerClient} / {@link createClient} with `apiKey`.
|
|
634
|
-
*/
|
|
635
882
|
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
636
883
|
readonly agents: RagableBrowserAgentsClient;
|
|
637
884
|
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
638
885
|
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
886
|
+
readonly transport: Transport;
|
|
639
887
|
private readonly options;
|
|
888
|
+
private readonly _ragableAuth;
|
|
640
889
|
constructor(options: RagableBrowserClientOptions);
|
|
641
|
-
/**
|
|
642
|
-
* Supabase-style table API: `.from('items').select().eq('id', 1).single()`.
|
|
643
|
-
* Pass `databaseInstanceId` here or set `databaseInstanceId` on the client options.
|
|
644
|
-
*/
|
|
645
890
|
from<TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string): PostgrestTableApi<Database, TableName>;
|
|
891
|
+
destroy(): void;
|
|
646
892
|
}
|
|
647
|
-
/**
|
|
648
|
-
* **Supabase-equivalent** browser client factory (no org API key).
|
|
649
|
-
* Same as {@link createRagableBrowserClient}.
|
|
650
|
-
*/
|
|
651
893
|
declare function createBrowserClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
652
|
-
/** Alias for {@link createBrowserClient} — matches Supabase `createClient` naming. */
|
|
653
894
|
declare const createRagableBrowserClient: typeof createBrowserClient;
|
|
654
895
|
|
|
655
896
|
/**
|
|
@@ -723,20 +964,9 @@ declare class Ragable {
|
|
|
723
964
|
};
|
|
724
965
|
constructor(options: RagableClientOptions);
|
|
725
966
|
}
|
|
726
|
-
/**
|
|
727
|
-
* **Supabase-style overloads**
|
|
728
|
-
* - `createClient(RAGABLE_URL, { organizationId, authGroupId, … })` — browser (no API key)
|
|
729
|
-
* - `createClient({ apiKey, baseUrl })` — server / Engine (secret key)
|
|
730
|
-
*
|
|
731
|
-
* Prefer {@link createRagableServerClient} in backend code if the dual overload is confusing.
|
|
732
|
-
*/
|
|
733
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>;
|
|
734
968
|
declare function createClient(options: RagableClientOptions): Ragable;
|
|
735
969
|
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
736
|
-
/**
|
|
737
|
-
* Explicit **server** factory — same as `createClient({ apiKey, baseUrl })`.
|
|
738
|
-
* Use in the Engine; never import alongside browser `createClient(url, …)` if you want tree-shaking clarity.
|
|
739
|
-
*/
|
|
740
970
|
declare function createRagableServerClient(options: RagableClientOptions): Ragable;
|
|
741
971
|
|
|
742
|
-
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, 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 };
|