@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 +27 -4
- package/dist/index.d.ts +27 -4
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,10 @@ function bindFetch(custom) {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
var DEFAULT_RAGABLE_API_BASE = "https://ragable-341305259977.asia-southeast1.run.app/api";
|
|
13
|
+
function resolveRagableApiBase(explicitBaseUrl) {
|
|
14
|
+
const raw = typeof explicitBaseUrl === "string" && explicitBaseUrl.trim().length > 0 ? explicitBaseUrl.trim() : DEFAULT_RAGABLE_API_BASE.trim();
|
|
15
|
+
return raw.replace(/\/+$/, "");
|
|
16
|
+
}
|
|
13
17
|
var RagableSdkError = class extends Error {
|
|
14
18
|
constructor(message) {
|
|
15
19
|
super(message);
|
|
@@ -138,7 +142,7 @@ var RagableRequestClient = class {
|
|
|
138
142
|
__publicField(this, "fetchImpl");
|
|
139
143
|
__publicField(this, "defaultHeaders");
|
|
140
144
|
this.apiKey = options.apiKey;
|
|
141
|
-
this.baseUrl =
|
|
145
|
+
this.baseUrl = resolveRagableApiBase(options.baseUrl);
|
|
142
146
|
this.fetchImpl = bindFetch(options.fetch);
|
|
143
147
|
this.defaultHeaders = options.headers;
|
|
144
148
|
}
|
|
@@ -2162,7 +2166,7 @@ var RagableAuth = class {
|
|
|
2162
2166
|
__publicField(this, "broadcast", null);
|
|
2163
2167
|
__publicField(this, "visibilityHandler", null);
|
|
2164
2168
|
__publicField(this, "initialized", false);
|
|
2165
|
-
this.baseUrl =
|
|
2169
|
+
this.baseUrl = resolveRagableApiBase(config.baseUrl);
|
|
2166
2170
|
this.authGroupId = config.authGroupId;
|
|
2167
2171
|
this.fetchImpl = bindFetch(config.fetch);
|
|
2168
2172
|
this.defaultHeaders = config.headers;
|
|
@@ -2531,8 +2535,8 @@ function decodeJwtExpiry(jwt) {
|
|
|
2531
2535
|
}
|
|
2532
2536
|
|
|
2533
2537
|
// src/browser.ts
|
|
2534
|
-
function normalizeBrowserApiBase() {
|
|
2535
|
-
return
|
|
2538
|
+
function normalizeBrowserApiBase(explicitBaseUrl) {
|
|
2539
|
+
return resolveRagableApiBase(explicitBaseUrl);
|
|
2536
2540
|
}
|
|
2537
2541
|
function effectiveDataAuth(options) {
|
|
2538
2542
|
if (options.dataAuth) return options.dataAuth;
|
|
@@ -2823,6 +2827,7 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2823
2827
|
this.options = options;
|
|
2824
2828
|
this.ragableAuth = ragableAuth;
|
|
2825
2829
|
__publicField(this, "fetchImpl");
|
|
2830
|
+
__publicField(this, "apiBase");
|
|
2826
2831
|
__publicField(this, "_transport", null);
|
|
2827
2832
|
__publicField(this, "collections");
|
|
2828
2833
|
__publicField(this, "collection");
|
|
@@ -2846,7 +2851,7 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2846
2851
|
}
|
|
2847
2852
|
const gid = requireAuthGroupId(opts);
|
|
2848
2853
|
const token = await resolveDatabaseAuthBearer(opts, ragableAuth);
|
|
2849
|
-
const apiBase =
|
|
2854
|
+
const apiBase = this.apiBase;
|
|
2850
2855
|
const qs = params.searchParams.toString();
|
|
2851
2856
|
const url = `${apiBase}/auth-groups/${gid}/data/rest/${params.table}${qs ? `?${qs}` : ""}`;
|
|
2852
2857
|
const headers = new Headers(opts.headers);
|
|
@@ -2961,6 +2966,7 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2961
2966
|
)
|
|
2962
2967
|
});
|
|
2963
2968
|
this.fetchImpl = bindFetch(options.fetch);
|
|
2969
|
+
this.apiBase = resolveRagableApiBase(options.baseUrl);
|
|
2964
2970
|
this.collections = new Proxy(
|
|
2965
2971
|
{},
|
|
2966
2972
|
{
|
|
@@ -2982,7 +2988,7 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2982
2988
|
this._transport = transport;
|
|
2983
2989
|
}
|
|
2984
2990
|
toUrl(path) {
|
|
2985
|
-
return `${
|
|
2991
|
+
return `${this.apiBase}${path.startsWith("/") ? path : `/${path}`}`;
|
|
2986
2992
|
}
|
|
2987
2993
|
async _requestCollection(method, path, body, databaseInstanceId) {
|
|
2988
2994
|
const gid = requireAuthGroupId(this.options);
|
|
@@ -3073,7 +3079,7 @@ async function subscribeBrowserRealtime(options, ragableAuth, fetchImpl, params)
|
|
|
3073
3079
|
headers.set("Authorization", `Bearer ${token}`);
|
|
3074
3080
|
headers.set("Content-Type", "application/json");
|
|
3075
3081
|
const response = await fetchImpl(
|
|
3076
|
-
`${
|
|
3082
|
+
`${resolveRagableApiBase(options.baseUrl)}/auth-groups/${gid}/data/realtime/stream`,
|
|
3077
3083
|
{
|
|
3078
3084
|
method: "POST",
|
|
3079
3085
|
headers,
|
|
@@ -3206,10 +3212,12 @@ var RagableBrowserAgentsClient = class {
|
|
|
3206
3212
|
constructor(options) {
|
|
3207
3213
|
this.options = options;
|
|
3208
3214
|
__publicField(this, "fetchImpl");
|
|
3215
|
+
__publicField(this, "apiBase");
|
|
3209
3216
|
this.fetchImpl = bindFetch(options.fetch);
|
|
3217
|
+
this.apiBase = resolveRagableApiBase(options.baseUrl);
|
|
3210
3218
|
}
|
|
3211
3219
|
toUrl(path) {
|
|
3212
|
-
return `${
|
|
3220
|
+
return `${this.apiBase}${path.startsWith("/") ? path : `/${path}`}`;
|
|
3213
3221
|
}
|
|
3214
3222
|
requireWebsiteId() {
|
|
3215
3223
|
const websiteId = this.options.websiteId?.trim();
|
|
@@ -3409,6 +3417,7 @@ var RagableBrowser = class {
|
|
|
3409
3417
|
if (options.authGroupId) {
|
|
3410
3418
|
this._ragableAuth = new RagableAuth({
|
|
3411
3419
|
authGroupId: options.authGroupId,
|
|
3420
|
+
baseUrl: options.baseUrl,
|
|
3412
3421
|
fetch: options.fetch,
|
|
3413
3422
|
headers: options.headers,
|
|
3414
3423
|
auth: options.auth
|
|
@@ -3583,6 +3592,7 @@ export {
|
|
|
3583
3592
|
parseSseDataLine,
|
|
3584
3593
|
parseTransportResponse,
|
|
3585
3594
|
readSseStream,
|
|
3595
|
+
resolveRagableApiBase,
|
|
3586
3596
|
runAgentChatStream,
|
|
3587
3597
|
runAgentChatStreamForUi,
|
|
3588
3598
|
runAgentChatStreamLenient,
|