@ragable/sdk 0.6.23 → 0.6.24

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
@@ -74,10 +74,20 @@ type ColumnValue<D extends RagableDatabase, T extends RagableTableNames<D>, C ex
74
74
  * or the browser throws **Illegal invocation**. Use this for defaults and for `options.fetch`.
75
75
  */
76
76
  declare function bindFetch(custom?: typeof fetch): typeof fetch;
77
- /** Hosted Ragable HTTP API base (`…/api`) used by all SDK clients (not configurable). */
77
+ /** Default hosted Ragable HTTP API base (`…/api`) when **`baseUrl`** is omitted. */
78
78
  declare const DEFAULT_RAGABLE_API_BASE = "https://ragable-341305259977.asia-southeast1.run.app/api";
79
+ /**
80
+ * Normalize the API base (no trailing slash). Use **`DEFAULT_RAGABLE_API_BASE`** when
81
+ * **`explicitBaseUrl`** is missing or blank.
82
+ */
83
+ declare function resolveRagableApiBase(explicitBaseUrl?: string | null | undefined): string;
79
84
  interface RagableClientOptions {
80
85
  apiKey: string;
86
+ /**
87
+ * HTTP API root including the **`/api`** segment, e.g. `https://your-host.com/api`.
88
+ * Defaults to {@link DEFAULT_RAGABLE_API_BASE}.
89
+ */
90
+ baseUrl?: string;
81
91
  fetch?: typeof fetch;
82
92
  headers?: HeadersInit;
83
93
  }
@@ -894,6 +904,8 @@ interface AuthOptions {
894
904
  }
895
905
  interface RagableAuthConfig {
896
906
  authGroupId: string;
907
+ /** HTTP API root (including `/api`); set from the browser client **`baseUrl`** option. */
908
+ baseUrl?: string;
897
909
  fetch?: typeof fetch;
898
910
  headers?: HeadersInit;
899
911
  auth?: AuthOptions;
@@ -1098,8 +1110,11 @@ declare class Transport {
1098
1110
  }
1099
1111
  declare function parseTransportResponse<T>(response: Response): Promise<T>;
1100
1112
 
1101
- /** Canonical browser/server API base (`…/api`, no trailing slash). */
1102
- declare function normalizeBrowserApiBase(): string;
1113
+ /**
1114
+ * Resolved API base (`…/api`, no trailing slash). With no argument, uses the same default as
1115
+ * {@link resolveRagableApiBase}.
1116
+ */
1117
+ declare function normalizeBrowserApiBase(explicitBaseUrl?: string): string;
1103
1118
  type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
1104
1119
  /**
1105
1120
  * Resolves how database requests are authorized. If `dataAuth` is omitted and a
@@ -1111,6 +1126,12 @@ type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
1111
1126
  declare function effectiveDataAuth(options: RagableBrowserClientOptions): BrowserDataAuthMode;
1112
1127
  interface RagableBrowserClientOptions {
1113
1128
  organizationId: string;
1129
+ /**
1130
+ * HTTP API root including **`/api`**, e.g. `https://your-host.com/api` or
1131
+ * `import.meta.env.VITE_RAGABLE_API_BASE`. Trailing slashes are stripped.
1132
+ * When omitted, the package default **`DEFAULT_RAGABLE_API_BASE`** is used.
1133
+ */
1134
+ baseUrl?: string;
1114
1135
  websiteId?: string;
1115
1136
  authGroupId?: string;
1116
1137
  databaseInstanceId?: string;
@@ -1418,6 +1439,7 @@ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = De
1418
1439
  private readonly options;
1419
1440
  private readonly ragableAuth;
1420
1441
  private readonly fetchImpl;
1442
+ private readonly apiBase;
1421
1443
  private _transport;
1422
1444
  readonly collections: BrowserCollections<Database>;
1423
1445
  readonly collection: BrowserCollectionFactory<Database>;
@@ -1541,6 +1563,7 @@ interface AgentConversationSubscription {
1541
1563
  declare class RagableBrowserAgentsClient {
1542
1564
  private readonly options;
1543
1565
  private readonly fetchImpl;
1566
+ private readonly apiBase;
1544
1567
  constructor(options: RagableBrowserClientOptions);
1545
1568
  private toUrl;
1546
1569
  private requireWebsiteId;
@@ -1673,4 +1696,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
1673
1696
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends object = DefaultAuthUser>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1674
1697
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
1675
1698
 
1676
- export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, 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 CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, 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, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, 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, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
1699
+ export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, 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 CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, 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, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, 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, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, resolveRagableApiBase, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
package/dist/index.d.ts CHANGED
@@ -74,10 +74,20 @@ type ColumnValue<D extends RagableDatabase, T extends RagableTableNames<D>, C ex
74
74
  * or the browser throws **Illegal invocation**. Use this for defaults and for `options.fetch`.
75
75
  */
76
76
  declare function bindFetch(custom?: typeof fetch): typeof fetch;
77
- /** Hosted Ragable HTTP API base (`…/api`) used by all SDK clients (not configurable). */
77
+ /** Default hosted Ragable HTTP API base (`…/api`) when **`baseUrl`** is omitted. */
78
78
  declare const DEFAULT_RAGABLE_API_BASE = "https://ragable-341305259977.asia-southeast1.run.app/api";
79
+ /**
80
+ * Normalize the API base (no trailing slash). Use **`DEFAULT_RAGABLE_API_BASE`** when
81
+ * **`explicitBaseUrl`** is missing or blank.
82
+ */
83
+ declare function resolveRagableApiBase(explicitBaseUrl?: string | null | undefined): string;
79
84
  interface RagableClientOptions {
80
85
  apiKey: string;
86
+ /**
87
+ * HTTP API root including the **`/api`** segment, e.g. `https://your-host.com/api`.
88
+ * Defaults to {@link DEFAULT_RAGABLE_API_BASE}.
89
+ */
90
+ baseUrl?: string;
81
91
  fetch?: typeof fetch;
82
92
  headers?: HeadersInit;
83
93
  }
@@ -894,6 +904,8 @@ interface AuthOptions {
894
904
  }
895
905
  interface RagableAuthConfig {
896
906
  authGroupId: string;
907
+ /** HTTP API root (including `/api`); set from the browser client **`baseUrl`** option. */
908
+ baseUrl?: string;
897
909
  fetch?: typeof fetch;
898
910
  headers?: HeadersInit;
899
911
  auth?: AuthOptions;
@@ -1098,8 +1110,11 @@ declare class Transport {
1098
1110
  }
1099
1111
  declare function parseTransportResponse<T>(response: Response): Promise<T>;
1100
1112
 
1101
- /** Canonical browser/server API base (`…/api`, no trailing slash). */
1102
- declare function normalizeBrowserApiBase(): string;
1113
+ /**
1114
+ * Resolved API base (`…/api`, no trailing slash). With no argument, uses the same default as
1115
+ * {@link resolveRagableApiBase}.
1116
+ */
1117
+ declare function normalizeBrowserApiBase(explicitBaseUrl?: string): string;
1103
1118
  type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
1104
1119
  /**
1105
1120
  * Resolves how database requests are authorized. If `dataAuth` is omitted and a
@@ -1111,6 +1126,12 @@ type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
1111
1126
  declare function effectiveDataAuth(options: RagableBrowserClientOptions): BrowserDataAuthMode;
1112
1127
  interface RagableBrowserClientOptions {
1113
1128
  organizationId: string;
1129
+ /**
1130
+ * HTTP API root including **`/api`**, e.g. `https://your-host.com/api` or
1131
+ * `import.meta.env.VITE_RAGABLE_API_BASE`. Trailing slashes are stripped.
1132
+ * When omitted, the package default **`DEFAULT_RAGABLE_API_BASE`** is used.
1133
+ */
1134
+ baseUrl?: string;
1114
1135
  websiteId?: string;
1115
1136
  authGroupId?: string;
1116
1137
  databaseInstanceId?: string;
@@ -1418,6 +1439,7 @@ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = De
1418
1439
  private readonly options;
1419
1440
  private readonly ragableAuth;
1420
1441
  private readonly fetchImpl;
1442
+ private readonly apiBase;
1421
1443
  private _transport;
1422
1444
  readonly collections: BrowserCollections<Database>;
1423
1445
  readonly collection: BrowserCollectionFactory<Database>;
@@ -1541,6 +1563,7 @@ interface AgentConversationSubscription {
1541
1563
  declare class RagableBrowserAgentsClient {
1542
1564
  private readonly options;
1543
1565
  private readonly fetchImpl;
1566
+ private readonly apiBase;
1544
1567
  constructor(options: RagableBrowserClientOptions);
1545
1568
  private toUrl;
1546
1569
  private requireWebsiteId;
@@ -1673,4 +1696,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
1673
1696
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends object = DefaultAuthUser>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1674
1697
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
1675
1698
 
1676
- export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, 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 CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, 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, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, 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, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
1699
+ export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, 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 CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, 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, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, 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, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, resolveRagableApiBase, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
package/dist/index.js CHANGED
@@ -82,6 +82,7 @@ __export(index_exports, {
82
82
  parseSseDataLine: () => parseSseDataLine,
83
83
  parseTransportResponse: () => parseTransportResponse,
84
84
  readSseStream: () => readSseStream,
85
+ resolveRagableApiBase: () => resolveRagableApiBase,
85
86
  runAgentChatStream: () => runAgentChatStream,
86
87
  runAgentChatStreamForUi: () => runAgentChatStreamForUi,
87
88
  runAgentChatStreamLenient: () => runAgentChatStreamLenient,
@@ -98,6 +99,10 @@ function bindFetch(custom) {
98
99
  };
99
100
  }
100
101
  var DEFAULT_RAGABLE_API_BASE = "https://ragable-341305259977.asia-southeast1.run.app/api";
102
+ function resolveRagableApiBase(explicitBaseUrl) {
103
+ const raw = typeof explicitBaseUrl === "string" && explicitBaseUrl.trim().length > 0 ? explicitBaseUrl.trim() : DEFAULT_RAGABLE_API_BASE.trim();
104
+ return raw.replace(/\/+$/, "");
105
+ }
101
106
  var RagableSdkError = class extends Error {
102
107
  constructor(message) {
103
108
  super(message);
@@ -226,7 +231,7 @@ var RagableRequestClient = class {
226
231
  __publicField(this, "fetchImpl");
227
232
  __publicField(this, "defaultHeaders");
228
233
  this.apiKey = options.apiKey;
229
- this.baseUrl = DEFAULT_RAGABLE_API_BASE.replace(/\/+$/, "");
234
+ this.baseUrl = resolveRagableApiBase(options.baseUrl);
230
235
  this.fetchImpl = bindFetch(options.fetch);
231
236
  this.defaultHeaders = options.headers;
232
237
  }
@@ -2250,7 +2255,7 @@ var RagableAuth = class {
2250
2255
  __publicField(this, "broadcast", null);
2251
2256
  __publicField(this, "visibilityHandler", null);
2252
2257
  __publicField(this, "initialized", false);
2253
- this.baseUrl = DEFAULT_RAGABLE_API_BASE.replace(/\/+$/, "");
2258
+ this.baseUrl = resolveRagableApiBase(config.baseUrl);
2254
2259
  this.authGroupId = config.authGroupId;
2255
2260
  this.fetchImpl = bindFetch(config.fetch);
2256
2261
  this.defaultHeaders = config.headers;
@@ -2619,8 +2624,8 @@ function decodeJwtExpiry(jwt) {
2619
2624
  }
2620
2625
 
2621
2626
  // src/browser.ts
2622
- function normalizeBrowserApiBase() {
2623
- return DEFAULT_RAGABLE_API_BASE.replace(/\/+$/, "");
2627
+ function normalizeBrowserApiBase(explicitBaseUrl) {
2628
+ return resolveRagableApiBase(explicitBaseUrl);
2624
2629
  }
2625
2630
  function effectiveDataAuth(options) {
2626
2631
  if (options.dataAuth) return options.dataAuth;
@@ -2911,6 +2916,7 @@ var RagableBrowserDatabaseClient = class {
2911
2916
  this.options = options;
2912
2917
  this.ragableAuth = ragableAuth;
2913
2918
  __publicField(this, "fetchImpl");
2919
+ __publicField(this, "apiBase");
2914
2920
  __publicField(this, "_transport", null);
2915
2921
  __publicField(this, "collections");
2916
2922
  __publicField(this, "collection");
@@ -2934,7 +2940,7 @@ var RagableBrowserDatabaseClient = class {
2934
2940
  }
2935
2941
  const gid = requireAuthGroupId(opts);
2936
2942
  const token = await resolveDatabaseAuthBearer(opts, ragableAuth);
2937
- const apiBase = normalizeBrowserApiBase();
2943
+ const apiBase = this.apiBase;
2938
2944
  const qs = params.searchParams.toString();
2939
2945
  const url = `${apiBase}/auth-groups/${gid}/data/rest/${params.table}${qs ? `?${qs}` : ""}`;
2940
2946
  const headers = new Headers(opts.headers);
@@ -3049,6 +3055,7 @@ var RagableBrowserDatabaseClient = class {
3049
3055
  )
3050
3056
  });
3051
3057
  this.fetchImpl = bindFetch(options.fetch);
3058
+ this.apiBase = resolveRagableApiBase(options.baseUrl);
3052
3059
  this.collections = new Proxy(
3053
3060
  {},
3054
3061
  {
@@ -3070,7 +3077,7 @@ var RagableBrowserDatabaseClient = class {
3070
3077
  this._transport = transport;
3071
3078
  }
3072
3079
  toUrl(path) {
3073
- return `${normalizeBrowserApiBase()}${path.startsWith("/") ? path : `/${path}`}`;
3080
+ return `${this.apiBase}${path.startsWith("/") ? path : `/${path}`}`;
3074
3081
  }
3075
3082
  async _requestCollection(method, path, body, databaseInstanceId) {
3076
3083
  const gid = requireAuthGroupId(this.options);
@@ -3161,7 +3168,7 @@ async function subscribeBrowserRealtime(options, ragableAuth, fetchImpl, params)
3161
3168
  headers.set("Authorization", `Bearer ${token}`);
3162
3169
  headers.set("Content-Type", "application/json");
3163
3170
  const response = await fetchImpl(
3164
- `${normalizeBrowserApiBase()}/auth-groups/${gid}/data/realtime/stream`,
3171
+ `${resolveRagableApiBase(options.baseUrl)}/auth-groups/${gid}/data/realtime/stream`,
3165
3172
  {
3166
3173
  method: "POST",
3167
3174
  headers,
@@ -3294,10 +3301,12 @@ var RagableBrowserAgentsClient = class {
3294
3301
  constructor(options) {
3295
3302
  this.options = options;
3296
3303
  __publicField(this, "fetchImpl");
3304
+ __publicField(this, "apiBase");
3297
3305
  this.fetchImpl = bindFetch(options.fetch);
3306
+ this.apiBase = resolveRagableApiBase(options.baseUrl);
3298
3307
  }
3299
3308
  toUrl(path) {
3300
- return `${normalizeBrowserApiBase()}${path.startsWith("/") ? path : `/${path}`}`;
3309
+ return `${this.apiBase}${path.startsWith("/") ? path : `/${path}`}`;
3301
3310
  }
3302
3311
  requireWebsiteId() {
3303
3312
  const websiteId = this.options.websiteId?.trim();
@@ -3497,6 +3506,7 @@ var RagableBrowser = class {
3497
3506
  if (options.authGroupId) {
3498
3507
  this._ragableAuth = new RagableAuth({
3499
3508
  authGroupId: options.authGroupId,
3509
+ baseUrl: options.baseUrl,
3500
3510
  fetch: options.fetch,
3501
3511
  headers: options.headers,
3502
3512
  auth: options.auth
@@ -3672,6 +3682,7 @@ function createRagableServerClient(options) {
3672
3682
  parseSseDataLine,
3673
3683
  parseTransportResponse,
3674
3684
  readSseStream,
3685
+ resolveRagableApiBase,
3675
3686
  runAgentChatStream,
3676
3687
  runAgentChatStreamForUi,
3677
3688
  runAgentChatStreamLenient,