@ragable/sdk 0.6.17 → 0.6.19

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
@@ -22,11 +22,9 @@ type RagableTableDefinition<Row extends Record<string, unknown> = Record<string,
22
22
  */
23
23
  interface RagableDatabase {
24
24
  public: {
25
- Tables: Record<string, RagableTableDefinition>;
26
- Views?: Record<string, {
27
- Row: Record<string, unknown>;
28
- }>;
29
- Enums?: Record<string, string>;
25
+ Tables: object;
26
+ Views?: object;
27
+ Enums?: object;
30
28
  };
31
29
  }
32
30
  /**
@@ -928,11 +926,29 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
928
926
  rows: Row[];
929
927
  }
930
928
  interface BrowserCollectionRecord<Row extends Record<string, unknown> = Record<string, unknown>> {
929
+ [key: string]: unknown;
931
930
  id: string;
932
931
  data: Row;
933
932
  createdAt: string;
934
933
  updatedAt: string;
935
934
  }
935
+ /**
936
+ * Collection APIs return record envelopes, but user schema `Row` types should be
937
+ * the JSON row inside `record.data`. If generated app types accidentally use the
938
+ * envelope as `Row`, unwrap it so consumers still get `record.data.<field>`.
939
+ */
940
+ type BrowserCollectionRowData<Row extends Record<string, unknown> = Record<string, unknown>> = Row extends {
941
+ id: string;
942
+ data: infer Data;
943
+ createdAt: string;
944
+ updatedAt: string;
945
+ } ? Data extends Record<string, unknown> ? Data : Row : Row;
946
+ type BrowserCollectionInsertData<Row extends Record<string, unknown>, Insert extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Insert : Insert extends {
947
+ data: infer Data;
948
+ } ? Data extends Record<string, unknown> ? Data : BrowserCollectionRowData<Row> : BrowserCollectionRowData<Row>;
949
+ type BrowserCollectionUpdateData<Row extends Record<string, unknown>, Update extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Update : Update extends {
950
+ data?: infer Data;
951
+ } ? Data extends Record<string, unknown> ? Partial<Data> : Partial<BrowserCollectionRowData<Row>> : Partial<BrowserCollectionRowData<Row>>;
936
952
  interface BrowserCollectionDefinition {
937
953
  id: string;
938
954
  name: string;
@@ -940,40 +956,57 @@ interface BrowserCollectionDefinition {
940
956
  createdAt: string;
941
957
  updatedAt: string;
942
958
  }
943
- interface BrowserCollectionFindParams {
944
- where?: Record<string, unknown>;
959
+ type CollectionWhere<Row extends Record<string, unknown>> = Partial<Row> & Record<string, unknown>;
960
+ type CollectionFilter<Row extends Record<string, unknown>> = {
961
+ [Field in Extract<keyof Row, string>]: {
962
+ field: Field;
963
+ op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
964
+ value: Row[Field];
965
+ };
966
+ }[Extract<keyof Row, string>];
967
+ type BrowserCollectionFindParams<Row extends Record<string, unknown> = Record<string, unknown>> = {
968
+ where?: CollectionWhere<Row>;
945
969
  filters?: Array<{
946
- field: string;
970
+ field: Extract<keyof Row, string> | (string & {});
947
971
  op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
948
972
  value: unknown;
949
- }>;
973
+ } | CollectionFilter<Row>>;
950
974
  limit?: number;
951
975
  offset?: number;
952
- orderBy?: string;
976
+ orderBy?: Extract<keyof Row, string> | (string & {});
953
977
  orderDirection?: "asc" | "desc";
954
- }
955
- declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>> {
978
+ };
979
+ declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> {
956
980
  private readonly database;
957
981
  private readonly name;
958
982
  private readonly databaseInstanceId?;
959
983
  constructor(database: RagableBrowserDatabaseClient<any>, name: string, databaseInstanceId?: string | undefined);
960
- find: (whereOrParams?: Record<string, unknown> | BrowserCollectionFindParams) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
961
- insert: (data: Row) => Promise<PostgrestResult<BrowserCollectionRecord<Row>>>;
962
- update: (where: Record<string, unknown>, patch: Partial<Row>, options?: {
984
+ find: (whereOrParams?: CollectionWhere<BrowserCollectionRowData<Row>> | BrowserCollectionFindParams<BrowserCollectionRowData<Row>>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
985
+ insert: (data: BrowserCollectionInsertData<Row, Insert>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>>>;
986
+ update: (where: CollectionWhere<BrowserCollectionRowData<Row>>, patch: BrowserCollectionUpdateData<Row, Update>, options?: {
963
987
  limit?: number;
964
- }) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
965
- delete: (where: Record<string, unknown>, options?: {
988
+ }) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
989
+ delete: (where: CollectionWhere<BrowserCollectionRowData<Row>>, options?: {
966
990
  limit?: number;
967
991
  }) => Promise<PostgrestResult<{
968
992
  deleted: number;
969
- records: BrowserCollectionRecord<Row>[];
993
+ records: BrowserCollectionRecord<BrowserCollectionRowData<Row>>[];
970
994
  }>>;
971
995
  }
996
+ type BrowserCollections<Database extends RagableDatabase = DefaultRagableDatabase> = [keyof Database["public"]["Tables"]] extends [never] ? Record<string, BrowserCollectionApi<Record<string, unknown>>> : {
997
+ readonly [Name in RagableTableNames<Database>]: BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
998
+ };
999
+ type BrowserCollectionFactory<Database extends RagableDatabase = DefaultRagableDatabase> = {
1000
+ <Name extends RagableTableNames<Database>>(name: Name, databaseInstanceId?: string): BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
1001
+ <Row extends Record<string, unknown>>(name: string, databaseInstanceId?: string): BrowserCollectionApi<Row>;
1002
+ };
972
1003
  declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = DefaultRagableDatabase> {
973
1004
  private readonly options;
974
1005
  private readonly ragableAuth;
975
1006
  private readonly fetchImpl;
976
1007
  private _transport;
1008
+ readonly collections: BrowserCollections<Database>;
1009
+ readonly collection: BrowserCollectionFactory<Database>;
977
1010
  constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
978
1011
  /** @internal Called by RagableBrowser to share the Transport instance. */
979
1012
  _setTransport(transport: Transport): void;
@@ -983,7 +1016,6 @@ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = De
983
1016
  */
984
1017
  from: <TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string) => PostgrestTableApi<Database, TableName>;
985
1018
  private toUrl;
986
- collection: <Row extends Record<string, unknown> = Record<string, unknown>>(name: string, databaseInstanceId?: string) => BrowserCollectionApi<Row>;
987
1019
  defineCollection: (name: string, schema?: Record<string, unknown>, databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition>>;
988
1020
  listCollections: (databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition[]>>;
989
1021
  _requestCollection<T>(method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body?: unknown, databaseInstanceId?: string): Promise<T>;
@@ -1175,4 +1207,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
1175
1207
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1176
1208
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
1177
1209
 
1178
- 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 BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, 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, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, 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, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
1210
+ 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, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, 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, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, 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, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
package/dist/index.d.ts CHANGED
@@ -22,11 +22,9 @@ type RagableTableDefinition<Row extends Record<string, unknown> = Record<string,
22
22
  */
23
23
  interface RagableDatabase {
24
24
  public: {
25
- Tables: Record<string, RagableTableDefinition>;
26
- Views?: Record<string, {
27
- Row: Record<string, unknown>;
28
- }>;
29
- Enums?: Record<string, string>;
25
+ Tables: object;
26
+ Views?: object;
27
+ Enums?: object;
30
28
  };
31
29
  }
32
30
  /**
@@ -928,11 +926,29 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
928
926
  rows: Row[];
929
927
  }
930
928
  interface BrowserCollectionRecord<Row extends Record<string, unknown> = Record<string, unknown>> {
929
+ [key: string]: unknown;
931
930
  id: string;
932
931
  data: Row;
933
932
  createdAt: string;
934
933
  updatedAt: string;
935
934
  }
935
+ /**
936
+ * Collection APIs return record envelopes, but user schema `Row` types should be
937
+ * the JSON row inside `record.data`. If generated app types accidentally use the
938
+ * envelope as `Row`, unwrap it so consumers still get `record.data.<field>`.
939
+ */
940
+ type BrowserCollectionRowData<Row extends Record<string, unknown> = Record<string, unknown>> = Row extends {
941
+ id: string;
942
+ data: infer Data;
943
+ createdAt: string;
944
+ updatedAt: string;
945
+ } ? Data extends Record<string, unknown> ? Data : Row : Row;
946
+ type BrowserCollectionInsertData<Row extends Record<string, unknown>, Insert extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Insert : Insert extends {
947
+ data: infer Data;
948
+ } ? Data extends Record<string, unknown> ? Data : BrowserCollectionRowData<Row> : BrowserCollectionRowData<Row>;
949
+ type BrowserCollectionUpdateData<Row extends Record<string, unknown>, Update extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Update : Update extends {
950
+ data?: infer Data;
951
+ } ? Data extends Record<string, unknown> ? Partial<Data> : Partial<BrowserCollectionRowData<Row>> : Partial<BrowserCollectionRowData<Row>>;
936
952
  interface BrowserCollectionDefinition {
937
953
  id: string;
938
954
  name: string;
@@ -940,40 +956,57 @@ interface BrowserCollectionDefinition {
940
956
  createdAt: string;
941
957
  updatedAt: string;
942
958
  }
943
- interface BrowserCollectionFindParams {
944
- where?: Record<string, unknown>;
959
+ type CollectionWhere<Row extends Record<string, unknown>> = Partial<Row> & Record<string, unknown>;
960
+ type CollectionFilter<Row extends Record<string, unknown>> = {
961
+ [Field in Extract<keyof Row, string>]: {
962
+ field: Field;
963
+ op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
964
+ value: Row[Field];
965
+ };
966
+ }[Extract<keyof Row, string>];
967
+ type BrowserCollectionFindParams<Row extends Record<string, unknown> = Record<string, unknown>> = {
968
+ where?: CollectionWhere<Row>;
945
969
  filters?: Array<{
946
- field: string;
970
+ field: Extract<keyof Row, string> | (string & {});
947
971
  op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
948
972
  value: unknown;
949
- }>;
973
+ } | CollectionFilter<Row>>;
950
974
  limit?: number;
951
975
  offset?: number;
952
- orderBy?: string;
976
+ orderBy?: Extract<keyof Row, string> | (string & {});
953
977
  orderDirection?: "asc" | "desc";
954
- }
955
- declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>> {
978
+ };
979
+ declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> {
956
980
  private readonly database;
957
981
  private readonly name;
958
982
  private readonly databaseInstanceId?;
959
983
  constructor(database: RagableBrowserDatabaseClient<any>, name: string, databaseInstanceId?: string | undefined);
960
- find: (whereOrParams?: Record<string, unknown> | BrowserCollectionFindParams) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
961
- insert: (data: Row) => Promise<PostgrestResult<BrowserCollectionRecord<Row>>>;
962
- update: (where: Record<string, unknown>, patch: Partial<Row>, options?: {
984
+ find: (whereOrParams?: CollectionWhere<BrowserCollectionRowData<Row>> | BrowserCollectionFindParams<BrowserCollectionRowData<Row>>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
985
+ insert: (data: BrowserCollectionInsertData<Row, Insert>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>>>;
986
+ update: (where: CollectionWhere<BrowserCollectionRowData<Row>>, patch: BrowserCollectionUpdateData<Row, Update>, options?: {
963
987
  limit?: number;
964
- }) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
965
- delete: (where: Record<string, unknown>, options?: {
988
+ }) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
989
+ delete: (where: CollectionWhere<BrowserCollectionRowData<Row>>, options?: {
966
990
  limit?: number;
967
991
  }) => Promise<PostgrestResult<{
968
992
  deleted: number;
969
- records: BrowserCollectionRecord<Row>[];
993
+ records: BrowserCollectionRecord<BrowserCollectionRowData<Row>>[];
970
994
  }>>;
971
995
  }
996
+ type BrowserCollections<Database extends RagableDatabase = DefaultRagableDatabase> = [keyof Database["public"]["Tables"]] extends [never] ? Record<string, BrowserCollectionApi<Record<string, unknown>>> : {
997
+ readonly [Name in RagableTableNames<Database>]: BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
998
+ };
999
+ type BrowserCollectionFactory<Database extends RagableDatabase = DefaultRagableDatabase> = {
1000
+ <Name extends RagableTableNames<Database>>(name: Name, databaseInstanceId?: string): BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
1001
+ <Row extends Record<string, unknown>>(name: string, databaseInstanceId?: string): BrowserCollectionApi<Row>;
1002
+ };
972
1003
  declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = DefaultRagableDatabase> {
973
1004
  private readonly options;
974
1005
  private readonly ragableAuth;
975
1006
  private readonly fetchImpl;
976
1007
  private _transport;
1008
+ readonly collections: BrowserCollections<Database>;
1009
+ readonly collection: BrowserCollectionFactory<Database>;
977
1010
  constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
978
1011
  /** @internal Called by RagableBrowser to share the Transport instance. */
979
1012
  _setTransport(transport: Transport): void;
@@ -983,7 +1016,6 @@ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = De
983
1016
  */
984
1017
  from: <TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string) => PostgrestTableApi<Database, TableName>;
985
1018
  private toUrl;
986
- collection: <Row extends Record<string, unknown> = Record<string, unknown>>(name: string, databaseInstanceId?: string) => BrowserCollectionApi<Row>;
987
1019
  defineCollection: (name: string, schema?: Record<string, unknown>, databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition>>;
988
1020
  listCollections: (databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition[]>>;
989
1021
  _requestCollection<T>(method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body?: unknown, databaseInstanceId?: string): Promise<T>;
@@ -1175,4 +1207,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
1175
1207
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1176
1208
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
1177
1209
 
1178
- 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 BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, 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, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, 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, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
1210
+ 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, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, 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, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, 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, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
package/dist/index.js CHANGED
@@ -2321,6 +2321,8 @@ var RagableBrowserDatabaseClient = class {
2321
2321
  this.ragableAuth = ragableAuth;
2322
2322
  __publicField(this, "fetchImpl");
2323
2323
  __publicField(this, "_transport", null);
2324
+ __publicField(this, "collections");
2325
+ __publicField(this, "collection");
2324
2326
  /**
2325
2327
  * PostgREST table access. Instance field so `client.database.from` is always an own,
2326
2328
  * enumerable function (avoids rare prototype/bundler issues).
@@ -2374,9 +2376,6 @@ var RagableBrowserDatabaseClient = class {
2374
2376
  };
2375
2377
  return new PostgrestTableApi(pgFetch, id, table);
2376
2378
  });
2377
- __publicField(this, "collection", (name, databaseInstanceId) => {
2378
- return new BrowserCollectionApi(this, name, databaseInstanceId);
2379
- });
2380
2379
  __publicField(this, "defineCollection", (name, schema, databaseInstanceId) => asPostgrestResponse(
2381
2380
  () => this._requestCollection(
2382
2381
  "POST",
@@ -2459,6 +2458,21 @@ var RagableBrowserDatabaseClient = class {
2459
2458
  )
2460
2459
  });
2461
2460
  this.fetchImpl = bindFetch(options.fetch);
2461
+ this.collections = new Proxy(
2462
+ {},
2463
+ {
2464
+ get: (_target, prop) => {
2465
+ if (typeof prop !== "string") return void 0;
2466
+ if (prop === "then") return void 0;
2467
+ return this.collection(prop);
2468
+ }
2469
+ }
2470
+ );
2471
+ this.collection = ((name, databaseInstanceId) => new BrowserCollectionApi(
2472
+ this,
2473
+ name,
2474
+ databaseInstanceId
2475
+ ));
2462
2476
  }
2463
2477
  /** @internal Called by RagableBrowser to share the Transport instance. */
2464
2478
  _setTransport(transport) {
@@ -2473,7 +2487,7 @@ var RagableBrowserDatabaseClient = class {
2473
2487
  const id = databaseInstanceId?.trim() || this.options.databaseInstanceId?.trim();
2474
2488
  if (!id) {
2475
2489
  throw new RagableError(
2476
- "db.collection() requires databaseInstanceId in client options or as an argument",
2490
+ "db.collections requires databaseInstanceId in client options. For dynamic collection() calls, you can also pass databaseInstanceId as the second argument.",
2477
2491
  400,
2478
2492
  { code: "SDK_MISSING_DATABASE_INSTANCE_ID" }
2479
2493
  );
@@ -2843,7 +2857,7 @@ function createClient(options) {
2843
2857
  if (isServerClientOptions(options)) {
2844
2858
  if (typeof options === "object" && options !== null && "organizationId" in options && typeof options.organizationId === "string") {
2845
2859
  console.warn(
2846
- "[@ragable/sdk] createClient: `apiKey` is set, so the server client is returned. It has no `database` or `auth` \u2014 only `agents` and `shift`. For `db.collection()` / `database.from()` / `auth.*`, use the browser client without `apiKey` (e.g. createClient({ organizationId, authGroupId, databaseInstanceId, ... }))."
2860
+ "[@ragable/sdk] createClient: `apiKey` is set, so the server client is returned. It has no `database` or `auth` \u2014 only `agents` and `shift`. For `db.collections.<name>` / `database.from()` / `auth.*`, use the browser client without `apiKey` (e.g. createClient({ organizationId, authGroupId, databaseInstanceId, ... }))."
2847
2861
  );
2848
2862
  }
2849
2863
  return new Ragable(options);