@ragable/sdk 0.4.1 → 0.5.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 CHANGED
@@ -53,6 +53,19 @@ type TablesInsert<D extends RagableDatabase, TableName extends keyof D["public"]
53
53
  type TablesUpdate<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
54
54
  Update: infer U;
55
55
  } ? U extends Record<string, unknown> ? U : Record<string, unknown> : Partial<Tables<D, TableName>>;
56
+ /**
57
+ * Table name union for `client.from(...)`.
58
+ * When `Tables` is empty (`DefaultRagableDatabase`), any `string` is allowed.
59
+ */
60
+ type RagableTableNames<D extends RagableDatabase> = [
61
+ keyof D["public"]["Tables"]
62
+ ] extends [never] ? string : Extract<keyof D["public"]["Tables"], string>;
63
+ /** Row type for `from(table)` when a concrete `Database` generic is set. */
64
+ type TableRow<D extends RagableDatabase, T extends RagableTableNames<D>> = [keyof D["public"]["Tables"]] extends [never] ? Record<string, unknown> : T extends keyof D["public"]["Tables"] ? Tables<D, T> : Record<string, unknown>;
65
+ /** Insert payload for typed `from(table).insert(...)`. */
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
+ /** Update patch for typed `from(table).update(...)`. */
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>;
56
69
 
57
70
  /**
58
71
  * Native `fetch` must not be called as a detached reference (`const f = fetch; f(url)`),
@@ -242,6 +255,12 @@ interface BrowserSqlExecResult<Row extends Record<string, unknown> = Record<stri
242
255
  truncated: boolean;
243
256
  rows: Row[];
244
257
  }
258
+ type FilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike";
259
+ interface Filter {
260
+ op: FilterOp;
261
+ column: string;
262
+ value: unknown;
263
+ }
245
264
  type PostgrestResult<T> = {
246
265
  data: T;
247
266
  error: null;
@@ -274,58 +293,160 @@ declare class PostgrestSelectBuilder<Row extends Record<string, unknown> = Recor
274
293
  order(column: string, options?: {
275
294
  ascending?: boolean;
276
295
  }): this;
277
- /** @param includeUserLimit when false, omit `.limit()` (for `.single()` / `.maybeSingle()`). */
278
296
  private buildSelectCore;
279
297
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
280
298
  private executeMany;
281
299
  single(): Promise<PostgrestResult<Row>>;
282
300
  maybeSingle(): Promise<PostgrestResult<Row | null>>;
283
301
  }
284
- declare class PostgrestInsertBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
302
+ /** After `.insert()`: await without `.select()` `{ data: null }` (Supabase default). */
303
+ declare class PostgrestInsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
285
304
  private readonly run;
286
305
  private readonly databaseInstanceId;
287
306
  private readonly table;
288
307
  private readonly rows;
289
- private returning;
290
308
  constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[]);
291
- select(columns?: string): this;
309
+ /**
310
+ * Return inserted rows (Supabase: chain `.select()` to get data).
311
+ * @see https://supabase.com/docs/reference/javascript/insert
312
+ */
313
+ select(columns?: string): PostgrestInsertReturningBuilder<Row>;
314
+ 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
+ private executeNoReturn;
316
+ }
317
+ declare class PostgrestInsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
318
+ private readonly run;
319
+ private readonly databaseInstanceId;
320
+ private readonly table;
321
+ private readonly rows;
322
+ private readonly returning;
323
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], returning: string);
292
324
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
293
- private execute;
325
+ private executeMany;
326
+ single(): Promise<PostgrestResult<Row>>;
327
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
294
328
  }
295
- declare class PostgrestUpdateBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
329
+ /** Update without `.select()` `{ data: null }` on success. */
330
+ declare class PostgrestUpdateRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
296
331
  private readonly run;
297
332
  private readonly databaseInstanceId;
298
333
  private readonly table;
299
334
  private readonly patch;
300
335
  private filters;
301
- private returning;
302
336
  constructor(run: RunQuery, databaseInstanceId: string, table: string, patch: Record<string, unknown>);
303
337
  eq(column: string, value: unknown): this;
304
- select(columns?: string): this;
338
+ neq(column: string, value: unknown): this;
339
+ gt(column: string, value: unknown): this;
340
+ gte(column: string, value: unknown): this;
341
+ lt(column: string, value: unknown): this;
342
+ lte(column: string, value: unknown): this;
343
+ like(column: string, value: unknown): this;
344
+ ilike(column: string, value: unknown): this;
345
+ /**
346
+ * Return updated rows (Supabase: `.update().eq().select()`).
347
+ * @see https://supabase.com/docs/reference/javascript/update
348
+ */
349
+ select(columns?: string): PostgrestUpdateReturningBuilder<Row>;
350
+ then<TResult1 = PostgrestResult<null>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<null>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
351
+ private executeNoReturn;
352
+ }
353
+ declare class PostgrestUpdateReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
354
+ private readonly run;
355
+ private readonly databaseInstanceId;
356
+ private readonly table;
357
+ private readonly patch;
358
+ private readonly filters;
359
+ private readonly returning;
360
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, patch: Record<string, unknown>, filters: Filter[], returning: string);
305
361
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
306
- private execute;
362
+ private executeMany;
363
+ single(): Promise<PostgrestResult<Row>>;
364
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
307
365
  }
308
- declare class PostgrestDeleteBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
366
+ /** Delete without `.select()` `{ data: null }`. */
367
+ declare class PostgrestDeleteRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
309
368
  private readonly run;
310
369
  private readonly databaseInstanceId;
311
370
  private readonly table;
312
371
  private filters;
313
- private returning;
314
372
  constructor(run: RunQuery, databaseInstanceId: string, table: string);
315
373
  eq(column: string, value: unknown): this;
316
- select(columns?: string): this;
374
+ neq(column: string, value: unknown): this;
375
+ gt(column: string, value: unknown): this;
376
+ gte(column: string, value: unknown): this;
377
+ lt(column: string, value: unknown): this;
378
+ lte(column: string, value: unknown): this;
379
+ like(column: string, value: unknown): this;
380
+ ilike(column: string, value: unknown): this;
381
+ /**
382
+ * Return deleted rows (Supabase: `.delete().eq().select()`).
383
+ * @see https://supabase.com/docs/reference/javascript/delete
384
+ */
385
+ select(columns?: string): PostgrestDeleteReturningBuilder<Row>;
386
+ 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
+ private executeNoReturn;
388
+ }
389
+ declare class PostgrestDeleteReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
390
+ private readonly run;
391
+ private readonly databaseInstanceId;
392
+ private readonly table;
393
+ private readonly filters;
394
+ private readonly returning;
395
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, filters: Filter[], returning: string);
317
396
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
318
- private execute;
397
+ private executeMany;
398
+ single(): Promise<PostgrestResult<Row>>;
399
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
400
+ }
401
+ interface PostgrestUpsertOptions {
402
+ /** Column(s) for `ON CONFLICT` — single name or comma-separated, e.g. `"id"` or `"org_id,user_id"`. */
403
+ onConflict: string;
404
+ /** When true, `ON CONFLICT DO NOTHING` (no update of existing rows). */
405
+ ignoreDuplicates?: boolean;
319
406
  }
320
- declare class PostgrestTableApi<Row extends Record<string, unknown> = Record<string, unknown>> {
407
+ /** Upsert without `.select()` `{ data: null }`. */
408
+ declare class PostgrestUpsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
321
409
  private readonly run;
322
410
  private readonly databaseInstanceId;
323
411
  private readonly table;
324
- constructor(run: RunQuery, databaseInstanceId: string, table: string);
325
- select(columns?: string): PostgrestSelectBuilder<Row>;
326
- insert(values: Record<string, unknown> | Record<string, unknown>[]): PostgrestInsertBuilder<Row>;
327
- update(patch: Record<string, unknown>): PostgrestUpdateBuilder<Row>;
328
- delete(): PostgrestDeleteBuilder<Row>;
412
+ private readonly rows;
413
+ private readonly ignoreDuplicates;
414
+ private readonly conflictCols;
415
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], onConflict: string, ignoreDuplicates: boolean);
416
+ /**
417
+ * Return upserted rows (Supabase: `.upsert().select()`).
418
+ * @see https://supabase.com/docs/reference/javascript/upsert
419
+ */
420
+ select(columns?: string): PostgrestUpsertReturningBuilder<Row>;
421
+ 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
+ private executeNoReturn;
423
+ private runUpsert;
424
+ /** Used by returning builder */
425
+ runWithReturning(returning: string): Promise<BrowserSqlExecResult<Row>>;
426
+ }
427
+ declare class PostgrestUpsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
428
+ private readonly root;
429
+ private readonly returning;
430
+ constructor(root: PostgrestUpsertRootBuilder<Row>, returning: string);
431
+ then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
432
+ private executeMany;
433
+ single(): Promise<PostgrestResult<Row>>;
434
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
435
+ }
436
+ declare class PostgrestTableApi<Database extends RagableDatabase = DefaultRagableDatabase, TableName extends RagableTableNames<Database> = RagableTableNames<Database>> {
437
+ private readonly run;
438
+ private readonly databaseInstanceId;
439
+ private readonly table;
440
+ constructor(run: RunQuery, databaseInstanceId: string, table: TableName extends string ? string : string);
441
+ select(columns?: string): PostgrestSelectBuilder<TableRow<Database, TableName>>;
442
+ 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
+ */
449
+ upsert(values: TableInsertRow<Database, TableName> | TableInsertRow<Database, TableName>[], options: PostgrestUpsertOptions): PostgrestUpsertRootBuilder<TableRow<Database, TableName>>;
329
450
  }
330
451
 
331
452
  declare function normalizeBrowserApiBase(baseUrl?: string): string;
@@ -455,7 +576,11 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
455
576
  }>;
456
577
  }
457
578
  interface BrowserSqlQueryParams {
458
- databaseInstanceId: string;
579
+ /**
580
+ * Defaults to `databaseInstanceId` on {@link RagableBrowserClientOptions} when set
581
+ * (so you can configure it once on `createBrowserClient`).
582
+ */
583
+ databaseInstanceId?: string;
459
584
  sql: string;
460
585
  params?: unknown[];
461
586
  /**
@@ -517,7 +642,7 @@ declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDa
517
642
  * Supabase-style table API: `.from('items').select().eq('id', 1).single()`.
518
643
  * Pass `databaseInstanceId` here or set `databaseInstanceId` on the client options.
519
644
  */
520
- from<Row extends Record<string, unknown> = Record<string, unknown>>(table: string, databaseInstanceId?: string): PostgrestTableApi<Row>;
645
+ from<TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string): PostgrestTableApi<Database, TableName>;
521
646
  }
522
647
  /**
523
648
  * **Supabase-equivalent** browser client factory (no org API key).
@@ -614,4 +739,4 @@ declare function createClient<Database extends RagableDatabase = DefaultRagableD
614
739
  */
615
740
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
616
741
 
617
- export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, PostgrestDeleteBuilder, PostgrestInsertBuilder, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableRequestClient, type RagableTableDefinition, type RequestOptions, type RetrieveParams, type RunQuery, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type Tables, type TablesInsert, type TablesUpdate, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
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 };
package/dist/index.d.ts CHANGED
@@ -53,6 +53,19 @@ type TablesInsert<D extends RagableDatabase, TableName extends keyof D["public"]
53
53
  type TablesUpdate<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
54
54
  Update: infer U;
55
55
  } ? U extends Record<string, unknown> ? U : Record<string, unknown> : Partial<Tables<D, TableName>>;
56
+ /**
57
+ * Table name union for `client.from(...)`.
58
+ * When `Tables` is empty (`DefaultRagableDatabase`), any `string` is allowed.
59
+ */
60
+ type RagableTableNames<D extends RagableDatabase> = [
61
+ keyof D["public"]["Tables"]
62
+ ] extends [never] ? string : Extract<keyof D["public"]["Tables"], string>;
63
+ /** Row type for `from(table)` when a concrete `Database` generic is set. */
64
+ type TableRow<D extends RagableDatabase, T extends RagableTableNames<D>> = [keyof D["public"]["Tables"]] extends [never] ? Record<string, unknown> : T extends keyof D["public"]["Tables"] ? Tables<D, T> : Record<string, unknown>;
65
+ /** Insert payload for typed `from(table).insert(...)`. */
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
+ /** Update patch for typed `from(table).update(...)`. */
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>;
56
69
 
57
70
  /**
58
71
  * Native `fetch` must not be called as a detached reference (`const f = fetch; f(url)`),
@@ -242,6 +255,12 @@ interface BrowserSqlExecResult<Row extends Record<string, unknown> = Record<stri
242
255
  truncated: boolean;
243
256
  rows: Row[];
244
257
  }
258
+ type FilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike";
259
+ interface Filter {
260
+ op: FilterOp;
261
+ column: string;
262
+ value: unknown;
263
+ }
245
264
  type PostgrestResult<T> = {
246
265
  data: T;
247
266
  error: null;
@@ -274,58 +293,160 @@ declare class PostgrestSelectBuilder<Row extends Record<string, unknown> = Recor
274
293
  order(column: string, options?: {
275
294
  ascending?: boolean;
276
295
  }): this;
277
- /** @param includeUserLimit when false, omit `.limit()` (for `.single()` / `.maybeSingle()`). */
278
296
  private buildSelectCore;
279
297
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
280
298
  private executeMany;
281
299
  single(): Promise<PostgrestResult<Row>>;
282
300
  maybeSingle(): Promise<PostgrestResult<Row | null>>;
283
301
  }
284
- declare class PostgrestInsertBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
302
+ /** After `.insert()`: await without `.select()` `{ data: null }` (Supabase default). */
303
+ declare class PostgrestInsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
285
304
  private readonly run;
286
305
  private readonly databaseInstanceId;
287
306
  private readonly table;
288
307
  private readonly rows;
289
- private returning;
290
308
  constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[]);
291
- select(columns?: string): this;
309
+ /**
310
+ * Return inserted rows (Supabase: chain `.select()` to get data).
311
+ * @see https://supabase.com/docs/reference/javascript/insert
312
+ */
313
+ select(columns?: string): PostgrestInsertReturningBuilder<Row>;
314
+ 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
+ private executeNoReturn;
316
+ }
317
+ declare class PostgrestInsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
318
+ private readonly run;
319
+ private readonly databaseInstanceId;
320
+ private readonly table;
321
+ private readonly rows;
322
+ private readonly returning;
323
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], returning: string);
292
324
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
293
- private execute;
325
+ private executeMany;
326
+ single(): Promise<PostgrestResult<Row>>;
327
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
294
328
  }
295
- declare class PostgrestUpdateBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
329
+ /** Update without `.select()` `{ data: null }` on success. */
330
+ declare class PostgrestUpdateRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
296
331
  private readonly run;
297
332
  private readonly databaseInstanceId;
298
333
  private readonly table;
299
334
  private readonly patch;
300
335
  private filters;
301
- private returning;
302
336
  constructor(run: RunQuery, databaseInstanceId: string, table: string, patch: Record<string, unknown>);
303
337
  eq(column: string, value: unknown): this;
304
- select(columns?: string): this;
338
+ neq(column: string, value: unknown): this;
339
+ gt(column: string, value: unknown): this;
340
+ gte(column: string, value: unknown): this;
341
+ lt(column: string, value: unknown): this;
342
+ lte(column: string, value: unknown): this;
343
+ like(column: string, value: unknown): this;
344
+ ilike(column: string, value: unknown): this;
345
+ /**
346
+ * Return updated rows (Supabase: `.update().eq().select()`).
347
+ * @see https://supabase.com/docs/reference/javascript/update
348
+ */
349
+ select(columns?: string): PostgrestUpdateReturningBuilder<Row>;
350
+ then<TResult1 = PostgrestResult<null>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<null>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
351
+ private executeNoReturn;
352
+ }
353
+ declare class PostgrestUpdateReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
354
+ private readonly run;
355
+ private readonly databaseInstanceId;
356
+ private readonly table;
357
+ private readonly patch;
358
+ private readonly filters;
359
+ private readonly returning;
360
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, patch: Record<string, unknown>, filters: Filter[], returning: string);
305
361
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
306
- private execute;
362
+ private executeMany;
363
+ single(): Promise<PostgrestResult<Row>>;
364
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
307
365
  }
308
- declare class PostgrestDeleteBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
366
+ /** Delete without `.select()` `{ data: null }`. */
367
+ declare class PostgrestDeleteRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
309
368
  private readonly run;
310
369
  private readonly databaseInstanceId;
311
370
  private readonly table;
312
371
  private filters;
313
- private returning;
314
372
  constructor(run: RunQuery, databaseInstanceId: string, table: string);
315
373
  eq(column: string, value: unknown): this;
316
- select(columns?: string): this;
374
+ neq(column: string, value: unknown): this;
375
+ gt(column: string, value: unknown): this;
376
+ gte(column: string, value: unknown): this;
377
+ lt(column: string, value: unknown): this;
378
+ lte(column: string, value: unknown): this;
379
+ like(column: string, value: unknown): this;
380
+ ilike(column: string, value: unknown): this;
381
+ /**
382
+ * Return deleted rows (Supabase: `.delete().eq().select()`).
383
+ * @see https://supabase.com/docs/reference/javascript/delete
384
+ */
385
+ select(columns?: string): PostgrestDeleteReturningBuilder<Row>;
386
+ 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
+ private executeNoReturn;
388
+ }
389
+ declare class PostgrestDeleteReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
390
+ private readonly run;
391
+ private readonly databaseInstanceId;
392
+ private readonly table;
393
+ private readonly filters;
394
+ private readonly returning;
395
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, filters: Filter[], returning: string);
317
396
  then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
318
- private execute;
397
+ private executeMany;
398
+ single(): Promise<PostgrestResult<Row>>;
399
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
400
+ }
401
+ interface PostgrestUpsertOptions {
402
+ /** Column(s) for `ON CONFLICT` — single name or comma-separated, e.g. `"id"` or `"org_id,user_id"`. */
403
+ onConflict: string;
404
+ /** When true, `ON CONFLICT DO NOTHING` (no update of existing rows). */
405
+ ignoreDuplicates?: boolean;
319
406
  }
320
- declare class PostgrestTableApi<Row extends Record<string, unknown> = Record<string, unknown>> {
407
+ /** Upsert without `.select()` `{ data: null }`. */
408
+ declare class PostgrestUpsertRootBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<null>> {
321
409
  private readonly run;
322
410
  private readonly databaseInstanceId;
323
411
  private readonly table;
324
- constructor(run: RunQuery, databaseInstanceId: string, table: string);
325
- select(columns?: string): PostgrestSelectBuilder<Row>;
326
- insert(values: Record<string, unknown> | Record<string, unknown>[]): PostgrestInsertBuilder<Row>;
327
- update(patch: Record<string, unknown>): PostgrestUpdateBuilder<Row>;
328
- delete(): PostgrestDeleteBuilder<Row>;
412
+ private readonly rows;
413
+ private readonly ignoreDuplicates;
414
+ private readonly conflictCols;
415
+ constructor(run: RunQuery, databaseInstanceId: string, table: string, rows: Record<string, unknown>[], onConflict: string, ignoreDuplicates: boolean);
416
+ /**
417
+ * Return upserted rows (Supabase: `.upsert().select()`).
418
+ * @see https://supabase.com/docs/reference/javascript/upsert
419
+ */
420
+ select(columns?: string): PostgrestUpsertReturningBuilder<Row>;
421
+ 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
+ private executeNoReturn;
423
+ private runUpsert;
424
+ /** Used by returning builder */
425
+ runWithReturning(returning: string): Promise<BrowserSqlExecResult<Row>>;
426
+ }
427
+ declare class PostgrestUpsertReturningBuilder<Row extends Record<string, unknown> = Record<string, unknown>> implements PromiseLike<PostgrestResult<Row[]>> {
428
+ private readonly root;
429
+ private readonly returning;
430
+ constructor(root: PostgrestUpsertRootBuilder<Row>, returning: string);
431
+ then<TResult1 = PostgrestResult<Row[]>, TResult2 = never>(onfulfilled?: ((value: PostgrestResult<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
432
+ private executeMany;
433
+ single(): Promise<PostgrestResult<Row>>;
434
+ maybeSingle(): Promise<PostgrestResult<Row | null>>;
435
+ }
436
+ declare class PostgrestTableApi<Database extends RagableDatabase = DefaultRagableDatabase, TableName extends RagableTableNames<Database> = RagableTableNames<Database>> {
437
+ private readonly run;
438
+ private readonly databaseInstanceId;
439
+ private readonly table;
440
+ constructor(run: RunQuery, databaseInstanceId: string, table: TableName extends string ? string : string);
441
+ select(columns?: string): PostgrestSelectBuilder<TableRow<Database, TableName>>;
442
+ 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
+ */
449
+ upsert(values: TableInsertRow<Database, TableName> | TableInsertRow<Database, TableName>[], options: PostgrestUpsertOptions): PostgrestUpsertRootBuilder<TableRow<Database, TableName>>;
329
450
  }
330
451
 
331
452
  declare function normalizeBrowserApiBase(baseUrl?: string): string;
@@ -455,7 +576,11 @@ declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown>
455
576
  }>;
456
577
  }
457
578
  interface BrowserSqlQueryParams {
458
- databaseInstanceId: string;
579
+ /**
580
+ * Defaults to `databaseInstanceId` on {@link RagableBrowserClientOptions} when set
581
+ * (so you can configure it once on `createBrowserClient`).
582
+ */
583
+ databaseInstanceId?: string;
459
584
  sql: string;
460
585
  params?: unknown[];
461
586
  /**
@@ -517,7 +642,7 @@ declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDa
517
642
  * Supabase-style table API: `.from('items').select().eq('id', 1).single()`.
518
643
  * Pass `databaseInstanceId` here or set `databaseInstanceId` on the client options.
519
644
  */
520
- from<Row extends Record<string, unknown> = Record<string, unknown>>(table: string, databaseInstanceId?: string): PostgrestTableApi<Row>;
645
+ from<TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string): PostgrestTableApi<Database, TableName>;
521
646
  }
522
647
  /**
523
648
  * **Supabase-equivalent** browser client factory (no org API key).
@@ -614,4 +739,4 @@ declare function createClient<Database extends RagableDatabase = DefaultRagableD
614
739
  */
615
740
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
616
741
 
617
- export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, PostgrestDeleteBuilder, PostgrestInsertBuilder, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableRequestClient, type RagableTableDefinition, type RequestOptions, type RetrieveParams, type RunQuery, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type Tables, type TablesInsert, type TablesUpdate, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
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 };